OSG::PathHandler Class Reference

#include <OSGPathHandler.h>

List of all members.


Public Member Functions

Constructors


 PathHandler (void)
 PathHandler (const Char8 *initialPathList)
Destructor


virtual ~PathHandler (void)
Get


std::string findFile (const Char8 *fileName)
const std::string & getBaseFile (void) const
std::string extractPath (const Char8 *szFilename)
Set


void push_backPath (const Char8 *pathList)
void push_backCurrentDir (void)
void push_backUnixPath (const Char8 *pathList)
void push_backWin32Path (const Char8 *pathList)
void push_frontPath (const Char8 *pathList)
void push_frontCurrentDir (void)
void subPath (const Char8 *pathList)
void push_frontUnixPath (const Char8 *pathList)
void push_frontWin32Path (const Char8 *pathList)
void subUnixPath (const Char8 *pathList)
void subWin32Path (const Char8 *pathList)
void clearPathList (void)
void setBaseFile (const Char8 *fileName)
void clearBaseFile (void)
Dump


void dump (void)

Protected Types

enum  PathType {
  Win32Path = 0x0001, UnixPath = 0x0002, AbsPath = 0x0100, PlatformMask = 0x00FF,
  TypeMask = 0xFF00
}
typedef std::list< std::string > PathList
typedef std::list< std::string
>::iterator 
PathListIter

Protected Member Functions

Helper


void validateList (PathList &pathList)
PathType analysePathList (const Char8 *pathList)
PathType analysePath (const Char8 *path)
void expandWin32Path (std::string &path)
void expandUnixPath (std::string &path)
void push_backPathList (PathList &pathList)
void push_frontPathList (PathList &pathList)
void subPathList (const PathList &pathList)
void convertPath (std::string &path)
void convertWin32PathList (PathList &result)
void convertUnixPathList (PathList &result)
void splitPathList (const Char8 *pathList, const Char8 pathSep, PathList &result)
void parsePathList (const Char8 *pathList, PathList &result)
void parseUnixPathList (const Char8 *pathList, PathList &result)
void parseWin32PathList (const Char8 *pathList, PathList &result)

Protected Attributes

Member


PathList _pathList
std::string _baseFilePath

Static Protected Attributes

Static Constants


static const Char8 _dirSepWin32 = '\\'
static const Char8 _pathSepWin32 = ';'
static const Char8 _dirSepUnix = '/'
static const Char8 _pathSepUnix = ':'
static const Char8 _dirSep = _dirSepUnix
static const Char8 _pathSep = _pathSepUnix
static const Char8 _dirSepOther = _dirSepWin32
static const Char8 _pathSepOther = _pathSepWin32

Private Member Functions

 PathHandler (const PathHandler &source)
 prohibit default function (move to 'public' if needed)
void operator= (const PathHandler &source)
 prohibit default function (move to 'public' if needed)

Detailed Description

Definition at line 65 of file OSGPathHandler.h.


Member Typedef Documentation

typedef std::list<std::string> OSG::PathHandler::PathList [protected]

Definition at line 145 of file OSGPathHandler.h.

typedef std::list<std::string>::iterator OSG::PathHandler::PathListIter [protected]

Definition at line 146 of file OSGPathHandler.h.


Member Enumeration Documentation

enum OSG::PathHandler::PathType [protected]

Enumerator:
Win32Path 
UnixPath 
AbsPath 
PlatformMask 
TypeMask 

Definition at line 134 of file OSGPathHandler.h.

00135     {
00136         Win32Path     = 0x0001,
00137         UnixPath      = 0x0002,
00138 
00139         AbsPath       = 0x0100,
00140 
00141         PlatformMask  = 0x00FF,
00142         TypeMask      = 0xFF00
00143     };


Constructor & Destructor Documentation

PathHandler::PathHandler ( void   ) 

Definition at line 73 of file OSGPathHandler.cpp.

00073                              :
00074     _pathList    (),
00075     _baseFilePath()
00076 {
00077 }

PathHandler::PathHandler ( const Char8 *  initialPathList  ) 

Definition at line 79 of file OSGPathHandler.cpp.

References push_backUnixPath().

00080 {
00081     push_backUnixPath(initialPathList);
00082 }

PathHandler::~PathHandler ( void   )  [virtual]

Definition at line 86 of file OSGPathHandler.cpp.

00087 {
00088 }

OSG::PathHandler::PathHandler ( const PathHandler source  )  [private]


Member Function Documentation

std::string PathHandler::findFile ( const Char8 *  fileName  ) 

Definition at line 92 of file OSGPathHandler.cpp.

References _baseFilePath, _pathList, AbsPath, analysePath(), OSG::AccessFlags::IsReadable, parsePathList(), SINFO, OSG::File::tstAttr(), and TypeMask.

Referenced by OSG::VisitSubTree::changed(), OSG::Stage::changed(), OSG::SimpleStage::changed(), OSG::ProxyGroup::changed(), OSG::Algorithm::changed(), OSG::SceneFileHandlerBase::initPathHandler(), OSG::ImageFileHandlerBase::read(), OSG::DATImageFileType::read(), and OSG::OBJSceneFileType::readMTL().

00093 {
00094     std::string returnValue;
00095     bool        bFound      = false;
00096 
00097     PathList     tmpList;
00098 
00099     PathListIter iter    = _pathList.begin();
00100     PathListIter listEnd = _pathList.end();
00101 
00102     PathType     pType   = analysePath(fileName);
00103 
00104     // doesn't work for filenames with ;
00105     // the original patch for it looks broken or incomplete
00106     parsePathList(fileName, tmpList);
00107 
00108     if(tmpList.size() != 0)
00109     {
00110         if((pType & TypeMask) == AbsPath)
00111         {
00112             SINFO << "Check abs : " << tmpList.front() << std::endl;
00113 
00114             if(File::tstAttr(tmpList.front().c_str(),
00115                              AccessFlags::IsReadable))
00116             {
00117                 returnValue.assign(fileName);
00118             }
00119         }
00120         else
00121         {
00122             if(_baseFilePath.empty() == false)
00123             {
00124                 returnValue.assign(_baseFilePath);
00125 
00126                 returnValue.append(tmpList.front());
00127 
00128                 SINFO << "Check base : " << returnValue << std::endl;
00129 
00130                 if(File::tstAttr(returnValue.c_str(),
00131                                  AccessFlags::IsReadable) == false)
00132                 {
00133                     returnValue.erase();
00134                 }
00135                 else
00136                 {
00137                     bFound = true;
00138                 }
00139             }
00140 
00141             if(bFound == false)
00142             {
00143                 while(iter != listEnd)
00144                 {
00145                     returnValue.assign(*iter);
00146                     returnValue.append(tmpList.front());
00147 
00148                     SINFO << "Check from pl : " << returnValue << std::endl;
00149 
00150                     if(File::tstAttr(returnValue.c_str(),
00151                                      AccessFlags::IsReadable) == true)
00152                     {
00153                         break;
00154                     }
00155 
00156                     ++iter;
00157                 }
00158 
00159                 if(iter == listEnd)
00160                 {
00161                     returnValue.erase();
00162                 }
00163             }
00164         }
00165     }
00166 
00167     return returnValue;
00168 }

const std::string & PathHandler::getBaseFile ( void   )  const

Definition at line 170 of file OSGPathHandler.cpp.

References _baseFilePath.

00171 {
00172   return _baseFilePath;
00173 }

std::string PathHandler::extractPath ( const Char8 *  szFilename  ) 

Definition at line 355 of file OSGPathHandler.cpp.

References _dirSep, analysePathList(), convertPath(), PlatformMask, and Win32Path.

Referenced by setBaseFile().

00356 {
00357     std::string            returnValue(szFilename);
00358 
00359     std::string::size_type pos = returnValue.find_last_of("\\/");
00360 
00361     if(pos != std::string::npos)
00362     {
00363         if(pos != returnValue.length() - 1)
00364         {
00365             returnValue.erase(pos + 1);
00366         }
00367     }
00368     else
00369     {
00370         returnValue.assign(".");
00371     }
00372 
00373     PathType pType = analysePathList(returnValue.c_str());
00374 
00375     if((pType & PlatformMask) == Win32Path)
00376     {
00377 #ifndef WIN32
00378         convertPath(returnValue);
00379 #endif
00380     }
00381     else
00382     {
00383 #ifdef WIN32
00384         convertPath(returnValue);
00385 #endif
00386     }
00387 
00388     if(returnValue[returnValue.length() - 1] != _dirSep)
00389     {
00390         returnValue += _dirSep;
00391     }
00392 
00393     return returnValue;
00394 }

void PathHandler::push_backPath ( const Char8 *  pathList  ) 

Definition at line 177 of file OSGPathHandler.cpp.

References parsePathList(), and push_backPathList().

00178 {
00179     PathList tmpList;
00180 
00181     parsePathList(pathList, tmpList);
00182 
00183     push_backPathList(tmpList);
00184 }

void PathHandler::push_backCurrentDir ( void   ) 

Definition at line 186 of file OSGPathHandler.cpp.

References _pathList, OSG::Directory::getCurrent(), and validateList().

00187 {
00188     Char8       *pCurrentDir = Directory::getCurrent();
00189     std::string  tmpString   = pCurrentDir;
00190 
00191     _pathList.push_back(tmpString);
00192 
00193     validateList(_pathList);
00194 
00195     delete [] pCurrentDir;
00196 }

void PathHandler::push_backUnixPath ( const Char8 *  pathList  ) 

Definition at line 198 of file OSGPathHandler.cpp.

References parseUnixPathList(), and push_backPathList().

Referenced by PathHandler().

00199 {
00200     PathList tmpList;
00201 
00202     parseUnixPathList(pathList, tmpList);
00203 
00204     push_backPathList(tmpList);
00205 }

void PathHandler::push_backWin32Path ( const Char8 *  pathList  ) 

Definition at line 207 of file OSGPathHandler.cpp.

References parseWin32PathList(), and push_backPathList().

00208 {
00209     PathList tmpList;
00210 
00211     parseWin32PathList(pathList, tmpList);
00212 
00213     push_backPathList(tmpList);
00214 }

void PathHandler::push_frontPath ( const Char8 *  pathList  ) 

Definition at line 217 of file OSGPathHandler.cpp.

References parsePathList(), and push_frontPathList().

00218 {
00219     PathList tmpList;
00220 
00221     parsePathList(pathList, tmpList);
00222 
00223     push_frontPathList(tmpList);
00224 }

void PathHandler::push_frontCurrentDir ( void   ) 

Definition at line 226 of file OSGPathHandler.cpp.

References _pathList, OSG::Directory::getCurrent(), and validateList().

Referenced by OSG::SceneFileHandlerBase::initPathHandler().

00227 {
00228     Char8       *pCurrentDir = Directory::getCurrent();
00229     std::string  tmpString   = pCurrentDir;
00230 
00231     _pathList.push_front(tmpString);
00232 
00233     validateList(_pathList);
00234 
00235     delete [] pCurrentDir;
00236 }

void PathHandler::subPath ( const Char8 *  pathList  ) 

Definition at line 256 of file OSGPathHandler.cpp.

References parsePathList(), subPathList(), and validateList().

00257 {
00258     PathList tmpList;
00259 
00260     parsePathList(pathList, tmpList);
00261 
00262     validateList(tmpList);
00263 
00264     subPathList(tmpList);
00265 }

void PathHandler::push_frontUnixPath ( const Char8 *  pathList  ) 

Definition at line 238 of file OSGPathHandler.cpp.

References parseUnixPathList(), and push_frontPathList().

00239 {
00240     PathList tmpList;
00241 
00242     parseUnixPathList(pathList, tmpList);
00243 
00244     push_frontPathList(tmpList);
00245 }

void PathHandler::push_frontWin32Path ( const Char8 *  pathList  ) 

Definition at line 247 of file OSGPathHandler.cpp.

References parseWin32PathList(), and push_frontPathList().

00248 {
00249     PathList tmpList;
00250 
00251     parseWin32PathList(pathList, tmpList);
00252 
00253     push_frontPathList(tmpList);
00254 }

void PathHandler::subUnixPath ( const Char8 *  pathList  ) 

Definition at line 267 of file OSGPathHandler.cpp.

References parsePathList(), subPathList(), and validateList().

00268 {
00269     PathList tmpList;
00270 
00271     parsePathList(pathList, tmpList);
00272 
00273     validateList(tmpList);
00274 
00275     subPathList(tmpList);
00276 }

void PathHandler::subWin32Path ( const Char8 *  pathList  ) 

Definition at line 278 of file OSGPathHandler.cpp.

References parseUnixPathList(), subPathList(), and validateList().

00279 {
00280     PathList tmpList;
00281 
00282     parseUnixPathList(pathList, tmpList);
00283 
00284     validateList(tmpList);
00285 
00286     subPathList(tmpList);
00287 }

void PathHandler::clearPathList ( void   ) 

Definition at line 289 of file OSGPathHandler.cpp.

References _pathList.

Referenced by OSG::SceneFileHandlerBase::initPathHandler().

00290 {
00291     _pathList.clear();
00292 }

void PathHandler::setBaseFile ( const Char8 *  fileName  ) 

Definition at line 295 of file OSGPathHandler.cpp.

References _baseFilePath, and extractPath().

Referenced by OSG::SceneFileHandlerBase::initPathHandler().

00296 {
00297     if(fileName != NULL)
00298     {
00299         _baseFilePath = extractPath(fileName);
00300     }
00301 }

void PathHandler::clearBaseFile ( void   ) 

Definition at line 303 of file OSGPathHandler.cpp.

References _baseFilePath.

Referenced by OSG::SceneFileHandlerBase::initPathHandler().

00304 {
00305     _baseFilePath.erase();
00306 }

void PathHandler::dump ( void   ) 

Definition at line 310 of file OSGPathHandler.cpp.

References _baseFilePath, _pathList, and SLOG.

00311 {
00312     PathListIter iter = _pathList.begin();
00313 
00314     if(_baseFilePath.size() != 0)
00315     {
00316         SLOG << "Base file path : " << _baseFilePath << std::endl;
00317     }
00318     else
00319     {
00320         SLOG << "Base file path : empty" << std::endl;
00321     }
00322 
00323     for( ; iter != _pathList.end(); ++iter )
00324     {
00325         SLOG << "\"" << *iter << "\"" << std::endl;
00326     }
00327 }

void PathHandler::validateList ( PathList pathList  )  [protected]

Definition at line 331 of file OSGPathHandler.cpp.

References _dirSep.

Referenced by push_backCurrentDir(), push_backPathList(), push_frontCurrentDir(), push_frontPathList(), subPath(), subUnixPath(), and subWin32Path().

00332 {
00333     PathListIter iter    = pathList.begin();
00334     PathListIter listEnd = pathList.end();
00335 
00336     while(iter != listEnd)
00337     {
00338         if(iter->empty() == true)
00339         {
00340             (*iter) += '.';
00341             (*iter) += _dirSep;
00342         }
00343         else
00344         {
00345             if((*iter)[iter->length() - 1] != _dirSep)
00346             {
00347                 (*iter) += _dirSep;
00348             }
00349         }
00350 
00351         ++iter;
00352     }
00353 }

PathHandler::PathType PathHandler::analysePathList ( const Char8 *  pathList  )  [protected]

Definition at line 396 of file OSGPathHandler.cpp.

References UnixPath, and Win32Path.

Referenced by extractPath(), and parsePathList().

00397 {
00398           PathType  returnValue = UnixPath;
00399     const Char8    *pCurr       = pathList;
00400 
00401     if(pathList == NULL)
00402         return returnValue;
00403 
00404     while(*pCurr != '\0')
00405     {
00406         if(*pCurr == '\\')
00407         {
00408             returnValue = Win32Path;
00409             break;
00410         }
00411         else if(*pCurr == ';')
00412         {
00413             returnValue = Win32Path;
00414             break;
00415         }
00416         else if(*pCurr == '%')
00417         {
00418             returnValue = Win32Path;
00419             break;
00420         }
00421         else if(*pCurr == '/')
00422         {
00423             returnValue = UnixPath;
00424             break;
00425         }
00426         else if(*pCurr == '$')
00427         {
00428             returnValue = UnixPath;
00429             break;
00430         }
00431         else if(*pCurr == ':')
00432         {
00433             if(*(pCurr + 1) == '\\')
00434             {
00435                 returnValue = Win32Path;
00436                 break;
00437             }
00438         }
00439 
00440         pCurr++;
00441     }
00442 
00443 #ifdef WIN32
00444     // HACK but d:/data/tie.wrl is also a valid windows path.
00445     if(returnValue == UnixPath)
00446     {
00447         // ok first look for a ";" in the path list.
00448         UInt32 uiSize = 0;
00449 
00450         pCurr = pathList;
00451 
00452         while(*pCurr != '\0')
00453         {
00454             if(*pCurr == ';')
00455             {
00456                 returnValue = Win32Path;
00457                 break;
00458             }
00459 
00460             pCurr++;
00461             uiSize++;
00462         }
00463 
00464         // ok we found no ";" in the list look for a absolute windows path.
00465         if(returnValue == UnixPath)
00466         {
00467             if(uiSize >= 3)
00468             {
00469                 if(pathList[1] == ':' &&
00470                    (pathList[2] == '/' || pathList[2] == '\\'))
00471                 {
00472                     returnValue = Win32Path;
00473                 }
00474             }
00475         }
00476     }
00477 #endif
00478 
00479     return returnValue;
00480 }

PathHandler::PathType PathHandler::analysePath ( const Char8 *  path  )  [protected]

Definition at line 482 of file OSGPathHandler.cpp.

References AbsPath, UnixPath, and Win32Path.

Referenced by findFile().

00483 {
00484           PathType  returnValue = UnixPath;
00485           UInt32    uiSize      = 0;
00486     const Char8    *pCurr       = path;
00487 
00488     if(path == NULL)
00489         return returnValue;
00490 
00491     while(*pCurr != '\0')
00492     {
00493         if(*pCurr == '\\')
00494         {
00495             returnValue = Win32Path;
00496             break;
00497         }
00498         else if(*pCurr == ';')
00499         {
00500             returnValue = Win32Path;
00501             break;
00502         }
00503         else if(*pCurr == '%')
00504         {
00505             returnValue = Win32Path;
00506             break;
00507         }
00508         else if(*pCurr == '/')
00509         {
00510             returnValue = UnixPath;
00511             break;
00512         }
00513         else if(*pCurr == '$')
00514         {
00515             returnValue = UnixPath;
00516             break;
00517         }
00518         else if(*pCurr == ':')
00519         {
00520             if(*(pCurr + 1) == '\\')
00521             {
00522                 returnValue = Win32Path;
00523                 uiSize++;
00524                 break;
00525             }
00526         }
00527 
00528         pCurr++;
00529         uiSize++;
00530     }
00531 
00532 #ifdef WIN32
00533     if(returnValue == UnixPath)
00534     {
00535         // d:/data/tie.wrl is also a windows path!
00536         if(uiSize >= 2)
00537         {
00538             if(path[1] == ':')
00539                 returnValue = Win32Path;
00540         }
00541     }
00542 #endif
00543 
00544     if(returnValue == Win32Path)
00545     {
00546         if(uiSize >= 2)
00547         {
00548             if(path[1] == ':')
00549                 returnValue = (PathType) (returnValue | AbsPath);
00550         }
00551         else
00552         {
00553             // windows network path.
00554             if(path[0] == '\\' && path[1] == '\\')
00555                 returnValue = (PathType) (returnValue | AbsPath);
00556         }
00557     }
00558     else
00559     {
00560         if(path[0] == '/')
00561             returnValue = (PathType) (returnValue | AbsPath);
00562     }
00563 
00564     return returnValue;
00565 }

void PathHandler::expandWin32Path ( std::string &  path  )  [protected]

Definition at line 567 of file OSGPathHandler.cpp.

References FWARNING.

Referenced by convertWin32PathList().

00568 {
00569     std::string            envVar;
00570 
00571     std::string::size_type currPos  = 0;
00572     std::string::size_type startPos = 0;
00573 
00574     while(currPos < path.size())
00575     {
00576         if(path[currPos] == '%')
00577         {
00578             envVar.erase();
00579             startPos = currPos++;
00580 
00581             while(path[currPos] != '%' &&
00582                   currPos < path.size())
00583             {
00584                 envVar += path[currPos++];
00585             }
00586 
00587             if(currPos < path.size())
00588             {
00589                 currPos++;
00590             }
00591 
00592             Char8 *szEnvVal = getenv(envVar.c_str());
00593 
00594             if(szEnvVal == NULL)
00595             {
00596                 FWARNING(("Could not find env var %s\n", envVar.c_str()));
00597             }
00598             else
00599             {
00600                 path.replace(startPos, currPos - startPos, szEnvVal);
00601             }
00602         }
00603         else
00604         {
00605             currPos++;
00606         }
00607     }
00608 }

void PathHandler::expandUnixPath ( std::string &  path  )  [protected]

Definition at line 610 of file OSGPathHandler.cpp.

References FWARNING.

Referenced by convertUnixPathList().

00611 {
00612     std::string  envVar;
00613     std::string  userName;
00614     std::string  userHome;
00615 #ifndef WIN32
00616     bool         stop;
00617     passwd      *userInfo;
00618 #endif
00619 
00620     std::string::size_type currPos  = 0;
00621     std::string::size_type startPos = 0;
00622 
00623     while(currPos < path.size())
00624     {
00625         if(path[currPos] == '$')
00626         {
00627             envVar.erase();
00628             startPos = currPos++;
00629 
00630             while(path[currPos] != ':' &&
00631                   path[currPos] != '/' &&
00632                   path[currPos] != '$' &&
00633                   currPos < path.size())
00634             {
00635                 envVar += path[currPos++];
00636             }
00637 
00638             Char8 *szEnvVal = getenv(envVar.c_str());
00639 
00640             if(szEnvVal == NULL)
00641             {
00642                 FWARNING(("Could not find env var %s\n", envVar.c_str()));
00643             }
00644             else
00645             {
00646                 path.replace(startPos, currPos - startPos, szEnvVal);
00647             }
00648         }
00649 #ifndef WIN32
00650         else if(path[currPos] == '~')
00651         {
00652             userName.erase();
00653             startPos = currPos++;
00654 
00655             while(path[currPos] != ':' &&
00656                   path[currPos] != '/' &&
00657                   path[currPos] != '$' &&
00658                   currPos < path.size())
00659             {
00660                 userName += path[currPos++];
00661             }
00662             
00663             if(!userName.empty())
00664             {
00665                 setpwent();     //prepare access to user db
00666                 stop = false;
00667 
00668                 while(stop == false)
00669                 {
00670                     if((userInfo=getpwent()) != NULL )
00671                     {
00672                         if(strcmp(userName.c_str(), userInfo->pw_name) == 0)
00673                         {
00674                             stop = true;
00675                             userHome = userInfo->pw_dir;
00676                         }
00677                     }
00678                     else
00679                     {
00680                         stop = true;
00681                     }
00682                 }
00683                 endpwent();
00684             }
00685             else
00686             {
00687                 if((userInfo=getpwuid(getuid())) != NULL)
00688                 {
00689                     userHome = userInfo->pw_dir;
00690                 }
00691             }
00692 
00693             if(userHome.empty() == false)
00694             {
00695                 path.replace(startPos, currPos - startPos, userHome);
00696             }
00697             else
00698             {
00699                 FWARNING(("Could not find user home %s\n", userHome.c_str()));
00700             }
00701         }
00702 #endif
00703         else
00704         {
00705             currPos++;
00706         }
00707     }
00708 }

void PathHandler::push_backPathList ( PathList pathList  )  [protected]

Definition at line 710 of file OSGPathHandler.cpp.

References _pathList, and validateList().

Referenced by push_backPath(), push_backUnixPath(), and push_backWin32Path().

00711 {
00712     _pathList.splice(_pathList.end(), pathList);
00713 
00714     validateList(_pathList);
00715 }

void PathHandler::push_frontPathList ( PathList pathList  )  [protected]

Definition at line 717 of file OSGPathHandler.cpp.

References _pathList, and validateList().

Referenced by push_frontPath(), push_frontUnixPath(), and push_frontWin32Path().

00718 {
00719     _pathList.splice(_pathList.begin(), pathList);
00720 
00721     validateList(_pathList);
00722 }

void PathHandler::subPathList ( const PathList pathList  )  [protected]

Definition at line 724 of file OSGPathHandler.cpp.

References _pathList.

Referenced by subPath(), subUnixPath(), and subWin32Path().

00725 {
00726     for(PathList::const_iterator i = pathList.begin(); i != pathList.end();++i)
00727     {
00728         for(PathList::iterator j = _pathList.begin(); j != _pathList.end();++j)
00729         {
00730             if(*j == *i)
00731             {
00732                 _pathList.erase(j);
00733                 break;
00734             }
00735         }
00736     }
00737 }

void PathHandler::convertPath ( std::string &  path  )  [protected]

Definition at line 739 of file OSGPathHandler.cpp.

References _dirSep, and _dirSepOther.

Referenced by convertUnixPathList(), convertWin32PathList(), and extractPath().

00740 {
00741     std::string::iterator stringIt  = path.begin();
00742     std::string::iterator stringEnd = path.end  ();
00743 
00744     while(stringIt != stringEnd)
00745     {
00746         if(*stringIt == _dirSepOther)
00747         {
00748             *stringIt = _dirSep;
00749         }
00750 
00751         stringIt++;
00752     };
00753 }

void PathHandler::convertWin32PathList ( PathList result  )  [protected]

Definition at line 755 of file OSGPathHandler.cpp.

References convertPath(), and expandWin32Path().

Referenced by parseWin32PathList().

00756 {
00757     PathListIter iter    = result.begin();
00758     PathListIter endList = result.end();
00759 
00760     while(iter != endList)
00761     {
00762         expandWin32Path(*iter);
00763 
00764 #ifndef WIN32
00765         convertPath    (*iter);
00766 #endif
00767 
00768         iter++;
00769     };
00770 }

void PathHandler::convertUnixPathList ( PathList result  )  [protected]

Definition at line 772 of file OSGPathHandler.cpp.

References convertPath(), and expandUnixPath().

Referenced by parseUnixPathList().

00773 {
00774     PathListIter iter    = result.begin();
00775     PathListIter endList = result.end();
00776 
00777     while(iter != endList)
00778     {
00779         expandUnixPath(*iter);
00780 
00781 #ifdef WIN32
00782         convertPath   (*iter);
00783 #endif
00784 
00785         iter++;
00786     };
00787 }

void PathHandler::splitPathList ( const Char8 *  pathList,
const Char8  pathSep,
PathList result 
) [protected]

Definition at line 789 of file OSGPathHandler.cpp.

Referenced by parseUnixPathList(), and parseWin32PathList().

00792 {
00793     std::string::size_type currPos    = 0;
00794     std::string::size_type startPos   = 0;
00795     std::string            workString(pathList);
00796 
00797     currPos = workString.find(pathSep);
00798 
00799     if(currPos == std::string::npos)
00800     {
00801         result.push_back(workString);
00802     }
00803     else
00804     {
00805         while(currPos != std::string::npos)
00806         {
00807             result.push_back(workString.substr(startPos,
00808                                                currPos - startPos));
00809 
00810             startPos = currPos + 1;
00811 
00812             currPos = workString.find(pathSep, startPos);
00813         }
00814 
00815         if(startPos != 0)
00816         {
00817             result.push_back(workString.substr(startPos));
00818         }
00819     }
00820 }

void PathHandler::parsePathList ( const Char8 *  pathList,
PathList result 
) [protected]

Definition at line 822 of file OSGPathHandler.cpp.

References analysePathList(), parseUnixPathList(), parseWin32PathList(), PlatformMask, and Win32Path.

Referenced by findFile(), push_backPath(), push_frontPath(), subPath(), and subUnixPath().

00823 {
00824     PathType pType = analysePathList(pathList);
00825 
00826     if((pType & PlatformMask) == Win32Path)
00827     {
00828         parseWin32PathList(pathList, result);
00829     }
00830     else
00831     {
00832         parseUnixPathList (pathList, result);
00833     }
00834 }

void PathHandler::parseUnixPathList ( const Char8 *  pathList,
PathList result 
) [protected]

Definition at line 836 of file OSGPathHandler.cpp.

References _pathSepUnix, convertUnixPathList(), and splitPathList().

Referenced by parsePathList(), push_backUnixPath(), push_frontUnixPath(), and subWin32Path().

00837 {
00838     if(pathList == NULL)
00839         return;
00840 
00841     splitPathList      (pathList, _pathSepUnix, result);
00842 
00843     convertUnixPathList(result);
00844 }

void PathHandler::parseWin32PathList ( const Char8 *  pathList,
PathList result 
) [protected]

Definition at line 846 of file OSGPathHandler.cpp.