From cda39ec9d6a0b5fab2c009046cf3570ab90db20b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 17 May 2017 18:21:22 +0300 Subject: Improve a bit virtfs based on directories. --- src/fs/virtfs/fsdir.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/fs/virtfs/fsdir.cpp') diff --git a/src/fs/virtfs/fsdir.cpp b/src/fs/virtfs/fsdir.cpp index 37c5cc795..e205e8362 100644 --- a/src/fs/virtfs/fsdir.cpp +++ b/src/fs/virtfs/fsdir.cpp @@ -65,7 +65,8 @@ namespace FsDir const std::string &filename, const FILEMTYPE mode) { - const std::string path = entry->root + entry->subDir + filename; + const std::string path = static_cast(entry)->rootSubDir + + filename; if (Files::existsLocal(path) == false) return nullptr; FILEHTYPE fd = FILEOPEN(path.c_str(), @@ -173,7 +174,7 @@ namespace FsDir std::string &realDir) { DirEntry *const dirEntry = static_cast(entry); - if (Files::existsLocal(dirEntry->root + entry->subDir + filename)) + if (Files::existsLocal(dirEntry->rootSubDir + filename)) { realDir = dirEntry->userDir; return true; @@ -185,14 +186,16 @@ namespace FsDir std::string fileName, std::string dirName A_UNUSED) { - return Files::existsLocal(entry->root + entry->subDir + fileName); + return Files::existsLocal(static_cast(entry)->rootSubDir + + fileName); } void enumerate(FsEntry *restrict const entry, std::string dirName, StringVect &names) { - const std::string path = entry->root + entry->subDir + dirName; + const std::string path = static_cast(entry)->rootSubDir + + dirName; const struct dirent *next_file = nullptr; DIR *const dir = opendir(path.c_str()); if (dir) @@ -234,7 +237,7 @@ namespace FsDir std::string dirName, bool &isDirFlag) { - std::string path = entry->root + entry->subDir + dirName; + std::string path = static_cast(entry)->rootSubDir + dirName; struct stat statbuf; if (stat(path.c_str(), &statbuf) == 0) @@ -462,7 +465,7 @@ namespace FsDir int &restrict fileSize) { const DirEntry *const dirEntry = static_cast(entry); - const std::string path = entry->root + entry->subDir + filename; + const std::string path = dirEntry->rootSubDir + filename; if (Files::existsLocal(path) == false) return nullptr; FILEHTYPE fd = FILEOPEN(path.c_str(), @@ -524,7 +527,8 @@ namespace FsDir std::string dirName, StringVect &names) { - const std::string path = entry->root + entry->subDir + dirName; + const std::string path = static_cast(entry)->rootSubDir + + dirName; const struct dirent *next_file = nullptr; DIR *const dir = opendir(path.c_str()); if (dir) @@ -573,7 +577,8 @@ namespace FsDir const std::string &dirName, StringVect &names) { - const std::string path = entry->root + entry->subDir + dirName; + const std::string path = static_cast(entry)->rootSubDir + + dirName; const struct dirent *next_file = nullptr; DIR *const dir = opendir(path.c_str()); if (dir) @@ -622,7 +627,8 @@ namespace FsDir std::string dirName, StringVect &names) { - const std::string path = entry->root + entry->subDir + dirName; + const std::string path = static_cast(entry)->rootSubDir + + dirName; const struct dirent *next_file = nullptr; DIR *const dir = opendir(path.c_str()); if (dir) -- cgit v1.2.3-70-g09d2