1、实现目录读取功能

This commit is contained in:
asypost committed 2026-06-27 18:37:37 +08:00
1 parent 6e60886fd3
commit fe476dff69
11 files changed
+320 -116

No files matched your search

+11
View File
@@ -9,12 +9,23 @@ namespace seafile::fs
{
struct SeaFileContext final
{
enum class Type
{
FILE,
DIRECTORY,
};
std::string repo_id;
std::string path;
Type type;
uint64_t size{};
std::string download_url;
};
}
+4 -5
View File
@@ -9,7 +9,6 @@
#include "seafile/seafile_api.hpp"
#include "seafile/token_type.hpp"
#include "seafile/fs/file_context.hpp"
namespace seafile::fs
{
@@ -19,15 +18,15 @@ namespace seafile::fs
std::string token;
TokenType token_type = TokenType::TOKEN;
SeaFileApi api;
std::wstring mount_point;
std::wstring volume_label;
public:
explicit SeafileFileSystem(const std::string& server,
const std::wstring& mount_point) : api(server), mount_point(mount_point)
const std::wstring& volume_label) : api(server), volume_label(volume_label)
{
}
void auth(const std::string& username, const std::string& password);
tl::expected<void, SeafileException> initialize(const std::string& username, const std::string& password);
SeafileFileSystem(const SeafileFileSystem&) = delete;
@@ -37,7 +36,7 @@ namespace seafile::fs
SeafileFileSystem& operator=(SeafileFileSystem&&) = delete;
NTSTATUS GetVolumeInfo(FSP_FSCTL_VOLUME_INFO* VolumeInfo);
NTSTATUS GetVolumeInfo(FSP_FSCTL_VOLUME_INFO* VolumeInfo) const;
NTSTATUS SetVolumeLabel_(PWSTR VolumeLabel,
FSP_FSCTL_VOLUME_INFO* VolumeInfo);
+1
View File
@@ -7,6 +7,7 @@
#include <optional>
#include <string>
#include <nlohmann/json.hpp>
#include <winfsp/fsctl.h>
namespace seafile
{
+16
View File
@@ -16,6 +16,7 @@
#include "account_info.hpp"
#include "auth_token.hpp"
#include "default_repo.hpp"
#include "dir_info.hpp"
#include "file_info.hpp"
#include "repo_entry.hpp"
#include "repo_info.hpp"
@@ -272,6 +273,21 @@ namespace seafile
return download_url;
}
}
tl::expected<DirInfo, SeafileException> dirDetail(const std::string& repo_id, const std::string& path,
const std::string& token, const TokenType token_type) const
{
const auto auth = makeAuthToken(token, token_type);
const auto url = cpr::Url{makeUrl(std::format("/api/v2.1/repos/{}/dir/detail/", repo_id))};
const auto response = cpr::Get(url, cpr::Header{
{"accept", "application/json"},
{"authorization", auth}
}, cpr::Parameters{
{"path", path}
});
return parseResponse<DirInfo>(response);
}
};
}