Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages
syspath.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2003 by Frank Richter 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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 csPluginPaths; 00040 00046 CS_CSUTIL_EXPORT csRef<iStringArray> csFindSystemRoots(); 00047 00056 CS_CSUTIL_EXPORT csString csGetConfigPath (); 00057 00062 CS_CSUTIL_EXPORT csPluginPaths* csGetPluginPaths (const char* argv0); 00063 00070 CS_CSUTIL_EXPORT char* csExpandPath (const char* path); 00071 00084 CS_CSUTIL_EXPORT csString csGetAppPath (const char* argv0); 00085 00099 CS_CSUTIL_EXPORT csString csGetAppDir (const char* argv0); 00100 00119 CS_CSUTIL_EXPORT csString csGetResourceDir (const char* argv0); 00120 00129 CS_CSUTIL_EXPORT bool csPathsIdentical (const char* path1, const char* path2); 00130 00134 struct CS_CSUTIL_EXPORT csPluginPath 00135 { 00140 char* path; 00142 char* type; 00144 bool scanRecursive; 00145 00146 csPluginPath () : path (0), type(0), scanRecursive (false) {} 00147 csPluginPath (const char* path, const char* type, bool recursive = false) 00148 { 00149 csPluginPath::path = csStrNew (path); 00150 csPluginPath::type = csStrNew (type); 00151 scanRecursive = recursive; 00152 }; 00153 csPluginPath (char* path, char* type, bool recursive = false) 00154 { 00155 csPluginPath::path = path; 00156 csPluginPath::type = type; 00157 scanRecursive = recursive; 00158 }; 00159 csPluginPath (const csPluginPath& src) 00160 { 00161 path = csStrNew (src.path); 00162 type = csStrNew (src.type); 00163 scanRecursive = src.scanRecursive; 00164 }; 00165 ~csPluginPath () { delete[] path; delete[] type; } 00166 }; 00167 00171 class CS_CSUTIL_EXPORT csPluginPaths 00172 { 00173 csArray<csPluginPath> paths; 00174 public: 00175 csPluginPaths () : paths (4, 4) { } 00176 00189 size_t AddOnce (const char* path, bool scanRecursive = false, 00190 const char* type = 0, bool overrideRecursive = true) 00191 { 00192 if (path == 0) return (size_t)-1; 00193 char* pathExpanded = csExpandPath (path); 00194 if (pathExpanded == 0) return (size_t)-1; 00195 00196 size_t i; 00197 for (i = 0; i < paths.Length(); i++) 00198 { 00199 if (csPathsIdentical (pathExpanded, paths[i].path)) 00200 { 00201 if (overrideRecursive) 00202 { 00203 paths[i].scanRecursive = scanRecursive; 00204 } 00205 delete[] paths[i].type; 00206 paths[i].type = csStrNew (type); 00207 delete[] pathExpanded; 00208 00209 return i; 00210 } 00211 } 00212 00213 csPluginPath pluginPath (pathExpanded, csStrNew (type), scanRecursive); 00214 return (paths.Push (pluginPath)); 00215 } 00216 00217 size_t GetCount () { return paths.Length(); } 00218 csPluginPath const& operator [] (size_t n) const 00219 { return paths[n]; } 00220 }; 00221 00225 #endif
Generated for Crystal Space by doxygen 1.3.9.1