1
0

Fixing stuff

This commit is contained in:
Scott E. Graves
2017-04-03 23:19:44 -05:00
parent aabd34b74a
commit 7c1c1b46c4
2 changed files with 15 additions and 39 deletions

View File

@@ -1,5 +1,6 @@
#include <siaapi.h> #include <siaapi.h>
#include <regex> #include <regex>
#include <filepath.h>
using namespace Sia::Api; using namespace Sia::Api;
@@ -73,40 +74,17 @@ std::vector<SString> CSiaApi::_CSiaFileTree::QueryDirectories(SString rootFolder
auto fileList = GetFileList(); auto fileList = GetFileList();
CSiaFileCollection col; CSiaFileCollection col;
rootFolder.Replace("/", "\\"); rootFolder.Replace("/", "\\");
if (rootFolder[0] == '\\')
{
rootFolder = rootFolder.SubString(1);
}
std::vector<SString> ret; std::vector<SString> ret;
std::for_each(fileList->begin(), fileList->end(), [&](const CSiaFilePtr& v) std::for_each(fileList->begin(), fileList->end(), [&](const CSiaFilePtr& v)
{ {
SString dir = v->GetSiaPath(); SString path = ("\\" + FilePath(v->GetSiaPath()).RemoveFileName()).Replace("/", "\\");
dir.Replace("/", "\\"); if (path.BeginsWith(rootFolder))
::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()); path = path.SubString(1, rootFolder.Length());
int idx = subFolder.str().find('\\'); if (path.Length())
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);
} }
} }
}); });

View File

@@ -482,12 +482,13 @@ private:
{ {
SString siaFileQuery = CSiaApi::FormatToSiaPath(fileName); SString siaFileQuery = CSiaApi::FormatToSiaPath(fileName);
SString siaRootPath = CSiaApi::FormatToSiaPath(fileName); SString siaRootPath = CSiaApi::FormatToSiaPath(fileName);
FilePath siaDirQuery = siaFileQuery; SString siaDirQuery;
FilePath findFile = GetCacheLocation(); FilePath findFile = GetCacheLocation();
FilePath cachePath = GetCacheLocation(); FilePath cachePath = GetCacheLocation();
if (FilePath::DirSep == fileName) if (FilePath::DirSep == fileName)
{ {
siaFileQuery += L"/*.*"; siaFileQuery += L"/*.*";
siaDirQuery = "/";
findFile.Append("*"); findFile.Append("*");
} }
else else
@@ -497,12 +498,9 @@ private:
if (dokanFileInfo->IsDirectory) if (dokanFileInfo->IsDirectory)
{ {
siaFileQuery += L"/*.*"; siaFileQuery += L"/*.*";
siaDirQuery = findFile;
findFile.Append("*"); findFile.Append("*");
} }
else
{
siaDirQuery = FilePath();
}
} }
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanFindFiles(cachePath, siaDirQuery, siaFileQuery, findFile, fileName))); CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanFindFiles(cachePath, siaDirQuery, siaFileQuery, findFile, fileName)));