FILE* fopensearch(const char* filename, string& fullpath) { FILE* f; char* envpath; if ((f = fopen(filename, "r"))) { buildFullPathname(fullpath, filename); return f; } if ((f = fopenat(fullpath, gMasterDirectory, filename))) { return f; } if ((envpath = getenv("FAUST_LIB_PATH")) && (f = fopenat(fullpath, envpath, filename))) { return f; } if ((f = fopenat(fullpath, gFaustDirectory, "architecture", filename))) { return f; } if ((f = fopenat(fullpath, gFaustSuperDirectory, "architecture", filename))) { return f; } if ((f = fopenat(fullpath, gFaustSuperSuperDirectory, "architecture", filename))) { return f; } return 0; }
FILE* fopensearch(const char* filename, string& fullpath) { FILE* f; char* envpath; // search in current directory if ((f = fopen(filename, "r"))) { buildFullPathname(fullpath, filename); return f; } // search file in user supplied directory path for (list< string >::iterator i = gImportDirList.begin(); i != gImportDirList.end(); i++) { if ((f = fopenat(fullpath, *i, filename))) { //std::cerr << "found file : " << fullpath << std::endl; return f; } } // search in default directories if ((f = fopenat(fullpath, gMasterDirectory, filename))) { return f; } if ((envpath = getenv("FAUST_LIB_PATH")) && (f = fopenat(fullpath, envpath, filename))) { return f; } if ((f = fopenat(fullpath, gFaustDirectory, "architecture", filename))) { return f; } if ((f = fopenat(fullpath, gFaustSuperDirectory, "architecture", filename))) { return f; } if ((f = fopenat(fullpath, gFaustSuperSuperDirectory, "architecture", filename))) { return f; } #ifdef INSTALL_PREFIX if ((f = fopenat(fullpath, INSTALL_PREFIX "/lib/faust", filename))) { return f; } #endif if ((f = fopenat(fullpath, "/usr/local/lib/faust", filename))) { return f; } if ((f = fopenat(fullpath, "/usr/lib/faust", filename))) { return f; } return 0; }
FILE* fopensearch(const char* filename, string& fullpath) { FILE* f; char* envpath; if ((f = fopen(filename, "r"))) { buildFullPathname(fullpath, filename); return f; } if ((f = fopenat(fullpath, gMasterDirectory, filename))) { return f; } if ((envpath = getenv("FAUST_LIB_PATH")) && (f = fopenat(fullpath, envpath, filename))) { return f; } if ((f = fopenat(fullpath, gFaustDirectory, "architecture", filename))) { return f; } if ((f = fopenat(fullpath, gFaustSuperDirectory, "architecture", filename))) { return f; } if ((f = fopenat(fullpath, gFaustSuperSuperDirectory, "architecture", filename))) { return f; } #ifdef INSTALL_PREFIX if ((f = fopenat(fullpath, INSTALL_PREFIX "/lib/faust", filename))) { return f; } #endif if ((f = fopenat(fullpath, "/usr/local/lib/faust", filename))) { return f; } if ((f = fopenat(fullpath, "/usr/lib/faust", filename))) { return f; } return 0; }
/** * Try to open the file '<dir>/<filename>'. If it succeed, it stores the full pathname * of the file into <fullpath> */ static FILE* fopenat(string& fullpath, const string& dir, const char* filename) { return fopenat(fullpath, dir.c_str(), filename); }