From 7c1c1b46c4b96677b2a442a8a6d776bde6894f7b Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Mon, 3 Apr 2017 23:19:44 -0500 Subject: [PATCH] Fixing stuff --- src/siadrive_api/siafiletree.cpp | 44 ++++++------------------ src/siadrive_dokan_api/siadokandrive.cpp | 10 +++--- 2 files changed, 15 insertions(+), 39 deletions(-) diff --git a/src/siadrive_api/siafiletree.cpp b/src/siadrive_api/siafiletree.cpp index 273d25d..6b043f4 100644 --- a/src/siadrive_api/siafiletree.cpp +++ b/src/siadrive_api/siafiletree.cpp @@ -1,5 +1,6 @@ #include #include +#include using namespace Sia::Api; @@ -72,43 +73,20 @@ std::vector CSiaApi::_CSiaFileTree::QueryDirectories(SString rootFolder { auto fileList = GetFileList(); CSiaFileCollection col; - rootFolder.Replace("/", "\\"); - if (rootFolder[0] == '\\') - { - rootFolder = rootFolder.SubString(1); - } + rootFolder.Replace("/", "\\"); std::vector ret; std::for_each(fileList->begin(), fileList->end(), [&](const CSiaFilePtr& v) { - SString dir = v->GetSiaPath(); - dir.Replace("/", "\\"); - ::PathRemoveFileSpec(&dir[0]); - ::PathRemoveBackslash(&dir[0]); - ::PathRemoveBackslash(&rootFolder[0]); - dir = dir.str().c_str(); - rootFolder = rootFolder.str().c_str(); - if ((dir.Length() > rootFolder.Length()) && (dir.SubString(0, rootFolder.Length()) == rootFolder)) - { - SString subFolder = dir.SubString(rootFolder.Length()); - int idx = subFolder.str().find('\\'); - if (idx == 0) - { - subFolder = subFolder.SubString(1); - idx = subFolder.str().find('\\'); - } - - if (idx > 0) - { - subFolder = subFolder.SubString(0, idx); - } - - auto it = std::find(ret.begin(), ret.end(), subFolder); - if (it == ret.end()) - { - ret.push_back(subFolder); - } - } + SString path = ("\\" + FilePath(v->GetSiaPath()).RemoveFileName()).Replace("/", "\\"); + if (path.BeginsWith(rootFolder)) + { + path = path.SubString(1, rootFolder.Length()); + if (path.Length()) + { + + } + } }); return std::move(ret); diff --git a/src/siadrive_dokan_api/siadokandrive.cpp b/src/siadrive_dokan_api/siadokandrive.cpp index c383820..9c6bc54 100644 --- a/src/siadrive_dokan_api/siadokandrive.cpp +++ b/src/siadrive_dokan_api/siadokandrive.cpp @@ -482,12 +482,13 @@ private: { SString siaFileQuery = CSiaApi::FormatToSiaPath(fileName); SString siaRootPath = CSiaApi::FormatToSiaPath(fileName); - FilePath siaDirQuery = siaFileQuery; + SString siaDirQuery; FilePath findFile = GetCacheLocation(); FilePath cachePath = GetCacheLocation(); if (FilePath::DirSep == fileName) { - siaFileQuery += L"/*.*"; + siaFileQuery += L"/*.*"; + siaDirQuery = "/"; findFile.Append("*"); } else @@ -497,12 +498,9 @@ private: if (dokanFileInfo->IsDirectory) { siaFileQuery += L"/*.*"; + siaDirQuery = findFile; findFile.Append("*"); } - else - { - siaDirQuery = FilePath(); - } } CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanFindFiles(cachePath, siaDirQuery, siaFileQuery, findFile, fileName)));