mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-20 00:20:47 +00:00
43 lines
826 B
C++
43 lines
826 B
C++
/*
|
|
* Copyright (C) 2014-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.1
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include <filesystem>
|
|
#include <seastar/core/sstring.hh>
|
|
#include <seastar/core/future.hh>
|
|
|
|
#include "seastarx.hh"
|
|
|
|
namespace fs = std::filesystem;
|
|
|
|
namespace utils {
|
|
class file_lock {
|
|
public:
|
|
file_lock() = delete;
|
|
file_lock(const file_lock&) = delete;
|
|
file_lock(file_lock&&) noexcept;
|
|
~file_lock();
|
|
|
|
file_lock& operator=(file_lock&&) = default;
|
|
|
|
static future<file_lock> acquire(fs::path);
|
|
|
|
fs::path path() const;
|
|
sstring to_string() const {
|
|
return path().native();
|
|
}
|
|
private:
|
|
class impl;
|
|
file_lock(fs::path);
|
|
std::unique_ptr<impl> _impl;
|
|
};
|
|
}
|
|
|