Files
seadisk/include/seafile/fs/seafile_file_system.hpp
T
2026-07-30 20:59:22 +08:00

85 lines
2.8 KiB
C++

//
// Created by Shell on 2026-06-18.
//
#ifndef SEADISK_SEAFILE_FILE_SYSTEM_HPP
#define SEADISK_SEAFILE_FILE_SYSTEM_HPP
#include <memory>
#include <string>
#include <winfsp/winfsp.h>
#include "seafile/api/seafile_api.hpp"
#include "seafile/fs/seafile_store.hpp"
#include "seafile/fs/storage/repo_entry.hpp"
#include "seafile/fs/storage/repo_info.hpp"
namespace seafile::fs
{
class SeafileFileSystem final
{
using SeafileException = api::SeafileException;
std::unique_ptr<SeafileStore> store;
std::wstring volume_label;
public:
explicit SeafileFileSystem(std::unique_ptr<SeafileStore> store,
const std::wstring& volume_label)
: store(std::move(store)), volume_label(volume_label)
{
}
tl::expected<void, SeafileException> initialize();
SeafileFileSystem(const SeafileFileSystem&) = delete;
SeafileFileSystem(SeafileFileSystem&&) = delete;
SeafileFileSystem& operator=(const SeafileFileSystem&) = delete;
SeafileFileSystem& operator=(SeafileFileSystem&&) = delete;
NTSTATUS GetVolumeInfo(FSP_FSCTL_VOLUME_INFO* VolumeInfo) const;
NTSTATUS SetVolumeLabel_(PWSTR VolumeLabel,
FSP_FSCTL_VOLUME_INFO* VolumeInfo);
NTSTATUS GetSecurityByName(PWSTR FileName,
PUINT32 PFileAttributes,
PSECURITY_DESCRIPTOR SecurityDescriptor,
SIZE_T* PSecurityDescriptorSize);
NTSTATUS Create(PWSTR FileName, UINT32 CreateOptions,
UINT32 GrantedAccess, UINT32 FileAttributes, PSECURITY_DESCRIPTOR SecurityDescriptor,
UINT64 AllocationSize, PVOID* PFileContext, FSP_FSCTL_FILE_INFO* FileInfo);
NTSTATUS Open(
PWSTR FileName,
UINT32 CreateOptions,
UINT32 GrantedAccess,
PVOID* PFileContext,
FSP_FSCTL_FILE_INFO* FileInfo);
NTSTATUS Read(PVOID FileContext, PVOID Buffer, UINT64 Offset, ULONG Length,
PULONG PBytesTransferred);
NTSTATUS GetFileInfo(HANDLE Handle, FSP_FSCTL_FILE_INFO* FileInfo);
VOID Close(PVOID FileContext0);
VOID Cleanup(PVOID FileContext, PWSTR FileName, ULONG Flags);
NTSTATUS Overwrite(
PVOID FileContext, UINT32 FileAttributes, BOOLEAN ReplaceFileAttributes, UINT64 AllocationSize,
FSP_FSCTL_FILE_INFO* FileInfo);
NTSTATUS ReadDirectory(PVOID FileContext, PWSTR Pattern, PWSTR Marker,
PVOID Buffer, ULONG BufferLength, PULONG PBytesTransferred);
NTSTATUS GetDirInfoByName(PVOID FileContext, PWSTR FileName,
FSP_FSCTL_DIR_INFO* DirInfo);
};
}
#endif //SEADISK_SEAFILE_FILE_SYSTEM_HPP