summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-02-13 15:25:21 +0300
committerAndrei Karas <akaras@inbox.ru>2017-02-13 15:25:21 +0300
commit63f37017719d01f9ea72fb1f1e1722918a368755 (patch)
tree555c9d860becb70205bf2608bea2d869e2386b7e /src/utils
parent20ba8c348fe5e4d3af16fd3775e74d2200a53b98 (diff)
downloadmv-63f37017719d01f9ea72fb1f1e1722918a368755.tar.gz
mv-63f37017719d01f9ea72fb1f1e1722918a368755.tar.bz2
mv-63f37017719d01f9ea72fb1f1e1722918a368755.tar.xz
mv-63f37017719d01f9ea72fb1f1e1722918a368755.zip
Remove from resourcemanager function for add/remove archives from directory.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/virtfs.cpp46
-rw-r--r--src/utils/virtfs.h5
2 files changed, 51 insertions, 0 deletions
diff --git a/src/utils/virtfs.cpp b/src/utils/virtfs.cpp
index 0ab3b668f..e5b407f35 100644
--- a/src/utils/virtfs.cpp
+++ b/src/utils/virtfs.cpp
@@ -299,4 +299,50 @@ namespace VirtFs
{
return PHYSFS_eof(file->mPrivate->mFile);
}
+
+ void searchAndAddArchives(const std::string &restrict path,
+ const std::string &restrict ext,
+ const Append append)
+ {
+ char **list = VirtFs::enumerateFiles(path.c_str());
+
+ for (char **i = list; *i; i++)
+ {
+ const size_t len = strlen(*i);
+
+ if (len > ext.length() &&
+ !ext.compare((*i) + (len - ext.length())))
+ {
+ const std::string file = path + (*i);
+ const std::string realPath = std::string(
+ VirtFs::getRealDir(file.c_str()));
+ VirtFs::addZipToSearchPath(std::string(realPath).append(
+ dirSeparator).append(file), append);
+ }
+ }
+ VirtFs::freeList(list);
+ }
+
+ void searchAndRemoveArchives(const std::string &restrict path,
+ const std::string &restrict ext)
+ {
+ char **list = VirtFs::enumerateFiles(path.c_str());
+
+ for (char **i = list; *i; i++)
+ {
+ const size_t len = strlen(*i);
+ if (len > ext.length() &&
+ !ext.compare((*i) + (len - ext.length())))
+ {
+ const std::string file = path + (*i);
+ const std::string realPath = std::string(
+ VirtFs::getRealDir(file.c_str()));
+ VirtFs::removeZipFromSearchPath(std::string(
+ realPath).append(
+ dirSeparator).append(
+ file));
+ }
+ }
+ VirtFs::freeList(list);
+ }
} // namespace PhysFs
diff --git a/src/utils/virtfs.h b/src/utils/virtfs.h
index f28354790..05243817f 100644
--- a/src/utils/virtfs.h
+++ b/src/utils/virtfs.h
@@ -70,6 +70,11 @@ namespace VirtFs
int seek(VirtFile *const file,
const uint64_t pos);
int eof(VirtFile *const file);
+ void searchAndAddArchives(const std::string &restrict path,
+ const std::string &restrict ext,
+ const Append append);
+ void searchAndRemoveArchives(const std::string &restrict path,
+ const std::string &restrict ext);
} // namespace VirtFs
extern const char *dirSeparator;