FILE *PathList::OpenFileInPath( char *filename, char *mode ) { FILE* file; int i; char buf[1024]; /* open the file */ file = fopen( filename, mode ); /* if we couldn't find it, search the alternate paths */ if (!file) for (i=0;i<GetNumPaths(); i++) { sprintf( buf, "%s%s", GetPath(i), filename ); file = fopen( buf, mode ); if (file) break; } return file; }
char *PathList::GetCompletePath( char *filename ) { FILE* file; int i; char buf[1024]; /* open the file */ file = fopen( filename, "r" ); sprintf(buf,"%s",filename); /* if we couldn't find it, search the alternate paths */ if (!file){ for (i=0;i<GetNumPaths(); i++) { sprintf( buf, "%s%s", GetPath(i), filename ); file = fopen( buf, "r" ); if (file) break; } } if (!file) return NULL; fclose( file ); return strdup( buf ); }
/// \brief /// Creates a new path and returns a reference to it (same as implicitly adding a new path) /// /// \return /// Reference to newly added path inline VGPath& CreatePath() { m_paths.Add(new VGPath()); return GetPath(GetNumPaths()-1); }