summaryrefslogtreecommitdiff
path: root/src/fs/virtfs
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/virtfs')
-rw-r--r--src/fs/virtfs/virtfsdir.cpp357
-rw-r--r--src/fs/virtfs/virtfsdir.h26
-rw-r--r--src/fs/virtfs/virtfszip.cpp413
-rw-r--r--src/fs/virtfs/virtfszip.h30
4 files changed, 7 insertions, 819 deletions
diff --git a/src/fs/virtfs/virtfsdir.cpp b/src/fs/virtfs/virtfsdir.cpp
index 38c0c1559..42342b37b 100644
--- a/src/fs/virtfs/virtfsdir.cpp
+++ b/src/fs/virtfs/virtfsdir.cpp
@@ -51,7 +51,6 @@ extern const char *dirSeparator;
namespace
{
- std::vector<VirtDirEntry*> mEntries;
std::string mWriteDir;
std::string mBaseDir;
std::string mUserDir;
@@ -61,39 +60,6 @@ namespace
namespace VirtFsDir
{
- namespace
- {
- static VirtFile *openFile(std::string filename,
- const int mode)
- {
- prepareFsPath(filename);
- if (checkPath(filename) == false)
- {
- reportAlways("VirtFsDir::openFile invalid path: %s",
- filename.c_str());
- return nullptr;
- }
- VirtDirEntry *const entry = searchEntryByPath(filename);
- if (entry == nullptr)
- return nullptr;
-
- const std::string path = entry->root + filename;
- const int fd = open(path.c_str(),
- mode,
- S_IRUSR | S_IWUSR);
- if (fd == -1)
- {
- reportAlways("VirtFsDir::openFile file open error: %s",
- filename.c_str());
- return nullptr;
- }
- VirtFile *restrict const file = new VirtFile(&funcs);
- file->mPrivate = new VirtFilePrivate(fd);
-
- return file;
- }
- } // namespace
-
VirtFile *openInternal(VirtFsEntry *restrict const entry,
const std::string &filename,
const int mode)
@@ -134,195 +100,8 @@ namespace VirtFsDir
return openInternal(entry, filename, O_WRONLY | O_CREAT | O_APPEND);
}
- VirtFile *openReadDirEntry(VirtDirEntry *const entry,
- const std::string &filename)
- {
- const std::string path = entry->root + filename;
- const int fd = open(path.c_str(),
- O_RDONLY,
- S_IRUSR | S_IWUSR);
- if (fd == -1)
- {
- reportAlways("VirtFsDir::openReadDirEntry file open error: %s",
- filename.c_str());
- return nullptr;
- }
- VirtFile *restrict const file = new VirtFile(&funcs);
- file->mPrivate = new VirtFilePrivate(fd);
-
- return file;
- }
-
- VirtDirEntry *searchEntryByRoot(const std::string &restrict root)
- {
- FOR_EACH (std::vector<VirtDirEntry*>::const_iterator, it, mEntries)
- {
- if ((*it)->root == root)
- return *it;
- }
- return nullptr;
- }
-
- VirtDirEntry *searchEntryByPath(const std::string &restrict path)
- {
- FOR_EACH (std::vector<VirtDirEntry*>::const_iterator, it, mEntries)
- {
- VirtDirEntry *const entry = *it;
- if (Files::existsLocal(entry->root + path))
- return entry;
- }
- return nullptr;
- }
-
- bool addToSearchPathSilent(std::string newDir,
- const Append append,
- const SkipError skipError)
- {
- prepareFsPath(newDir);
- if (skipError == SkipError_false &&
- Files::existsLocal(newDir) == false)
- {
- logger->log("VirtFsDir::addToSearchPath directory not exists: %s",
- newDir.c_str());
- return false;
- }
- if (newDir.find(".zip") != std::string::npos)
- {
- reportAlways("Called VirtFsDir::addToSearchPath with zip archive");
- return false;
- }
- std::string rootDir = newDir;
- if (findLast(rootDir, std::string(dirSeparator)) == false)
- rootDir += dirSeparator;
- VirtDirEntry *const entry = VirtFsDir::searchEntryByRoot(rootDir);
- if (entry != nullptr)
- {
- reportAlways("VirtFsDir::addToSearchPath already exists: %s",
- newDir.c_str());
- return false;
- }
- logger->log("Add virtual directory: " + newDir);
- if (append == Append_true)
- {
- mEntries.push_back(new VirtDirEntry(newDir,
- rootDir,
- &funcs));
- }
- else
- {
- mEntries.insert(mEntries.begin(),
- new VirtDirEntry(newDir,
- rootDir,
- &funcs));
- }
- return true;
- }
-
- bool addToSearchPath(std::string newDir,
- const Append append)
- {
- prepareFsPath(newDir);
- if (Files::existsLocal(newDir) == false)
- {
- reportAlways("VirtFsDir::addToSearchPath directory not exists: %s",
- newDir.c_str());
- return false;
- }
- if (newDir.find(".zip") != std::string::npos)
- {
- reportAlways("Called VirtFsDir::addToSearchPath with zip archive");
- return false;
- }
- std::string rootDir = newDir;
- if (findLast(rootDir, std::string(dirSeparator)) == false)
- rootDir += dirSeparator;
- VirtDirEntry *const entry = VirtFsDir::searchEntryByRoot(rootDir);
- if (entry != nullptr)
- {
- reportAlways("VirtFsDir::addToSearchPath already exists: %s",
- newDir.c_str());
- return false;
- }
- logger->log("Add virtual directory: " + newDir);
- if (append == Append_true)
- {
- mEntries.push_back(new VirtDirEntry(newDir,
- rootDir,
- &funcs));
- }
- else
- {
- mEntries.insert(mEntries.begin(),
- new VirtDirEntry(newDir,
- rootDir,
- &funcs));
- }
- return true;
- }
-
- bool removeFromSearchPathSilent(std::string oldDir)
- {
- prepareFsPath(oldDir);
- if (oldDir.find(".zip") != std::string::npos)
- {
- reportAlways("Called removeFromSearchPath with zip archive");
- return false;
- }
- if (findLast(oldDir, std::string(dirSeparator)) == false)
- oldDir += dirSeparator;
- FOR_EACH (std::vector<VirtDirEntry*>::iterator, it, mEntries)
- {
- VirtDirEntry *const entry = *it;
- if (entry->root == oldDir)
- {
- logger->log("Remove virtual directory: " + oldDir);
- mEntries.erase(it);
- delete entry;
- return true;
- }
- }
-
- logger->log("VirtFsDir::removeFromSearchPath not exists: %s",
- oldDir.c_str());
- return false;
- }
-
- bool removeFromSearchPath(std::string oldDir)
- {
- prepareFsPath(oldDir);
- if (oldDir.find(".zip") != std::string::npos)
- {
- reportAlways("Called removeFromSearchPath with zip archive");
- return false;
- }
- if (findLast(oldDir, std::string(dirSeparator)) == false)
- oldDir += dirSeparator;
- FOR_EACH (std::vector<VirtDirEntry*>::iterator, it, mEntries)
- {
- VirtDirEntry *const entry = *it;
- if (entry->root == oldDir)
- {
- logger->log("Remove virtual directory: " + oldDir);
- mEntries.erase(it);
- delete entry;
- return true;
- }
- }
-
- reportAlways("VirtFsDir::removeFromSearchPath not exists: %s",
- oldDir.c_str());
- return false;
- }
-
- std::vector<VirtDirEntry*> &getEntries()
- {
- return mEntries;
- }
-
void deinit()
{
- delete_all(mEntries);
- mEntries.clear();
}
#if defined(__native_client__)
@@ -379,25 +158,6 @@ namespace VirtFsDir
return mUserDir.c_str();
}
- std::string getRealDir(std::string filename)
- {
- prepareFsPath(filename);
- if (checkPath(filename) == false)
- {
- reportAlways("VirtFsDir::exists invalid path: %s",
- filename.c_str());
- return std::string();
- }
- FOR_EACH (std::vector<VirtDirEntry*>::iterator, it, mEntries)
- {
- VirtDirEntry *const entry = *it;
- const std::string path = entry->root + filename;
- if (Files::existsLocal(path))
- return entry->userDir;
- }
- return std::string();
- }
-
bool getRealDir(VirtFsEntry *restrict const entry,
const std::string &filename,
const std::string &dirName A_UNUSED,
@@ -413,24 +173,6 @@ namespace VirtFsDir
return false;
}
- bool exists(std::string name)
- {
- prepareFsPath(name);
- if (checkPath(name) == false)
- {
- reportAlways("VirtFsDir::exists invalid path: %s",
- name.c_str());
- return false;
- }
- FOR_EACH (std::vector<VirtDirEntry*>::iterator, it, mEntries)
- {
- VirtDirEntry *const entry = *it;
- if (Files::existsLocal(entry->root + name))
- return true;
- }
- return false;
- }
-
bool exists(VirtFsEntry *restrict const entry,
const std::string &fileName,
const std::string &dirName A_UNUSED)
@@ -438,19 +180,6 @@ namespace VirtFsDir
return Files::existsLocal(entry->root + fileName);
}
- VirtList *enumerateFiles(std::string dirName)
- {
- VirtList *const list = new VirtList;
- prepareFsPath(dirName);
- if (checkPath(dirName) == false)
- {
- reportAlways("VirtFsDir::enumerateFiles invalid path: %s",
- dirName.c_str());
- return list;
- }
- return enumerateFiles(dirName, list);
- }
-
void enumerate(VirtFsEntry *restrict const entry,
const std::string &dirName,
StringVect &names)
@@ -490,53 +219,6 @@ namespace VirtFsDir
}
}
- VirtList *enumerateFiles(const std::string &restrict dirName,
- VirtList *restrict const list)
- {
- StringVect &names = list->names;
- FOR_EACH (std::vector<VirtDirEntry*>::iterator, it, mEntries)
- {
- VirtDirEntry *const entry = *it;
- StringVect files;
- std::string path = entry->root + dirName;
- if (findLast(path, std::string(dirSeparator)) == false)
- path += dirSeparator;
- const struct dirent *next_file = nullptr;
- DIR *const dir = opendir(path.c_str());
- if (dir)
- {
- while ((next_file = readdir(dir)))
- {
- const std::string file = next_file->d_name;
- if (file == "." || file == "..")
- continue;
- if (mPermitLinks == false)
- {
- struct stat statbuf;
- if (lstat(path.c_str(), &statbuf) == 0 &&
- S_ISLNK(statbuf.st_mode) != 0)
- {
- continue;
- }
- }
- bool found(false);
- FOR_EACH (StringVectCIter, itn, names)
- {
- if (*itn == file)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- names.push_back(file);
- }
- closedir(dir);
- }
- }
- return list;
- }
-
bool isDirectory(VirtFsEntry *restrict const entry,
const std::string &dirName,
bool &isDirFlag)
@@ -552,25 +234,6 @@ namespace VirtFsDir
return false;
}
- bool isDirectoryInternal(const std::string &restrict dirName)
- {
- FOR_EACH (std::vector<VirtDirEntry*>::iterator, it, mEntries)
- {
- VirtDirEntry *const entry = *it;
- std::string path = entry->root + dirName;
- if (findLast(path, std::string(dirSeparator)) == false)
- path += dirSeparator;
-
- struct stat statbuf;
- if (stat(path.c_str(), &statbuf) == 0 &&
- S_ISDIR(statbuf.st_mode) != 0)
- {
- return true;
- }
- }
- return false;
- }
-
bool isSymbolicLink(std::string name)
{
prepareFsPath(name);
@@ -593,21 +256,6 @@ namespace VirtFsDir
delete handle;
}
- VirtFile *openRead(const std::string &restrict filename)
- {
- return openFile(filename, O_RDONLY);
- }
-
- VirtFile *openWrite(const std::string &restrict filename)
- {
- return openFile(filename, O_WRONLY | O_CREAT | O_TRUNC);
- }
-
- VirtFile *openAppend(const std::string &restrict filename)
- {
- return openFile(filename, O_WRONLY | O_CREAT | O_APPEND);
- }
-
bool setWriteDir(std::string newDir)
{
prepareFsPath(newDir);
@@ -644,11 +292,6 @@ namespace VirtFsDir
mPermitLinks = val;
}
- const char *getLastError()
- {
- return nullptr;
- }
-
int close(VirtFile *restrict const file)
{
if (file == nullptr)
diff --git a/src/fs/virtfs/virtfsdir.h b/src/fs/virtfs/virtfsdir.h
index 069c20c8d..826d4dde4 100644
--- a/src/fs/virtfs/virtfsdir.h
+++ b/src/fs/virtfs/virtfsdir.h
@@ -29,7 +29,6 @@
#include "localconsts.h"
-struct VirtDirEntry;
struct VirtFile;
struct VirtFsEntry;
struct VirtFsFuncs;
@@ -37,51 +36,33 @@ struct VirtList;
namespace VirtFsDir
{
- VirtDirEntry *searchEntryByRoot(const std::string &restrict root);
- VirtDirEntry *searchEntryByPath(const std::string &restrict path);
+ VirtFile *openInternal(VirtFsEntry *restrict const entry,
+ const std::string &filename,
+ const int mode);
VirtFile *openRead(VirtFsEntry *restrict const entry,
const std::string &filename);
VirtFile *openWrite(VirtFsEntry *restrict const entry,
const std::string &filename);
VirtFile *openAppend(VirtFsEntry *restrict const entry,
const std::string &filename);
- VirtFile *openReadDirEntry(VirtDirEntry *const entry,
- const std::string &filename);
const char *getBaseDir();
const char *getUserDir();
VirtFsFuncs *getFuncs();
- bool addToSearchPath(std::string newDir,
- const Append append);
- bool addToSearchPathSilent(std::string newDir,
- const Append append,
- const SkipError skipError);
- bool removeFromSearchPath(std::string oldDir);
- bool removeFromSearchPathSilent(std::string oldDir);
void init(const std::string &restrict name);
void initFuncs(VirtFsFuncs *restrict const ptr);
void deinit();
- std::vector<VirtDirEntry*> &getEntries();
- bool exists(std::string name);
bool exists(VirtFsEntry *restrict const entry,
const std::string &fileName,
const std::string &dirName);
void enumerate(VirtFsEntry *restrict const entry,
const std::string &dirName,
StringVect &names);
- VirtList *enumerateFiles(std::string dirName) RETURNS_NONNULL;
- VirtList *enumerateFiles(const std::string &restrict dirName,
- VirtList *restrict const list) RETURNS_NONNULL;
bool isDirectory(VirtFsEntry *restrict const entry,
const std::string &dirName,
bool &isDirFlag);
- bool isDirectoryInternal(const std::string &restrict dirName);
bool isSymbolicLink(std::string name);
void freeList(VirtList *restrict const handle);
- VirtFile *openRead(const std::string &restrict filename);
- VirtFile *openWrite(const std::string &restrict filename);
- VirtFile *openAppend(const std::string &restrict filename);
bool setWriteDir(std::string newDir);
- std::string getRealDir(std::string filename);
bool getRealDir(VirtFsEntry *restrict const entry,
const std::string &filename,
const std::string &dirName,
@@ -89,7 +70,6 @@ namespace VirtFsDir
bool mkdir(std::string dirName);
bool remove(std::string filename);
void permitLinks(const bool val);
- const char *getLastError();
int64_t read(VirtFile *restrict const handle,
void *restrict const buffer,
const uint32_t objSize,
diff --git a/src/fs/virtfs/virtfszip.cpp b/src/fs/virtfs/virtfszip.cpp
index 881e028cc..eac4a2535 100644
--- a/src/fs/virtfs/virtfszip.cpp
+++ b/src/fs/virtfs/virtfszip.cpp
@@ -43,211 +43,18 @@ extern const char *dirSeparator;
namespace
{
- std::vector<VirtZipEntry*> mEntries;
VirtFsFuncs funcs;
} // namespace
namespace VirtFsZip
{
- VirtZipEntry *searchEntryByArchive(const std::string &restrict archiveName)
- {
- FOR_EACH (std::vector<VirtZipEntry*>::const_iterator, it, mEntries)
- {
- if ((*it)->root == archiveName)
- return *it;
- }
- return nullptr;
- }
-
- ZipLocalHeader *searchHeaderByName(const std::string &restrict filename)
- {
- FOR_EACH (std::vector<VirtZipEntry*>::const_iterator, it, mEntries)
- {
- VirtZipEntry *const entry = *it;
- FOR_EACH (std::vector<ZipLocalHeader*>::const_iterator,
- it2,
- entry->mHeaders)
- {
- if ((*it2)->fileName == filename)
- return *it2;
- }
- }
- return nullptr;
- }
-
- VirtZipEntry *searchZipEntryByNameWithDir(const std::string &restrict
- filename)
- {
- std::string dirName = filename;
- if (findLast(dirName, std::string(dirSeparator)) == false)
- dirName += dirSeparator;
- FOR_EACH (std::vector<VirtZipEntry*>::const_iterator, it, mEntries)
- {
- VirtZipEntry *const entry = *it;
- FOR_EACH (std::vector<ZipLocalHeader*>::const_iterator,
- it2,
- entry->mHeaders)
- {
- if ((*it2)->fileName == filename)
- return entry;
- }
- FOR_EACH (std::vector<std::string>::const_iterator,
- it2,
- entry->mDirs)
- {
- if (*it2 == dirName)
- return entry;
- }
- }
- return nullptr;
- }
-
VirtFsFuncs *getFuncs()
{
return &funcs;
}
- bool addToSearchPathSilent(std::string newDir,
- const Append append)
- {
- prepareFsPath(newDir);
- if (Files::existsLocal(newDir) == false)
- {
- logger->log("VirtFsZip::addToSearchPath file not exists: %s",
- newDir.c_str());
- return false;
- }
- if (findLast(newDir, ".zip") == false)
- {
- reportAlways("Called VirtFsZip::addToSearchPath without "
- "zip archive");
- return false;
- }
- VirtZipEntry *entry = VirtFsZip::searchEntryByArchive(newDir);
- if (entry != nullptr)
- {
- reportAlways("VirtFsZip::addToSearchPath already exists: %s",
- newDir.c_str());
- return false;
- }
- entry = new VirtZipEntry(newDir, &funcs);
- if (Zip::readArchiveInfo(entry) == false)
- {
- delete entry;
- return false;
- }
-
- logger->log("Add virtual zip: " + newDir);
- if (append == Append_true)
- mEntries.push_back(entry);
- else
- {
- mEntries.insert(mEntries.begin(),
- entry);
- }
- return true;
- }
-
- bool addToSearchPath(std::string newDir,
- const Append append)
- {
- prepareFsPath(newDir);
- if (Files::existsLocal(newDir) == false)
- {
- reportAlways("VirtFsZip::addToSearchPath directory not exists: %s",
- newDir.c_str());
- return false;
- }
- if (findLast(newDir, ".zip") == false)
- {
- reportAlways("Called VirtFsZip::addToSearchPath without "
- "zip archive");
- return false;
- }
- VirtZipEntry *entry = VirtFsZip::searchEntryByArchive(newDir);
- if (entry != nullptr)
- {
- reportAlways("VirtFsZip::addToSearchPath already exists: %s",
- newDir.c_str());
- return false;
- }
- entry = new VirtZipEntry(newDir, &funcs);
- if (Zip::readArchiveInfo(entry) == false)
- {
- delete entry;
- return false;
- }
-
- logger->log("Add virtual zip: " + newDir);
- if (append == Append_true)
- mEntries.push_back(entry);
- else
- {
- mEntries.insert(mEntries.begin(),
- entry);
- }
- return true;
- }
-
- bool removeFromSearchPathSilent(std::string oldDir)
- {
- prepareFsPath(oldDir);
- if (findLast(oldDir, ".zip") == false)
- {
- reportAlways("Called removeFromSearchPath without zip archive");
- return false;
- }
- FOR_EACH (std::vector<VirtZipEntry*>::iterator, it, mEntries)
- {
- VirtZipEntry *const entry = *it;
- if (entry->root == oldDir)
- {
- logger->log("Remove virtual zip: " + oldDir);
- mEntries.erase(it);
- delete entry;
- return true;
- }
- }
-
- logger->log("VirtFsZip::removeFromSearchPath not exists: %s",
- oldDir.c_str());
- return false;
- }
-
- bool removeFromSearchPath(std::string oldDir)
- {
- prepareFsPath(oldDir);
- if (findLast(oldDir, ".zip") == false)
- {
- reportAlways("Called removeFromSearchPath without zip archive");
- return false;
- }
- FOR_EACH (std::vector<VirtZipEntry*>::iterator, it, mEntries)
- {
- VirtZipEntry *const entry = *it;
- if (entry->root == oldDir)
- {
- logger->log("Remove virtual zip: " + oldDir);
- mEntries.erase(it);
- delete entry;
- return true;
- }
- }
-
- reportAlways("VirtFsZip::removeFromSearchPath not exists: %s",
- oldDir.c_str());
- return false;
- }
-
- std::vector<VirtZipEntry*> &getEntries()
- {
- return mEntries;
- }
-
void deinit()
{
- delete_all(mEntries);
- mEntries.clear();
}
void init()
@@ -273,27 +80,6 @@ namespace VirtFsZip
ptr->openAppend = &VirtFsZip::openAppend;
}
- std::string getRealDir(std::string filename)
- {
- prepareFsPath(filename);
- if (checkPath(filename) == false)
- {
- reportAlways("VirtFsZip::exists invalid path: %s",
- filename.c_str());
- return std::string();
- }
- return getRealDirInternal(filename);
- }
-
- std::string getRealDirInternal(const std::string &filename)
- {
- VirtZipEntry *restrict const entry = searchZipEntryByNameWithDir(
- filename);
- if (entry != nullptr)
- return entry->root;
- return std::string();
- }
-
bool getRealDir(VirtFsEntry *restrict const entry,
const std::string &filename,
const std::string &dirName,
@@ -323,20 +109,6 @@ namespace VirtFsZip
return false;
}
- bool exists(std::string name)
- {
- prepareFsPath(name);
- if (checkPath(name) == false)
- {
- reportAlways("VirtFsZip::exists invalid path: %s",
- name.c_str());
- return false;
- }
- VirtZipEntry *restrict const entry = searchZipEntryByNameWithDir(
- name);
- return entry != nullptr;
- }
-
bool exists(VirtFsEntry *restrict const entry,
const std::string &filename,
const std::string &dirName)
@@ -359,19 +131,6 @@ namespace VirtFsZip
return false;
}
- VirtList *enumerateFiles(std::string dirName)
- {
- VirtList *const list = new VirtList;
- prepareFsPath(dirName);
- if (checkPath(dirName) == false)
- {
- reportAlways("VirtFsZip::enumerateFiles invalid path: %s",
- dirName.c_str());
- return list;
- }
- return enumerateFiles(dirName, list);
- }
-
void enumerate(VirtFsEntry *restrict const entry,
const std::string &dirName,
StringVect &names)
@@ -432,77 +191,6 @@ namespace VirtFsZip
}
}
- VirtList *enumerateFiles(std::string dirName,
- VirtList *restrict const list)
- {
- if (findLast(dirName, std::string(dirSeparator)) == false)
- dirName += dirSeparator;
- StringVect &names = list->names;
- if (dirName == "/")
- {
- FOR_EACH (std::vector<VirtZipEntry*>::const_iterator, it, mEntries)
- {
- VirtZipEntry *const entry = *it;
- FOR_EACH (std::vector<ZipLocalHeader*>::const_iterator,
- it2,
- entry->mHeaders)
- {
- ZipLocalHeader *const header = *it2;
- std::string fileName = header->fileName;
- // skip subdirs from enumeration
- const size_t idx = fileName.find(dirSeparator);
- if (idx != std::string::npos)
- fileName.erase(idx);
- bool found(false);
- FOR_EACH (StringVectCIter, itn, names)
- {
- if (*itn == fileName)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- names.push_back(fileName);
- }
- }
- }
- else
- {
- FOR_EACH (std::vector<VirtZipEntry*>::const_iterator, it, mEntries)
- {
- VirtZipEntry *const entry = *it;
- FOR_EACH (std::vector<ZipLocalHeader*>::const_iterator,
- it2,
- entry->mHeaders)
- {
- ZipLocalHeader *const header = *it2;
- std::string fileName = header->fileName;
- if (findCutFirst(fileName, dirName) == true)
- {
- // skip subdirs from enumeration
- const size_t idx = fileName.find(dirSeparator);
- if (idx != std::string::npos)
- fileName.erase(idx);
- bool found(false);
- FOR_EACH (StringVectCIter, itn, names)
- {
- if (*itn == fileName)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- names.push_back(fileName);
- }
- }
- }
- }
-
- return list;
- }
-
bool isDirectory(VirtFsEntry *restrict const entry,
const std::string &dirName,
bool &isDirFlag)
@@ -521,54 +209,11 @@ namespace VirtFsZip
return false;
}
- bool isDirectoryInternal(std::string dirName)
- {
- if (findLast(dirName, std::string(dirSeparator)) == false)
- dirName += dirSeparator;
- FOR_EACH (std::vector<VirtZipEntry*>::const_iterator, it, mEntries)
- {
- VirtZipEntry *const entry = *it;
- FOR_EACH (std::vector<std::string>::const_iterator,
- it2,
- entry->mDirs)
- {
- if (*it2 == dirName)
- return true;
- }
- }
- return false;
- }
-
- bool isSymbolicLink(std::string name)
- {
- prepareFsPath(name);
- if (checkPath(name) == false)
- {
- reportAlways("VirtFsZip::isSymbolicLink invalid path: %s",
- name.c_str());
- return false;
- }
- // look like in zip files can be symlinks, but here they useless
- return false;
- }
-
void freeList(VirtList *restrict const handle)
{
delete handle;
}
- VirtFile *openRead(std::string filename)
- {
- prepareFsPath(filename);
- if (checkPath(filename) == false)
- {
- reportAlways("VirtFsZip::openRead invalid path: %s",
- filename.c_str());
- return nullptr;
- }
- return openReadInternal(filename);
- }
-
VirtFile *openRead(VirtFsEntry *restrict const entry,
const std::string &filename)
{
@@ -592,70 +237,20 @@ namespace VirtFsZip
return nullptr;
}
- VirtFile *openWrite(VirtFsEntry *restrict const entry,
- const std::string &filename)
+ VirtFile *openWrite(VirtFsEntry *restrict const entry A_UNUSED,
+ const std::string &filename A_UNUSED)
{
reportAlways("VirtFs::openWrite for zip not implemented.");
return nullptr;
}
- VirtFile *openAppend(VirtFsEntry *restrict const entry,
- const std::string &filename)
+ VirtFile *openAppend(VirtFsEntry *restrict const entry A_UNUSED,
+ const std::string &filename A_UNUSED)
{
reportAlways("VirtFs::openAppend for zip not implemented.");
return nullptr;
}
- VirtFile *openReadInternal(const std::string &filename)
- {
- ZipLocalHeader *restrict const header = searchHeaderByName(filename);
- if (header != nullptr)
- {
- uint8_t *restrict const buf = Zip::readFile(header);
- if (buf == nullptr)
- return nullptr;
- VirtFile *restrict const file = new VirtFile(&funcs);
- file->mPrivate = new VirtFilePrivate(buf,
- header->uncompressSize);
- return file;
- }
- return nullptr;
- }
-
- VirtFile *openWrite(const std::string &restrict filename A_UNUSED)
- {
- return nullptr;
- }
-
- VirtFile *openAppend(const std::string &restrict filename A_UNUSED)
- {
- return nullptr;
- }
-
- bool setWriteDir(const std::string &restrict newDir A_UNUSED)
- {
- return false;
- }
-
- bool mkdir(const std::string &restrict dirname A_UNUSED)
- {
- return false;
- }
-
- bool remove(const std::string &restrict filename A_UNUSED)
- {
- return false;
- }
-
- void permitLinks(const bool val A_UNUSED)
- {
- }
-
- const char *getLastError()
- {
- return nullptr;
- }
-
int close(VirtFile *restrict const file)
{
if (file == nullptr)
diff --git a/src/fs/virtfs/virtfszip.h b/src/fs/virtfs/virtfszip.h
index e88c74b69..bf4f5b3be 100644
--- a/src/fs/virtfs/virtfszip.h
+++ b/src/fs/virtfs/virtfszip.h
@@ -33,44 +33,23 @@ struct VirtFile;
struct VirtList;
struct VirtFsFuncs;
struct VirtFsEntry;
-struct VirtZipEntry;
-struct ZipLocalHeader;
namespace VirtFsZip
{
VirtFsFuncs *getFuncs();
- VirtZipEntry *searchEntryByArchive(const std::string &restrict
- archiveName);
- ZipLocalHeader *searchHeaderByName(const std::string &restrict filename);
- VirtZipEntry *searchZipEntryByNameWithDir(const std::string &restrict
- filename);
- bool addToSearchPath(std::string newDir,
- const Append append);
- bool addToSearchPathSilent(std::string newDir,
- const Append append);
- bool removeFromSearchPath(std::string oldDir);
- bool removeFromSearchPathSilent(std::string oldDir);
void init();
void initFuncs(VirtFsFuncs *restrict const ptr);
void deinit();
- std::vector<VirtZipEntry*> &getEntries();
- bool exists(std::string name);
bool exists(VirtFsEntry *restrict const entry,
const std::string &filename,
const std::string &dirName);
void enumerate(VirtFsEntry *restrict const entry,
const std::string &dirName,
StringVect &names);
- VirtList *enumerateFiles(std::string dirName) RETURNS_NONNULL;
- VirtList *enumerateFiles(std::string dirName,
- VirtList *restrict const list) RETURNS_NONNULL;
bool isDirectory(VirtFsEntry *restrict const entry,
const std::string &dirName,
bool &isDirFlag);
- bool isDirectoryInternal(std::string dirName);
- bool isSymbolicLink(std::string name);
void freeList(VirtList *restrict const handle);
- VirtFile *openRead(std::string filename);
VirtFile *openRead(VirtFsEntry *restrict const entry,
const std::string &filename);
VirtFile *openWrite(VirtFsEntry *restrict const entry,
@@ -78,19 +57,10 @@ namespace VirtFsZip
VirtFile *openAppend(VirtFsEntry *restrict const entry,
const std::string &filename);
VirtFile *openReadInternal(const std::string &filename);
- VirtFile *openWrite(const std::string &restrict filename);
- VirtFile *openAppend(const std::string &restrict filename);
- bool setWriteDir(const std::string &restrict newDir);
- std::string getRealDir(std::string filename);
- std::string getRealDirInternal(const std::string &filename);
bool getRealDir(VirtFsEntry *restrict const entry,
const std::string &filename,
const std::string &dirName,
std::string &realDir);
- bool mkdir(const std::string &restrict dirName);
- bool remove(const std::string &restrict filename);
- void permitLinks(const bool val);
- const char *getLastError();
int64_t read(VirtFile *restrict const handle,
void *restrict const buffer,
const uint32_t objSize,