Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CS_CSSYS_SYSPATH_H__
00020 #define __CS_CSSYS_SYSPATH_H__
00021
00022 #include "csextern.h"
00023 #include "array.h"
00024 #include "csstring.h"
00025 #include "ref.h"
00026 #include "util.h"
00027 #include "iutil/stringarray.h"
00028
00039 class csPathsList;
00040
00049 CS_CRYSTALSPACE_EXPORT csString csGetConfigPath ();
00050
00055 CS_CRYSTALSPACE_EXPORT csPathsList* csGetPluginPaths (const char* argv0);
00056
00062 class CS_CRYSTALSPACE_EXPORT csPathsList
00063 {
00064 public:
00068 struct CS_CRYSTALSPACE_EXPORT Entry
00069 {
00073 csString path;
00075 csString type;
00077 bool scanRecursive;
00078
00079 void FixSeparators();
00080
00081 Entry () : scanRecursive (false) {}
00082 Entry (const char* path, const char* type, bool recursive = false)
00083 {
00084 Entry::path = path;
00085 FixSeparators();
00086 Entry::type = type;
00087 scanRecursive = recursive;
00088 };
00089 Entry (const Entry& src)
00090 {
00091 path = src.path;
00092 type = src.type;
00093 scanRecursive = src.scanRecursive;
00094 };
00095 };
00096 private:
00097 csArray<Entry, csArrayElementHandler<Entry>, CS::Container::ArrayAllocDefault,
00098 csArrayCapacityFixedGrow<4> > paths;
00099 public:
00101 csPathsList ();
00103 csPathsList (csPathsList const& o);
00105 csPathsList (const char* pathList, bool expand = false);
00110 csPathsList (const char* const pathList[], bool expand = false);
00112 ~csPathsList();
00114 csPathsList& operator= (csPathsList const& o);
00115
00127 size_t AddUnique (const char* path, bool scanRecursive = false,
00128 const char* type = 0, bool overrideRecursive = true);
00134 size_t AddUniqueExpanded (const char* path, bool scanRecursive = false,
00135 const char* type = 0, bool overrideRecursive = true);
00144 size_t AddUnique (const Entry& path, bool overrideRecursive = true);
00150 size_t AddUniqueExpanded (const Entry& path, bool overrideRecursive = true);
00154 void AddUnique (const csPathsList& list, bool overrideRecursive = true)
00155 {
00156 for (size_t i = 0; i < list.Length(); i++)
00157 {
00158 AddUnique (list[i], overrideRecursive);
00159 }
00160 }
00166 void AddUniqueExpanded (const csPathsList& list,
00167 bool overrideRecursive = true)
00168 {
00169 for (size_t i = 0; i < list.Length(); i++)
00170 {
00171 AddUniqueExpanded (list[i], overrideRecursive);
00172 }
00173 }
00175 void DeleteIndex (size_t index);
00176
00178
00179 size_t Length () const { return paths.GetSize (); }
00180 size_t GetSize () const { return paths.GetSize (); }
00182 CS_DEPRECATED_METHOD_MSG("Use GetSize() instead")
00183 size_t GetCount () const { return Length(); }
00185
00186 Entry const& operator [] (size_t n) const { return paths[n]; }
00187 Entry& operator [] (size_t n) { return paths[n]; }
00189
00191
00196 CS_CRYSTALSPACE_EXPORT friend csPathsList operator* (const csPathsList& left,
00197 const csPathsList& right);
00198 csPathsList operator*= (const csPathsList& right);
00199 friend csPathsList operator* (const Entry& left,
00200 const csPathsList& right);
00201 friend csPathsList operator* (const char* left,
00202 const csPathsList& right);
00203 friend csPathsList operator* (const csPathsList& left,
00204 const Entry& right);
00205 friend csPathsList operator* (const csPathsList& left,
00206 const char* right);
00207 csPathsList operator*= (const Entry& right);
00208 csPathsList operator*= (const char* right);
00210 };
00211
00215 class CS_CRYSTALSPACE_EXPORT csPathsUtilities
00216 {
00217 public:
00226 static bool PathsIdentical (const char* path1, const char* path2);
00233 static char* ExpandPath (const char* path);
00234
00242 static csPathsList LocateFile (const csPathsList& paths,
00243 const char* file, bool thorough = false);
00244
00246 static void FilterInvalid (csPathsList& paths);
00247
00249 static csPathsList ExpandAll (const csPathsList& paths);
00250 };
00251
00252
00257 class CS_CRYSTALSPACE_EXPORT csInstallationPathsHelper
00258 {
00259 public:
00268 static csPathsList* GetPlatformInstallationPaths ();
00274 static csRef<iStringArray> FindSystemRoots();
00287 static csString GetAppPath (const char* argv0);
00288
00302 static csString GetAppDir (const char* argv0);
00303
00322 static csString GetResourceDir (const char* argv0);
00327 static csPathsList* GetPluginPaths (const char* argv0);
00331 static csString GetAppFilename (const char* basename);
00332 };
00333
00334
00335 namespace CS
00336 {
00337 namespace Platform
00338 {
00339
00341 CS_CRYSTALSPACE_EXPORT csString GetTempDirectory ();
00342
00344 CS_CRYSTALSPACE_EXPORT csString GetTempFilename (const char* path);
00345
00353 CS_CRYSTALSPACE_EXPORT int CreateDirectory (const char* path);
00354
00355 }
00356 }
00357
00358
00362 #endif