1、接口实现

This commit is contained in:
asypost committed 2026-06-20 16:11:17 +08:00
1 parent d306f261bd
commit cc2fdef069
14 files changed
+757 -34

No files matched your search

+48 -11
View File
@@ -1,15 +1,52 @@
#include "seafile/seafile_api.hpp"
#include <iostream>
#include <winfsp/winfsp.h>
int main(int argc,char** argv) {
seafile::SeaFileApi api("https://pan.hanwangsoft.com/");
if (const auto token = api.authToken("asypost@yeah.net","Shell0805@china"); token.has_value()) {
std::cout<<token.value<seafile::AuthToken>().token<<std::endl;
}else {
std::cout<<token.error().what()<<std::endl;
#include "seafile/fs/seafile_file_system.hpp"
using namespace seafile::fs;
static std::shared_ptr<SeafileFileSystem> file_system = nullptr;
static NTSTATUS GetVolumeInfo(
FSP_FILE_SYSTEM* FileSystem,
FSP_FSCTL_VOLUME_INFO* VolumeInfo)
{
const auto fs = static_cast<SeafileFileSystem*>(FileSystem->UserContext);
return fs->GetVolumeInfo(VolumeInfo);
}
static FSP_FILE_SYSTEM_INTERFACE seafile_interface = {
.GetVolumeInfo = GetVolumeInfo
};
static
NTSTATUS SvcStart(FSP_SERVICE* Service, ULONG argc, PWSTR* argv) // (2)
{
if (file_system)
{
return file_system->SvcStart(Service, argc, argv);
}
if (const auto server = api.serverInfo(); server.has_value()) {
std::cout<<server.value<seafile::ServerInfo>().version<<std::endl;
return STATUS_NOT_IMPLEMENTED;
}
static
NTSTATUS SvcStop(FSP_SERVICE* Service) // (3)
{
if (file_system)
{
return file_system->SvcStop(Service);
}
return 0;
}
return STATUS_NOT_IMPLEMENTED;
}
int wmain(int argc, wchar_t** argv)
{
if (!NT_SUCCESS(FspLoad(nullptr)))
return ERROR_DELAY_LOAD_FAILED;
file_system = std::make_shared<SeafileFileSystem>(std::wstring("X:"));
file_system->auth("asypost@yeah.net","Shell0805@china");
return FspServiceRun(const_cast<PWSTR>(L"SeaDisk"), SvcStart, SvcStop, nullptr);
}
+16
View File
@@ -0,0 +1,16 @@
//
// Created by Shell on 2026-06-18.
//
#include "seafile/fs/seafile_file_system.hpp"
namespace seafile::fs
{
void SeafileFileSystem::auth(const std::string& username, const std::string& password)
{
if (const auto authToken = api.authToken(username, password); authToken.has_value())
{
this->token = authToken.value().token;
}
}
}