refactor
This commit is contained in:
parent
857dcc5535
commit
924b79add2
@ -39,11 +39,12 @@ public:
|
|||||||
: mount_location_(std::move(mount_location)) {}
|
: mount_location_(std::move(mount_location)) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::string mount_location_;
|
std::string mount_location_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] auto get_directory_item_count(
|
[[nodiscard]] auto
|
||||||
const std::string & /*api_path*/) const -> std::uint64_t override {
|
get_directory_item_count(const std::string & /*api_path*/) const
|
||||||
|
-> std::uint64_t override {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,9 +55,8 @@ public:
|
|||||||
directory_item di{};
|
directory_item di{};
|
||||||
di.api_path = ".";
|
di.api_path = ".";
|
||||||
di.directory = true;
|
di.directory = true;
|
||||||
di.size = 0u;
|
di.size = 0U;
|
||||||
di.meta = {
|
di.meta = {{META_ATTRIBUTES, "16"},
|
||||||
{META_ATTRIBUTES, "16"},
|
|
||||||
{META_MODIFIED, std::to_string(utils::time::get_time_now())},
|
{META_MODIFIED, std::to_string(utils::time::get_time_now())},
|
||||||
{META_WRITTEN, std::to_string(utils::time::get_time_now())},
|
{META_WRITTEN, std::to_string(utils::time::get_time_now())},
|
||||||
{META_ACCESSED, std::to_string(utils::time::get_time_now())},
|
{META_ACCESSED, std::to_string(utils::time::get_time_now())},
|
||||||
@ -75,7 +75,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto get_item_meta(const std::string & /*api_path*/,
|
auto get_item_meta(const std::string & /*api_path*/,
|
||||||
api_meta_map &meta) const -> api_error override {
|
api_meta_map & /* meta */) const -> api_error override {
|
||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,19 +85,19 @@ public:
|
|||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto
|
auto get_security_by_name(PWSTR /*file_name*/, PUINT32 attributes,
|
||||||
get_security_by_name(PWSTR /*file_name*/, PUINT32 attributes,
|
|
||||||
PSECURITY_DESCRIPTOR descriptor,
|
PSECURITY_DESCRIPTOR descriptor,
|
||||||
std::uint64_t *descriptor_size) -> NTSTATUS override {
|
std::uint64_t *descriptor_size)
|
||||||
|
-> NTSTATUS override {
|
||||||
auto ret = STATUS_SUCCESS;
|
auto ret = STATUS_SUCCESS;
|
||||||
|
|
||||||
if (attributes) {
|
if (attributes != nullptr) {
|
||||||
*attributes = FILE_ATTRIBUTE_NORMAL;
|
*attributes = FILE_ATTRIBUTE_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (descriptor_size) {
|
if (descriptor_size) {
|
||||||
ULONG sz = 0;
|
ULONG sz{0U};
|
||||||
PSECURITY_DESCRIPTOR sd = nullptr;
|
PSECURITY_DESCRIPTOR sd{nullptr};
|
||||||
if (::ConvertStringSecurityDescriptorToSecurityDescriptor(
|
if (::ConvertStringSecurityDescriptorToSecurityDescriptor(
|
||||||
"O:BAG:BAD:P(A;;FA;;;SY)(A;;FA;;;BA)(A;;FA;;;WD)",
|
"O:BAG:BAD:P(A;;FA;;;SY)(A;;FA;;;BA)(A;;FA;;;WD)",
|
||||||
SDDL_REVISION_1, &sd, &sz)) {
|
SDDL_REVISION_1, &sd, &sz)) {
|
||||||
@ -117,21 +117,21 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto get_total_drive_space() const -> std::uint64_t override {
|
[[nodiscard]] auto get_total_drive_space() const -> std::uint64_t override {
|
||||||
return 100 * 1024 * 1024;
|
return 100ULL * 1024ULL * 1024ULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto get_total_item_count() const -> std::uint64_t override {
|
[[nodiscard]] auto get_total_item_count() const -> std::uint64_t override {
|
||||||
return 0;
|
return 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto get_used_drive_space() const -> std::uint64_t override {
|
[[nodiscard]] auto get_used_drive_space() const -> std::uint64_t override {
|
||||||
return 0;
|
return 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_volume_info(UINT64 &total_size, UINT64 &free_size,
|
void get_volume_info(UINT64 &total_size, UINT64 &free_size,
|
||||||
std::string &volume_label) const override {
|
std::string &volume_label) const override {
|
||||||
free_size = 100;
|
free_size = 100U;
|
||||||
total_size = 200;
|
total_size = 200U;
|
||||||
volume_label = "TestVolumeLabel";
|
volume_label = "TestVolumeLabel";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,10 +162,10 @@ public:
|
|||||||
WINFSP_ALLOCATION_UNIT) *
|
WINFSP_ALLOCATION_UNIT) *
|
||||||
WINFSP_ALLOCATION_UNIT;
|
WINFSP_ALLOCATION_UNIT;
|
||||||
file_info.FileAttributes = fi.FileAttributes;
|
file_info.FileAttributes = fi.FileAttributes;
|
||||||
file_info.ChangeTime = fi.ChangeTime.QuadPart;
|
file_info.ChangeTime = static_cast<UINT64>(fi.ChangeTime.QuadPart);
|
||||||
file_info.CreationTime = fi.CreationTime.QuadPart;
|
file_info.CreationTime = static_cast<UINT64>(fi.CreationTime.QuadPart);
|
||||||
file_info.LastAccessTime = fi.LastAccessTime.QuadPart;
|
file_info.LastAccessTime = static_cast<UINT64>(fi.LastAccessTime.QuadPart);
|
||||||
file_info.LastWriteTime = fi.LastWriteTime.QuadPart;
|
file_info.LastWriteTime = static_cast<UINT64>(fi.LastWriteTime.QuadPart);
|
||||||
::CloseHandle(handle);
|
::CloseHandle(handle);
|
||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
@ -436,15 +436,17 @@ static void set_basic_info_test(remote_client &client) {
|
|||||||
const auto change_time = last_write_time;
|
const auto change_time = last_write_time;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EXPECT_EQ(STATUS_SUCCESS,
|
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_set_basic_info(
|
||||||
client.winfsp_set_basic_info(file_desc, attributes, creation_time,
|
file_desc, static_cast<UINT32>(attributes),
|
||||||
last_access_time, last_write_time,
|
static_cast<UINT64>(creation_time),
|
||||||
change_time, &fi));
|
static_cast<UINT64>(last_access_time),
|
||||||
EXPECT_EQ(static_cast<std::uint32_t>(attributes), fi.FileAttributes);
|
static_cast<UINT64>(last_write_time),
|
||||||
EXPECT_EQ(creation_time, fi.CreationTime);
|
static_cast<UINT64>(change_time), &fi));
|
||||||
EXPECT_EQ(last_access_time, fi.LastAccessTime);
|
EXPECT_EQ(static_cast<UINT32>(attributes), fi.FileAttributes);
|
||||||
EXPECT_EQ(last_write_time, fi.LastWriteTime);
|
EXPECT_EQ(static_cast<UINT64>(creation_time), fi.CreationTime);
|
||||||
EXPECT_EQ(change_time, fi.ChangeTime);
|
EXPECT_EQ(static_cast<UINT64>(last_access_time), fi.LastAccessTime);
|
||||||
|
EXPECT_EQ(static_cast<UINT64>(last_write_time), fi.LastWriteTime);
|
||||||
|
EXPECT_EQ(static_cast<UINT64>(change_time), fi.ChangeTime);
|
||||||
|
|
||||||
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user