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
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef _OSGPATHHANDLER_H
00040 #define _OSGPATHHANDLER_H
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044
00045 #include <stdlib.h>
00046 #include <fcntl.h>
00047 #include <list>
00048 #include <string>
00049
00050 #ifndef WIN32
00051 #include <unistd.h>
00052 #endif
00053
00054 #include <OSGBaseTypes.h>
00055 #include <OSGConfig.h>
00056 #include <OSGLog.h>
00057
00058 OSG_BEGIN_NAMESPACE
00059
00063 class OSG_BASE_DLLMAPPING PathHandler
00064 {
00065
00066
00067 public:
00068
00069
00073 PathHandler(void);
00074 PathHandler(const Char8 *initialPathList);
00075
00077
00081 virtual ~PathHandler(void);
00082
00084
00088 std::string findFile (const Char8 *fileName);
00089
00090 const std::string &getBaseFile( void ) const;
00091
00093
00097 void push_backPath (const Char8 *pathList);
00098 void push_backCurrentDir ( void );
00099
00100 void push_backUnixPath (const Char8 *pathList);
00101 void push_backWin32Path (const Char8 *pathList);
00102
00103 void push_frontPath (const Char8 *pathList);
00104 void push_frontCurrentDir( void );
00105
00106 void push_frontUnixPath (const Char8 *pathList);
00107 void push_frontWin32Path (const Char8 *pathList);
00108
00109 void subPath (const Char8 *pathList);
00110 void subUnixPath (const Char8 *pathList);
00111 void subWin32Path (const Char8 *pathList);
00112
00113 void clearPathList ( void );
00114
00115 void setBaseFile (const Char8 *fileName);
00116 void clearBaseFile ( void );
00117
00118 std::string extractPath (const Char8 *szFilename);
00119
00121
00125 void dump(void);
00126
00128
00129
00130 protected:
00131
00132 enum PathType
00133 {
00134 Win32Path = 0x0001,
00135 UnixPath = 0x0002,
00136
00137 AbsPath = 0x0100,
00138
00139 PlatformMask = 0x00FF,
00140 TypeMask = 0xFF00
00141 };
00142
00143 typedef std::list<std::string> PathList;
00144 typedef std::list<std::string>::iterator PathListIter;
00145
00146
00150 static const Char8 _dirSepWin32;
00151 static const Char8 _pathSepWin32;
00152
00153 static const Char8 _dirSepUnix;
00154 static const Char8 _pathSepUnix;
00155
00156 static const Char8 _dirSep;
00157 static const Char8 _pathSep;
00158
00159 static const Char8 _dirSepOther;
00160 static const Char8 _pathSepOther;
00161
00163
00167 PathList _pathList;
00168 std::string _baseFilePath;
00169
00171
00175 void validateList ( PathList &pathList );
00176
00177 PathType analysePathList (const Char8 *pathList );
00178 PathType analysePath (const Char8 *path );
00179
00180 void expandWin32Path ( std::string &path );
00181 void expandUnixPath ( std::string &path );
00182
00183 void push_backPathList ( PathList &pathList );
00184 void push_frontPathList ( PathList &pathList );
00185
00186 void subPathList (const PathList &pathList );
00187
00188 void convertPath ( std::string &path );
00189
00190 void convertWin32PathList( PathList &result );
00191 void convertUnixPathList ( PathList &result );
00192
00193 void splitPathList (const Char8 *pathList,
00194 const Char8 pathSep,
00195 PathList &result );
00196 void parsePathList (const Char8 *pathList,
00197 PathList &result );
00198 void parseUnixPathList (const Char8 *pathList,
00199 PathList &result );
00200 void parseWin32PathList (const Char8 *pathList,
00201 PathList &result );
00202
00204
00205
00206 private:
00207
00209 PathHandler(const PathHandler &source);
00211 void operator =(const PathHandler &source);
00212 };
00213
00214 OSG_END_NAMESPACE
00215
00216 #endif
00217
00218 #define OSGPATHHANDLER_HEADER_CVSID "@(#)$Id: $"
00219