This commit is contained in:
Scott E. Graves 2024-10-09 13:41:32 -05:00
parent 3fa16fd846
commit d20ed07066
7 changed files with 48 additions and 17 deletions

View File

@ -34,15 +34,15 @@ protected:
protected:
struct compat_open_info {
std::size_t count = 0u;
std::string client_id = "";
std::size_t count{0U};
std::string client_id;
std::string path;
};
struct open_info {
std::size_t count = 0u;
std::string client_id = "";
PVOID directory_buffer = nullptr;
std::size_t count{0U};
std::string client_id;
PVOID directory_buffer{nullptr};
std::string path;
};

View File

@ -172,10 +172,16 @@ public:
get_handles() const -> std::vector<std::uint64_t> override;
[[nodiscard]] auto
get_open_data() const -> std::map<std::uint64_t, open_file_data> override;
get_open_data() -> std::map<std::uint64_t, open_file_data> & override;
[[nodiscard]] auto get_open_data() const
-> const std::map<std::uint64_t, open_file_data> & override;
[[nodiscard]] auto
get_open_data(std::uint64_t handle) const -> open_file_data override;
get_open_data(std::uint64_t handle) -> open_file_data & override;
[[nodiscard]] auto get_open_data(std::uint64_t handle) const
-> const open_file_data & override;
[[nodiscard]] auto get_open_file_count() const -> std::size_t override;

View File

@ -41,10 +41,16 @@ public:
[[nodiscard]] virtual auto get_filesystem_item() const -> filesystem_item = 0;
[[nodiscard]] virtual auto
get_open_data() const -> std::map<std::uint64_t, open_file_data> = 0;
get_open_data() -> std::map<std::uint64_t, open_file_data> & = 0;
[[nodiscard]] virtual auto
get_open_data(std::uint64_t handle) const -> open_file_data = 0;
get_open_data() const -> const std::map<std::uint64_t, open_file_data> & = 0;
[[nodiscard]] virtual auto
get_open_data(std::uint64_t handle) -> open_file_data & = 0;
[[nodiscard]] virtual auto
get_open_data(std::uint64_t handle) const -> const open_file_data & = 0;
[[nodiscard]] virtual auto get_open_file_count() const -> std::size_t = 0;

View File

@ -150,7 +150,7 @@ enum class provider_type : std::size_t {
#if defined(_WIN32)
struct open_file_data final {
void *directory_buffer{};
PVOID directory_buffer{nullptr};
};
#else
using open_file_data = int;

View File

@ -273,7 +273,7 @@ VOID winfsp_drive::Close(PVOID /*file_node*/, PVOID file_desc) {
auto handle =
static_cast<std::uint64_t>(reinterpret_cast<std::uintptr_t>(file_desc));
if (handle != 0U) {
PVOID directory_buffer = nullptr;
PVOID directory_buffer{nullptr};
std::shared_ptr<i_open_file> file;
if (fm_->get_open_file(handle, false, file)) {
@ -286,6 +286,7 @@ VOID winfsp_drive::Close(PVOID /*file_node*/, PVOID file_desc) {
FspFileSystemDeleteDirectoryBuffer(&directory_buffer);
}
}
RAISE_WINFSP_EVENT(function_name, api_path, 0);
}

View File

@ -164,14 +164,26 @@ auto file_manager::open_file_base::get_handles() const
return ret;
}
auto file_manager::open_file_base::get_open_data() const
-> std::map<std::uint64_t, open_file_data> {
auto file_manager::open_file_base::get_open_data()
-> std::map<std::uint64_t, open_file_data> & {
recur_mutex_lock file_lock(file_mtx_);
return open_data_;
}
auto file_manager::open_file_base::get_open_data() const
-> const std::map<std::uint64_t, open_file_data> & {
recur_mutex_lock file_lock(file_mtx_);
return open_data_;
}
auto file_manager::open_file_base::get_open_data(std::uint64_t handle)
-> open_file_data & {
recur_mutex_lock file_lock(file_mtx_);
return open_data_.at(handle);
}
auto file_manager::open_file_base::get_open_data(std::uint64_t handle) const
-> open_file_data {
-> const open_file_data & {
recur_mutex_lock file_lock(file_mtx_);
return open_data_.at(handle);
}

View File

@ -37,7 +37,10 @@ public:
MOCK_METHOD(filesystem_item, get_filesystem_item, (), (const, override));
MOCK_METHOD(open_file_data, get_open_data, (std::uint64_t handle),
MOCK_METHOD(open_file_data &, get_open_data, (std::uint64_t handle),
(override));
MOCK_METHOD(const open_file_data &, get_open_data, (std::uint64_t handle),
(const, override));
MOCK_METHOD(std::size_t, get_open_file_count, (), (const, override));
@ -82,8 +85,11 @@ public:
MOCK_METHOD(std::vector<std::uint64_t>, get_handles, (), (const, override));
MOCK_METHOD((std::map<std::uint64_t, open_file_data>), get_open_data, (),
(const, override));
MOCK_METHOD((std::map<std::uint64_t, open_file_data> &), get_open_data, (),
(override));
MOCK_METHOD((const std::map<std::uint64_t, open_file_data> &), get_open_data,
(), (const, override));
MOCK_METHOD(bool, is_complete, (), (const, override));