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);
}
};
}
+22
View File
@@ -0,0 +1,22 @@
//
// Created by Shell on 2026-04-13.
//
#ifndef FORCAST_API_ICU_RAII_H
#define FORCAST_API_ICU_RAII_H
#include <unicode/ucsdet.h>
struct UCharsetDetectorDeleter final
{
void operator ()(UCharsetDetector* ptr) const
{
if (ptr)
{
ucsdet_close(ptr);
}
}
};
using UCharsetDetectorPtr = std::unique_ptr<UCharsetDetector, UCharsetDetectorDeleter>;
#endif //FORCAST_API_ICU_RAII_H
+27
View File
@@ -0,0 +1,27 @@
//
// Created by Shell on 2025-12-17.
//
#ifndef FORCAST_API_CLIENT_STRING_UTIL_HPP
#define FORCAST_API_CLIENT_STRING_UTIL_HPP
#include <string>
#include <vector>
namespace shell::util {
class StringUtil final {
public:
static std::vector<std::string> split(const std::string &s, const std::string &delim);
static std::string convert_encoding(const std::string& input,const std::string& from,const std::string& to);
static std::string detect_encoding(const std::string& data);
static std::string convert_encoding(const std::string& input,const std::string& to);
#ifdef _WIN32
static std::wstring utf8_to_utf16le(const std::string& input);
static std::string utf16le_to_utf8(const std::wstring& input);
static std::string utf16le_to_utf8(const wchar_t* input);
};
#endif
}
#endif //FORCAST_API_CLIENT_STRING_UTIL_HPP