初步实现
This commit is contained in:
1 parent
fe476dff69
commit
bf9496e702
1 file changed
+16
-13
@@ -15,6 +15,14 @@ namespace seafile::fs
|
||||
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()
|
||||
{
|
||||
FILETIME ft;
|
||||
@@ -111,15 +119,13 @@ namespace seafile::fs
|
||||
NTSTATUS SeafileFileSystem::Open(PWSTR FileName, UINT32 CreateOptions, UINT32 GrantedAccess, PVOID* PFileContext,
|
||||
FSP_FSCTL_FILE_INFO* FileInfo)
|
||||
{
|
||||
const bool expect_dir = (CreateOptions & FILE_DIRECTORY_FILE) != 0;
|
||||
|
||||
if (repo_id.empty())
|
||||
{
|
||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
const auto path = shell::util::StringUtil::utf16le_to_utf8(FileName);
|
||||
if (wcscmp(FileName, L"\\") == 0)
|
||||
const auto path = normalize_path(shell::util::StringUtil::utf16le_to_utf8(FileName));
|
||||
if (path == "/")
|
||||
{
|
||||
auto repo = api.repoInfo(repo_id, token, token_type);
|
||||
if (!repo.has_value())
|
||||
@@ -130,8 +136,6 @@ namespace seafile::fs
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (expect_dir)
|
||||
{
|
||||
if (const auto dirInfo = api.dirDetail(repo_id, path, token, token_type); dirInfo.has_value())
|
||||
{
|
||||
const auto& info = dirInfo.value();
|
||||
@@ -140,9 +144,8 @@ namespace seafile::fs
|
||||
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())
|
||||
{
|
||||
const auto& info = fileInfo.value();
|
||||
@@ -151,7 +154,7 @@ namespace seafile::fs
|
||||
SetFileInfo(FileInfo,FILE_ATTRIBUTE_ARCHIVE, 0, 0);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -179,7 +182,7 @@ namespace seafile::fs
|
||||
{
|
||||
const auto fc = static_cast<SeaFileContext*>(FileContext);
|
||||
*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);
|
||||
|
||||
if (entries_result.has_value())
|
||||
@@ -200,7 +203,7 @@ namespace seafile::fs
|
||||
}
|
||||
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 size = sizeof(FSP_FSCTL_DIR_INFO) + ((entry_name.size() + 1) * sizeof(WCHAR));
|
||||
|
||||
@@ -233,7 +236,7 @@ namespace seafile::fs
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
std::cout<<entries_result.error().what()<<std::endl;
|
||||
std::cout << entries_result.error().what() << std::endl;
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user