126 lines
6.0 KiB
C++
126 lines
6.0 KiB
C++
/*
|
|
Copyright <2018-2022> <scott.e.graves@protonmail.com>
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all copies or
|
|
substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
|
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
#ifndef INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_CLIENT_HPP_
|
|
#define INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_CLIENT_HPP_
|
|
|
|
#include "common.hpp"
|
|
#include "comm/packet/packet.hpp"
|
|
#include "comm/packet/packet_client.hpp"
|
|
#include "drives/winfsp/remotewinfsp/i_remote_instance.hpp"
|
|
#include "drives/remote/remote_open_file_table.hpp"
|
|
|
|
namespace repertory {
|
|
class app_config;
|
|
namespace remote_winfsp {
|
|
class remote_client final : public remote_open_file_table, public virtual i_remote_instance {
|
|
public:
|
|
explicit remote_client(const app_config &config);
|
|
|
|
private:
|
|
const app_config &config_;
|
|
packet_client packet_client_;
|
|
|
|
private:
|
|
#ifdef _WIN32
|
|
#define to_handle(x) (x)
|
|
#else
|
|
static OSHandle to_handle(PVOID file_desc) {
|
|
return static_cast<OSHandle>(reinterpret_cast<std::uint64_t>(file_desc));
|
|
}
|
|
#endif
|
|
|
|
protected:
|
|
void delete_open_directory(void * /*dir*/) override {}
|
|
|
|
public:
|
|
packet::error_type json_create_directory_snapshot(const std::string &path,
|
|
json &json_data) override;
|
|
|
|
packet::error_type json_read_directory_snapshot(const std::string &path,
|
|
const remote::file_handle &handle,
|
|
const std::uint32_t &page,
|
|
json &json_data) override;
|
|
|
|
packet::error_type json_release_directory_snapshot(const std::string &path,
|
|
const remote::file_handle &handle) override;
|
|
|
|
packet::error_type winfsp_can_delete(PVOID file_desc, PWSTR file_name) override;
|
|
|
|
packet::error_type winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags,
|
|
BOOLEAN &was_closed) override;
|
|
|
|
packet::error_type winfsp_close(PVOID file_desc) override;
|
|
|
|
packet::error_type winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access,
|
|
UINT32 attributes, UINT64 allocation_size, PVOID *file_desc,
|
|
remote::file_info *file_info, std::string &normalized_name,
|
|
BOOLEAN &exists) override;
|
|
|
|
packet::error_type winfsp_flush(PVOID file_desc, remote::file_info *file_info) override;
|
|
|
|
packet::error_type winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) override;
|
|
|
|
packet::error_type winfsp_get_file_info(PVOID file_desc, remote::file_info *file_info) override;
|
|
|
|
packet::error_type winfsp_get_security_by_name(PWSTR file_name, PUINT32 attributes,
|
|
std::uint64_t *descriptor_size,
|
|
std::wstring &string_descriptor) override;
|
|
|
|
packet::error_type winfsp_get_volume_info(UINT64 &total_size, UINT64 &free_size,
|
|
std::string &volume_label) override;
|
|
|
|
packet::error_type winfsp_mounted(const std::wstring &location) override;
|
|
|
|
packet::error_type winfsp_open(PWSTR file_name, UINT32 create_options, UINT32 granted_access,
|
|
PVOID *file_desc, remote::file_info *file_info,
|
|
std::string &normalized_name) override;
|
|
|
|
packet::error_type winfsp_overwrite(PVOID file_desc, UINT32 attributes,
|
|
BOOLEAN replace_attributes, UINT64 allocation_size,
|
|
remote::file_info *file_info) override;
|
|
|
|
packet::error_type winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
|
|
PUINT32 bytes_transferred) override;
|
|
|
|
packet::error_type winfsp_read_directory(PVOID file_desc, PWSTR pattern, PWSTR marker,
|
|
json &itemList) override;
|
|
|
|
packet::error_type winfsp_rename(PVOID file_desc, PWSTR file_name, PWSTR new_file_name,
|
|
BOOLEAN replace_if_exists) override;
|
|
|
|
packet::error_type winfsp_set_basic_info(PVOID file_desc, UINT32 attributes, UINT64 creation_time,
|
|
UINT64 last_access_time, UINT64 last_write_time,
|
|
UINT64 change_time,
|
|
remote::file_info *file_info) override;
|
|
|
|
packet::error_type winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
|
|
BOOLEAN set_allocation_size,
|
|
remote::file_info *file_info) override;
|
|
|
|
packet::error_type winfsp_unmounted(const std::wstring &location) override;
|
|
|
|
packet::error_type winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
|
|
BOOLEAN write_to_end, BOOLEAN constrained_io,
|
|
PUINT32 bytes_transferred, remote::file_info *file_info) override;
|
|
};
|
|
} // namespace remote_winfsp
|
|
} // namespace repertory
|
|
|
|
#endif // INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_CLIENT_HPP_
|