9 #ifndef G3D_FileSystem_h
10 #define G3D_FileSystem_h
75 includeParentPath(
true) {}
117 bool contains(
const std::string& child,
bool caseSensitive =
126 void computeZipListing(
const std::string& zipfile,
const std::string& pathInsideZipfile);
152 bool _inZipfile(
const std::string& path, std::string& zipfile);
176 bool _exists(
const std::string& f,
bool trustCache =
true,
bool caseSensitive =
193 void _copyFile(
const std::string& srcPath,
const std::string& dstPath);
199 bool _isNewer(
const std::string& src,
const std::string& dst);
211 void _list(
const std::string& spec,
Array<std::string>& result,
const ListSettings& listSettings = ListSettings());
222 return list(spec, result, set);
231 return list(spec, result, set);
235 FILE*
_fopen(
const char* filename,
const char* mode);
264 static bool inZipfile(
const std::string& path, std::string& zipfile) {
282 static FILE*
fopen(
const char* filename,
const char* mode) {
378 static void copyFile(
const std::string& srcPath,
const std::string& dstPath) {
401 static bool exists(
const std::string& f,
bool trustCache =
true,
bool caseSensitive =
425 static bool isFile(
const std::string& path) {
453 static bool isNewer(
const std::string& src,
const std::string& dst) {
530 static std::string
concat(
const std::string& a,
const std::string& b);
537 static bool isRoot(
const std::string& f);
543 static std::string
ext(
const std::string& path);
546 static std::string
baseExt(
const std::string& path);
549 static std::string
base(
const std::string& path);
552 static std::string
parent(
const std::string& path);
590 (
const std::string& filename,
599 static bool matches(
const std::string& path,
const std::string& pattern,
bool caseSensitive =
true);
602 static std::string
makeLegalFilename(
const std::string& f,
size_t maxLength = 100000);
void _removeFile(const std::string &path)
Delete this file. No effect if path does not exist.
Definition: FileSystem.cpp:492
bool _isFile(const std::string &path)
Definition: FileSystem.h:188
std::string name
Definition: FileSystem.h:96
float _cacheLifetime() const
Definition: FileSystem.h:168
bool _isDirectory(const std::string &path)
Definition: FileSystem.cpp:483
void _setCacheLifetime(float t)
Definition: FileSystem.cpp:364
bool includeParentPath
Definition: FileSystem.h:64
Entry()
Definition: FileSystem.h:98
Definition: FileSystem.h:46
bool _isNewer(const std::string &src, const std::string &dst)
Definition: FileSystem.cpp:565
static std::string expandEnvironmentVariables(const std::string &path)
Replaces $VAR and patterns with the corresponding environment variable. Throws std::string if the en...
Definition: FileSystem.cpp:949
bool isZipfile
Definition: FileSystem.h:108
static bool isFile(const std::string &path)
Definition: FileSystem.h:425
static bool isNewer(const std::string &src, const std::string &dst)
Definition: FileSystem.h:453
static void cleanup()
Definition: FileSystem.cpp:62
void lock()
Definition: GThread.cpp:248
Array< std::string > m_winDrive
Definition: FileSystem.h:82
static bool isZipfile(const std::string &path)
Definition: FileSystem.h:323
static std::string baseExt(const std::string &path)
Definition: FileSystem.cpp:765
float m_cacheLifetime
Definition: FileSystem.h:84
Mutual exclusion lock used for synchronization.
Definition: GMutex.h:76
static void parse(const std::string &filename, std::string &drive, Array< std::string > &path, std::string &base, std::string &ext)
Definition: FileSystem.cpp:838
Type type
Definition: FileSystem.h:97
static void init()
Definition: FileSystem.cpp:55
void computeZipListing(const std::string &zipfile, const std::string &pathInsideZipfile)
Definition: FileSystem.cpp:88
Definition: FileSystem.h:90
static void clearCache(const std::string &path="")
Definition: FileSystem.h:273
Array< Entry > nodeArray
Definition: FileSystem.h:112
static bool containsWildcards(const std::string &p)
Definition: FileSystem.cpp:813
Definition: FileSystem.h:102
static void fclose(FILE *f)
Definition: FileSystem.h:290
static std::string concat(const std::string &a, const std::string &b)
Definition: FileSystem.cpp:743
#define false
Definition: CascPort.h:18
bool recursive
Definition: FileSystem.h:61
bool exists
Definition: FileSystem.h:106
Entry(const char *n)
Definition: FileSystem.h:99
void _clearCache(const std::string &path)
Definition: FileSystem.cpp:337
ListSettings()
Definition: FileSystem.h:66
bool inZipfile
Definition: FileSystem.h:109
Table< std::string, Dir > m_cache
Definition: FileSystem.h:133
static const Set< std::string > & usedFiles()
Definition: FileSystem.cpp:560
static GMutex mutex
Definition: FileSystem.h:143
Dir()
Definition: FileSystem.h:128
#define true
Definition: CascPort.h:17
void unlock()
Definition: GThread.cpp:256
bool contains(const std::string &child, bool caseSensitive=true) const
Definition: FileSystem.cpp:73
static bool exists(const std::string &f, bool trustCache=true, bool caseSensitive=true)
Definition: FileSystem.h:401
bool directories
Definition: FileSystem.h:55
Definition: FileSystem.h:93
void _createDirectory(const std::string &path)
Definition: FileSystem.cpp:369
bool caseSensitive
Definition: FileSystem.h:58
static bool isRoot(const std::string &f)
Definition: FileSystem.cpp:698
static std::string parent(const std::string &path)
Definition: FileSystem.cpp:795
static std::string currentDirectory()
Definition: FileSystem.h:364
static void removeFile(const std::string &path)
Delete this file. No effect if path does not exist.
Definition: FileSystem.h:314
static float cacheLifetime()
Definition: FileSystem.h:341
Parsing of file system paths.
Definition: FileSystem.h:526
int64 _size(const std::string &path)
Definition: FileSystem.cpp:580
static std::string removeTrailingSlash(const std::string &f)
Definition: FileSystem.cpp:736
static std::string ext(const std::string &path)
Definition: FileSystem.cpp:755
static int64 size(const std::string &path)
Definition: FileSystem.h:462
static bool matches(const std::string &path, const std::string &pattern, bool caseSensitive=true)
Definition: FileSystem.cpp:818
void setCacheLifetime(float t)
Definition: FileSystem.h:333
void _list(const std::string &spec, Array< std::string > &result, const ListSettings &listSettings=ListSettings())
Definition: FileSystem.cpp:665
static bool isDirectory(const std::string &path)
Definition: FileSystem.h:416
static void copyFile(const std::string &srcPath, const std::string &dstPath)
Definition: FileSystem.h:378
std::string _resolve(const std::string &path, const std::string &cwd=currentDirectory())
Definition: FileSystem.cpp:508
void _copyFile(const std::string &srcPath, const std::string &dstPath)
Definition: FileSystem.cpp:424
int64_t int64
Definition: g3dmath.h:169
static std::string canonicalize(std::string x)
Definition: FileSystem.cpp:832
double lastChecked
Definition: FileSystem.h:115
FileSystem()
Definition: FileSystem.cpp:69
bool _inZipfile(const std::string &path)
Definition: FileSystem.h:158
static std::string resolve(const std::string &path, const std::string &cwd=currentDirectory())
Definition: FileSystem.h:440
static std::string base(const std::string &path)
Definition: FileSystem.cpp:783
static bool inZipfile(const std::string &path)
Definition: FileSystem.h:300
bool _exists(const std::string &f, bool trustCache=true, bool caseSensitive=true)
Definition: FileSystem.cpp:441
static FILE * fopen(const char *filename, const char *mode)
Definition: FileSystem.h:282
Definition: FileSystem.h:49
Definition: FileSystem.h:89
bool _isZipfile(const std::string &path)
Definition: FileSystem.cpp:296
static FileSystem & instance()
Definition: FileSystem.cpp:49
static bool inZipfile(const std::string &path, std::string &zipfile)
Definition: FileSystem.h:264
Definition: FileSystem.h:88
void listHelper(const std::string &shortSpec, const std::string &parentPath, Array< std::string > &result, const ListSettings &settings)
Definition: FileSystem.cpp:617
Type
Definition: FileSystem.h:86
static void getFiles(const std::string &spec, Array< std::string > &result, bool includeParentPath=false)
Definition: FileSystem.h:488
static std::string makeLegalFilename(const std::string &f, size_t maxLength=100000)
Definition: FileSystem.cpp:1015
G3D::int16 x
Definition: Vector2int16.h:37
bool files
Definition: FileSystem.h:52
static void markFileUsed(const std::string &filename)
Definition: FileSystem.cpp:553
static void list(const std::string &spec, Array< std::string > &result, const ListSettings &listSettings=ListSettings())
Definition: FileSystem.h:479
static void getDirectories(const std::string &spec, Array< std::string > &result, bool includeParentPath=false)
Definition: FileSystem.h:496
void _getDirectories(const std::string &spec, Array< std::string > &result, bool includeParentPath=false)
Definition: FileSystem.h:226
Dir & getContents(const std::string &path, bool forceUpdate)
Definition: FileSystem.cpp:147
static void createDirectory(const std::string &path)
Definition: FileSystem.h:356
std::string _currentDirectory()
Definition: FileSystem.cpp:542
FILE * _fopen(const char *filename, const char *mode)
Definition: FileSystem.cpp:321
void _getFiles(const std::string &spec, Array< std::string > &result, bool includeParentPath=false)
Definition: FileSystem.h:217
bool _inZipfile(const std::string &path, std::string &zipfile)
Definition: FileSystem.cpp:261