00001 #if 0
00002
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef NL_NEW_PATH_H
00028 #define NL_NEW_PATH_H
00029
00030 #include "nel/misc/types_nl.h"
00031
00032 #include <map>
00033 #include <string>
00034 #include <vector>
00035
00036 namespace NLMISC {
00037
00046 class CNewPath
00047 {
00048 public:
00063 static void addSearchPath (const std::string &path, bool recurse, bool alternative);
00064
00066 static void addSearchPath (const std::string &path) { addSearchPath (path, false, true); }
00067
00069 static void addSearchFile (const std::string &file, bool remap = false, const std::string &virtual_ext = "");
00070
00072 static void addSearchListFile (const std::string &filename, bool recurse, bool alternative);
00073
00075 static void addSearchBigFile (const std::string &filename, bool recurse, bool alternative);
00076
00087 static std::string lookup (const std::string &filename);
00088
00091 static void clearMap ();
00092
00098 static void remapExtension (const std::string &ext1, const std::string &ext2, bool substitute);
00099
00100 static void display ();
00101
00102
00103 private:
00104
00105 static CNewPath *getInstance ();
00106
00107
00108 static CNewPath *_Instance;
00109
00110 private:
00111
00112 std::vector<std::string> _Paths;
00113
00114
00115 std::vector<std::string> _AlternativePaths;
00116
00117 struct CNewFileEntry
00118 {
00119 CNewFileEntry (std::string path, bool remapped, std::string ext) : Path(path), Remapped(remapped), Extension(ext) { }
00120 std::string Path;
00121 bool Remapped;
00122 std::string Extension;
00123 };
00124
00128 std::map<std::string, CNewFileEntry> _Files;
00129
00131 std::vector<std::pair<std::string, std::string> > _Extensions;
00132
00133 sint findExtension (const std::string &ext1, const std::string &ext2);
00134 static std::string standardizePath (const std::string &path, bool addFinalSlash = true);
00135 static void getPathContent (const std::string &path, bool recurse, bool wantDir, bool wantFile, std::vector<std::string> &result);
00136 static void insertFileInMap (const std::string &filename, const std::string &filepath, bool remap, const std::string &extension);
00137 };
00138
00139
00140
00147 struct CNewFile
00148 {
00153 static std::string getFilename (const std::string &filename);
00154
00159 static std::string getPath (const std::string &filename);
00160
00165 static bool isDirectory (const std::string &filename);
00166
00172 static bool fileExists (const std::string &filename);
00173
00179 static bool isExists (const std::string& filename);
00180
00186 static std::string findNewFile (const std::string &filename);
00187
00192 static int getLastSeparator (const std::string &filename);
00193
00194 static std::string getFilenameWithoutExtension (const std::string &filename);
00195 static std::string getExtension (const std::string &filename);
00196
00197 };
00198
00199
00200
00201
00202 }
00203
00204
00205 #endif // NL_NEW_PATH_H
00206
00207
00208 #enfif