mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
Original Source for 1.13 Mod High Resolution version from 12/06/05
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@21 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// Snap: Declaration of the TFileCat class
|
||||
//
|
||||
// This class catalogues files in a directory and all its subdirectories
|
||||
//
|
||||
#ifndef FILECAT_H
|
||||
#define FILECAT_H
|
||||
|
||||
#include "stringicmp.h"
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
|
||||
class TFileCat {
|
||||
public:
|
||||
|
||||
TFileCat(std::string root) { NewCat(root); }
|
||||
TFileCat() {}
|
||||
|
||||
// Build a new file catalogue by recursively traversing the root directory
|
||||
void NewCat(std::string root);
|
||||
|
||||
std::string GetRootDir() const { return fRootDir; }
|
||||
|
||||
// Look for a given file in the catalogue
|
||||
// Unless pathIncludesRoot == true, will prepend the root directory to path
|
||||
bool FindFile(std::string path, bool pathIncludesRoot = false) const;
|
||||
|
||||
// Delete a given file from the catalogue
|
||||
// Unless pathIncludesRoot == true, will prepend the root directory to path
|
||||
size_t RemoveFile(std::string path, bool pathIncludesRoot = false);
|
||||
|
||||
// Delete all files from a given directory in the catalogue
|
||||
// Unless pathIncludesRoot == true, will prepend the root directory to path
|
||||
size_t RemoveDir(std::string dir, bool pathIncludesRoot = false);
|
||||
|
||||
private:
|
||||
|
||||
typedef std::set<std::string, TStringiLess> TCatalogue;
|
||||
|
||||
std::string fRootDir;
|
||||
TCatalogue fFileCat;
|
||||
|
||||
// Recursively traverse a directory, adding regular files to the catalogue
|
||||
void TraverseDir(std::string dir, int depth = -1);
|
||||
};
|
||||
|
||||
#endif // FILECAT_H
|
||||
Reference in New Issue
Block a user