#ifndef B3_FILE_UTILS_H #define B3_FILE_UTILS_H #include #include "b3Scalar.h" #include //ptrdiff_h struct b3FileUtils { b3FileUtils() { } virtual ~b3FileUtils() { } bool findFile(const char* orgFileName, char* relativeFileName, int maxRelativeFileNameMaxLen) { FILE* f=0; f = fopen(orgFileName,"rb"); if (f) { //printf("original file found: [%s]\n", orgFileName); sprintf(relativeFileName,"%s", orgFileName); fclose(f); return true; } //printf("Trying various directories, relative to current working directory\n"); const char* prefix[]={"./","./data/","../data/","../../data/","../../../data/","../../../../data/"}; int numPrefixes = sizeof(prefix)/sizeof(const char*); f=0; bool fileFound = false; int result = 0; for (int i=0;!f && i0); if (maxPathLength>0) { path[0] = 0; } } } /*static const char* strip2(const char* name, const char* pattern) { size_t const patlen = strlen(pattern); size_t patcnt = 0; const char * oriptr; const char * patloc; // find how many times the pattern occurs in the original string for (oriptr = name; patloc = strstr(oriptr, pattern); oriptr = patloc + patlen) { patcnt++; } return oriptr; } */ }; #endif //B3_FILE_UTILS_H