初步实现
This commit is contained in:
1 parent
fe476dff69
commit
bf9496e702
1 file changed
+28
-25
@@ -15,6 +15,14 @@ namespace seafile::fs
|
|||||||
return UNIX_EPOCH_AS_FILETIME + unix_time * HUNDREDS_OF_NANOSECONDS_PER_SECOND;
|
return UNIX_EPOCH_AS_FILETIME + unix_time * HUNDREDS_OF_NANOSECONDS_PER_SECOND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string normalize_path(const std::string& path)
|
||||||
|
{
|
||||||
|
std::string result = path;
|
||||||
|
std::ranges::replace(result, '\\', '/');
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
int64_t NowFileTime()
|
int64_t NowFileTime()
|
||||||
{
|
{
|
||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
@@ -111,15 +119,13 @@ namespace seafile::fs
|
|||||||
NTSTATUS SeafileFileSystem::Open(PWSTR FileName, UINT32 CreateOptions, UINT32 GrantedAccess, PVOID* PFileContext,
|
NTSTATUS SeafileFileSystem::Open(PWSTR FileName, UINT32 CreateOptions, UINT32 GrantedAccess, PVOID* PFileContext,
|
||||||
FSP_FSCTL_FILE_INFO* FileInfo)
|
FSP_FSCTL_FILE_INFO* FileInfo)
|
||||||
{
|
{
|
||||||
const bool expect_dir = (CreateOptions & FILE_DIRECTORY_FILE) != 0;
|
|
||||||
|
|
||||||
if (repo_id.empty())
|
if (repo_id.empty())
|
||||||
{
|
{
|
||||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto path = shell::util::StringUtil::utf16le_to_utf8(FileName);
|
const auto path = normalize_path(shell::util::StringUtil::utf16le_to_utf8(FileName));
|
||||||
if (wcscmp(FileName, L"\\") == 0)
|
if (path == "/")
|
||||||
{
|
{
|
||||||
auto repo = api.repoInfo(repo_id, token, token_type);
|
auto repo = api.repoInfo(repo_id, token, token_type);
|
||||||
if (!repo.has_value())
|
if (!repo.has_value())
|
||||||
@@ -130,28 +136,25 @@ namespace seafile::fs
|
|||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expect_dir)
|
if (const auto dirInfo = api.dirDetail(repo_id, path, token, token_type); dirInfo.has_value())
|
||||||
{
|
{
|
||||||
if (const auto dirInfo = api.dirDetail(repo_id, path, token, token_type); dirInfo.has_value())
|
const auto& info = dirInfo.value();
|
||||||
{
|
const auto ctx = new SeaFileContext{info.repo_id, info.path, SeaFileContext::Type::DIRECTORY, 0, ""};
|
||||||
const auto& info = dirInfo.value();
|
*PFileContext = ctx;
|
||||||
const auto ctx = new SeaFileContext{info.repo_id, info.path, SeaFileContext::Type::DIRECTORY, 0, ""};
|
SetFileInfo(FileInfo,FILE_ATTRIBUTE_DIRECTORY, 0, 0);
|
||||||
*PFileContext = ctx;
|
return STATUS_SUCCESS;
|
||||||
SetFileInfo(FileInfo,FILE_ATTRIBUTE_DIRECTORY, 0, 0);
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
if (const auto fileInfo = api.fileDetail(repo_id, path, token, token_type); fileInfo.has_value())
|
||||||
{
|
{
|
||||||
if (const auto fileInfo = api.fileDetail(repo_id, path, token, token_type); fileInfo.has_value())
|
const auto& info = fileInfo.value();
|
||||||
{
|
const auto ctx = new SeaFileContext(repo_id, path, SeaFileContext::Type::FILE, info.size, "");
|
||||||
const auto& info = fileInfo.value();
|
*PFileContext = ctx;
|
||||||
const auto ctx = new SeaFileContext(repo_id, path, SeaFileContext::Type::FILE, info.size, "");
|
SetFileInfo(FileInfo,FILE_ATTRIBUTE_ARCHIVE, 0, 0);
|
||||||
*PFileContext = ctx;
|
return STATUS_SUCCESS;
|
||||||
SetFileInfo(FileInfo,FILE_ATTRIBUTE_ARCHIVE, 0, 0);
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +182,7 @@ namespace seafile::fs
|
|||||||
{
|
{
|
||||||
const auto fc = static_cast<SeaFileContext*>(FileContext);
|
const auto fc = static_cast<SeaFileContext*>(FileContext);
|
||||||
*PBytesTransferred = 0;
|
*PBytesTransferred = 0;
|
||||||
const auto path = std::ranges::replace(fc->path,'\\','/');
|
const auto path = std::ranges::replace(fc->path, '\\', '/');
|
||||||
const auto entries_result = api.repoDir(fc->repo_id, fc->path, token, token_type);
|
const auto entries_result = api.repoDir(fc->repo_id, fc->path, token, token_type);
|
||||||
|
|
||||||
if (entries_result.has_value())
|
if (entries_result.has_value())
|
||||||
@@ -200,7 +203,7 @@ namespace seafile::fs
|
|||||||
}
|
}
|
||||||
for (auto i = start; i < entries.size(); ++i)
|
for (auto i = start; i < entries.size(); ++i)
|
||||||
{
|
{
|
||||||
const auto entry = entries[i];
|
const auto& entry = entries[i];
|
||||||
const auto entry_name = shell::util::StringUtil::utf8_to_utf16le(entry.name);
|
const auto entry_name = shell::util::StringUtil::utf8_to_utf16le(entry.name);
|
||||||
const auto size = sizeof(FSP_FSCTL_DIR_INFO) + ((entry_name.size() + 1) * sizeof(WCHAR));
|
const auto size = sizeof(FSP_FSCTL_DIR_INFO) + ((entry_name.size() + 1) * sizeof(WCHAR));
|
||||||
|
|
||||||
@@ -233,7 +236,7 @@ namespace seafile::fs
|
|||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout<<entries_result.error().what()<<std::endl;
|
std::cout << entries_result.error().what() << std::endl;
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user