refactor
This commit is contained in:
		| @@ -31,22 +31,25 @@ class i_winfsp_drive { | ||||
|   INTERFACE_SETUP(i_winfsp_drive); | ||||
|  | ||||
| public: | ||||
|   [[nodiscard]] virtual auto get_directory_item_count( | ||||
|       const std::string &api_path) const -> std::uint64_t = 0; | ||||
|  | ||||
|   [[nodiscard]] virtual auto get_directory_items( | ||||
|       const std::string &api_path) const -> directory_item_list = 0; | ||||
|   [[nodiscard]] virtual auto | ||||
|   get_directory_item_count(const std::string &api_path) const | ||||
|       -> std::uint64_t = 0; | ||||
|  | ||||
|   [[nodiscard]] virtual auto | ||||
|   get_file_size(const std::string &api_path) const -> std::uint64_t = 0; | ||||
|   get_directory_items(const std::string &api_path) const | ||||
|       -> directory_item_list = 0; | ||||
|  | ||||
|   [[nodiscard]] virtual auto | ||||
|   get_item_meta(const std::string &api_path, const std::string &name, | ||||
|                 std::string &value) const -> api_error = 0; | ||||
|   [[nodiscard]] virtual auto get_file_size(const std::string &api_path) const | ||||
|       -> std::uint64_t = 0; | ||||
|  | ||||
|   [[nodiscard]] virtual auto | ||||
|   get_item_meta(const std::string &api_path, | ||||
|                 api_meta_map &meta) const -> api_error = 0; | ||||
|   [[nodiscard]] virtual auto get_item_meta(const std::string &api_path, | ||||
|                                            const std::string &name, | ||||
|                                            std::string &value) const | ||||
|       -> api_error = 0; | ||||
|  | ||||
|   [[nodiscard]] virtual auto get_item_meta(const std::string &api_path, | ||||
|                                            api_meta_map &meta) const | ||||
|       -> api_error = 0; | ||||
|  | ||||
|   [[nodiscard]] virtual auto | ||||
|   get_security_by_name(PWSTR file_name, PUINT32 attributes, | ||||
| @@ -62,9 +65,9 @@ public: | ||||
|   virtual void get_volume_info(UINT64 &total_size, UINT64 &free_size, | ||||
|                                std::string &volume_label) const = 0; | ||||
|  | ||||
|   [[nodiscard]] virtual auto | ||||
|   populate_file_info(const std::string &api_path, | ||||
|                      remote::file_info &fi) -> api_error = 0; | ||||
|   [[nodiscard]] virtual auto populate_file_info(const std::string &api_path, | ||||
|                                                 remote::file_info &fi) const | ||||
|       -> api_error = 0; | ||||
| }; | ||||
| } // namespace repertory | ||||
|  | ||||
|   | ||||
| @@ -86,10 +86,10 @@ private: | ||||
|  | ||||
|   void populate_file_info(const std::string &api_path, std::uint64_t file_size, | ||||
|                           const api_meta_map &meta, | ||||
|                           FSP_FSCTL_OPEN_FILE_INFO &ofi); | ||||
|                           FSP_FSCTL_OPEN_FILE_INFO &ofi) const; | ||||
|  | ||||
|   void populate_file_info(std::uint64_t file_size, api_meta_map meta, | ||||
|                           FSP_FSCTL_FILE_INFO &fi); | ||||
|                           FSP_FSCTL_FILE_INFO &fi) const; | ||||
|  | ||||
|   static void set_file_info(remote::file_info &dest, | ||||
|                             const FSP_FSCTL_FILE_INFO &src); | ||||
| @@ -167,7 +167,7 @@ public: | ||||
|                  FileInfo *file_info) -> NTSTATUS override; | ||||
|  | ||||
|   [[nodiscard]] auto populate_file_info(const std::string &api_path, | ||||
|                                         remote::file_info &file_info) | ||||
|                                         remote::file_info &file_info) const | ||||
|       -> api_error override; | ||||
|  | ||||
|   auto Read(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset, | ||||
|   | ||||
| @@ -793,7 +793,7 @@ auto winfsp_drive::parse_mount_location(const std::wstring &mount_location) | ||||
| void winfsp_drive::populate_file_info(const std::string &api_path, | ||||
|                                       std::uint64_t file_size, | ||||
|                                       const api_meta_map &meta, | ||||
|                                       FSP_FSCTL_OPEN_FILE_INFO &ofi) { | ||||
|                                       FSP_FSCTL_OPEN_FILE_INFO &ofi) const { | ||||
|   auto file_path = utils::string::from_utf8( | ||||
|       utils::string::replace_copy(api_path, '/', '\\')); | ||||
|  | ||||
| @@ -805,7 +805,7 @@ void winfsp_drive::populate_file_info(const std::string &api_path, | ||||
| } | ||||
|  | ||||
| auto winfsp_drive::populate_file_info(const std::string &api_path, | ||||
|                                       remote::file_info &file_info) | ||||
|                                       remote::file_info &file_info) const | ||||
|     -> api_error { | ||||
|   api_meta_map meta{}; | ||||
|   auto ret = provider_.get_item_meta(api_path, meta); | ||||
| @@ -820,7 +820,7 @@ auto winfsp_drive::populate_file_info(const std::string &api_path, | ||||
|  | ||||
| void winfsp_drive::populate_file_info(std::uint64_t file_size, | ||||
|                                       api_meta_map meta, | ||||
|                                       FSP_FSCTL_FILE_INFO &file_info) { | ||||
|                                       FSP_FSCTL_FILE_INFO &file_info) const { | ||||
|   file_info.FileSize = file_size; | ||||
|   file_info.AllocationSize = | ||||
|       utils::divide_with_ceiling(file_size, WINFSP_ALLOCATION_UNIT) * | ||||
| @@ -1006,7 +1006,7 @@ auto winfsp_drive::Rename(PVOID /*file_node*/, PVOID /*file_desc*/, | ||||
|  | ||||
|   bool exists{}; | ||||
|   auto res = provider_.is_file(from_api_path, exists); | ||||
|   if res != api_error::success) { | ||||
|   if (res != api_error::success) { | ||||
|     return handle_error(res); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -136,7 +136,8 @@ public: | ||||
|   } | ||||
|  | ||||
|   auto populate_file_info(const std::string &api_path, | ||||
|                           remote::file_info &file_info) -> api_error override { | ||||
|                           remote::file_info &file_info) const | ||||
|       -> api_error override { | ||||
|     auto file_path = utils::path::combine(mount_location_, {api_path}); | ||||
|     auto directory = utils::file::directory(file_path).exists(); | ||||
|     auto attributes = | ||||
|   | ||||
		Reference in New Issue
	
	Block a user