00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00034 #ifndef PG_FILEARCHIVE_H
00035 #define PG_FILEARCHIVE_H
00036
00037 #include "paragui.h"
00038 #include "pgfile.h"
00039 #include "pgsurfacecache.h"
00040 #include "pgdatacontainer.h"
00041
00042 #include <vector>
00043 #include <string>
00044
00046 typedef std::vector< std::string > PG_FileList;
00047
00054 class DECLSPEC PG_FileArchive {
00055 private:
00056 void init( const char* argv0 );
00057
00058 public:
00059
00061 enum Mode {
00062 READ,
00063 WRITE,
00064 APPEND
00065 };
00066
00067 PG_FileArchive();
00068 PG_FileArchive( const char* argv0);
00069
00070 ~PG_FileArchive();
00071
00072 static void Deinit();
00073
00080 static bool AddArchive(const std::string& arch, bool append = true);
00081
00087 static bool RemoveArchive(const std::string& arch);
00088
00092 static bool RemoveAllArchives();
00093
00095
00105 static char **GetSearchPath();
00106
00108
00114 static void FreeList(void* list);
00115
00117
00129 static char **EnumerateFiles(const std::string& dir);
00130
00136 static bool Exists(const std::string& filename);
00137
00143 static bool IsDirectory(const std::string& filename);
00144
00149 static const char* GetDirSeparator();
00150
00151 static const char* GetRealDir(const std::string&filename);
00152
00153 static const char* GetLastError();
00155
00160 static bool MakeDir(const std::string& dir);
00161
00163
00167 static bool SetWriteDir(const std::string& dir);
00168
00170
00177 static std::string *PathToPlatform(const std::string& path);
00178
00180
00183 static const char* GetBaseDir();
00184
00186
00192 static const char* GetUserDir();
00193
00195
00200 static const char* GetWriteDir();
00201
00203
00218 static bool SetSaneConfig(const std::string& organization,
00219 const std::string& appName,
00220 const std::string& archiveExt = PG_NULLSTR,
00221 bool includeCdRoms = false,
00222 bool archivesFirst = true);
00223
00230 static PG_File* OpenFile(const std::string& filename, Mode mode = READ);
00231
00238 static SDL_RWops* OpenFileRWops(const std::string& filename, Mode mode = READ);
00239
00241
00248 static PG_DataContainer* ReadFile(const std::string& filename);
00249
00257 static SDL_Surface* LoadSurface(const std::string& filename, bool convert = false);
00258
00268 static SDL_Surface* LoadSurface(const std::string& filename, bool usekey, Uint32 colorkey, bool convert = false);
00269
00276 static bool UnloadSurface(SDL_Surface* surface, bool bDeleteIfNotExists = true);
00277
00287 static void EnableSymlinks(bool followSymlinks);
00288
00290
00299 static PG_FileList* GetSearchPathList();
00300
00301
00303
00313 static PG_FileList* GetFileList(const std::string& dir, const std::string& wildcard="*");
00314
00315 private:
00316
00317 static Uint32 my_instance_count;
00318
00319 static PG_SurfaceCache my_cache;
00320 };
00321
00322 #endif