Merge pull request #42 from DDRBoxman/master

Add search path arg
This commit is contained in:
auriamg 2019-10-17 19:48:38 -04:00 committed by GitHub
commit 9cf053f8b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 0 deletions

View File

@ -97,4 +97,9 @@ bool isPrefixBundled(std::string prefix)
return true;
}
std::vector<std::string> searchPaths;
void addSearchPath(std::string path){ searchPaths.push_back(path); }
int searchPathAmount(){ return searchPaths.size(); }
std::string searchPath(const int n){ return searchPaths[n]; }
}

View File

@ -56,5 +56,9 @@ std::string fileToFix(const int n);
std::string inside_lib_path();
void inside_lib_path(std::string p);
void addSearchPath(std::string path);
int searchPathAmount();
std::string searchPath(const int n);
}
#endif

View File

@ -169,6 +169,20 @@ int systemp(std::string& cmd)
std::string getUserInputDirForFile(const std::string& filename)
{
const int searchPathAmount = Settings::searchPathAmount();
for(int n=0; n<searchPathAmount; n++)
{
auto searchPath = Settings::searchPath(n);
if( !searchPath.empty() && searchPath[ searchPath.size()-1 ] != '/' ) searchPath += "/";
if( !fileExists( searchPath+filename ) ) {
continue;
} else {
std::cerr << (searchPath+filename) << " was found. /!\\MANUALLY CHECK THE EXECUTABLE WITH 'otool -L', DYLIBBUNDLDER MAY NOT HANDLE CORRECTLY THIS UNSTANDARD/ILL-FORMED DEPENDENCY" << std::endl;
return searchPath;
}
}
while (true)
{
std::cout << "Please specify now the directory where this library can be found (or write 'quit' to abort): "; fflush(stdout);

View File

@ -121,6 +121,12 @@ int main (int argc, char * const argv[])
showHelp();
exit(0);
}
if(strcmp(argv[i],"-s")==0 or strcmp(argv[i],"--search-path")==0)
{
i++;
Settings::addSearchPath(argv[i]);
continue;
}
else if(i>0)
{
// if we meet an unknown flag, abort