diff options
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/src/FileFinder.cpp')
-rw-r--r-- | Build/source/texk/dvisvgm/dvisvgm-src/src/FileFinder.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/FileFinder.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/FileFinder.cpp index a72bd1fa3a1..8caae75275a 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/FileFinder.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/FileFinder.cpp @@ -37,7 +37,7 @@ #include <cstdlib> #include <fstream> #include <map> -#include <string> +#include <set> #include "FileFinder.h" #include "FileSystem.h" #include "FontMap.h" @@ -48,6 +48,7 @@ static bool _initialized = false; static bool _mktex_enabled = false; +static std::set<std::string> _additional_dirs; // --------------------------------------------------- @@ -66,6 +67,7 @@ void FileFinder::init (const char *argv0, const char *progname, bool enable_mkte return; _mktex_enabled = enable_mktexmf; + addLookupDir("."); // always lookup files in the current working directory #ifdef MIKTEX miktex = new MiKTeXCom; #else @@ -123,6 +125,11 @@ std::string FileFinder::version () { } +void FileFinder::addLookupDir (const std::string &path) { + _additional_dirs.insert(path); +} + + /** Determines filetype by the filename extension and calls kpse_find_file * to actually look up the file. * @param[in] fname name of file to look up @@ -133,10 +140,16 @@ static const char* find_file (const std::string &fname, const char *ftype) { return 0; static std::string buf; - // try to lookup the file in the current working directory - buf = FileSystem::getcwd()+"/"+fname; - if (FileSystem::exists(buf.c_str())) - return buf.c_str(); + // try to lookup the file in the additionally specified directories + for (std::set<std::string>::iterator it=_additional_dirs.begin(); it != _additional_dirs.end(); ++it) { + if (it->at(0) == '/') + buf.clear(); + else + buf = FileSystem::getcwd()+"/"; + buf += (*it) + "/" + fname; + if (FileSystem::exists(buf)) + return buf.c_str(); + } std::string ext; if (ftype) @@ -152,7 +165,7 @@ static const char* find_file (const std::string &fname, const char *ftype) { if (ext == "dll" || ext == "exe") { // lookup dll and exe files in the MiKTeX bin directory first buf = miktex->getBinDir() + "/" + fname; - if (FileSystem::exists(buf.c_str())) + if (FileSystem::exists(buf)) return buf.c_str(); } else if (ext == "cmap") { @@ -175,7 +188,7 @@ static const char* find_file (const std::string &fname, const char *ftype) { // lookup exe files in directory where dvisvgm is located if (const char *path = kpse_var_value("SELFAUTOLOC")) { buf = std::string(path) + "/" + fname; - return FileSystem::exists(buf.c_str()) ? buf.c_str() : 0; + return FileSystem::exists(buf) ? buf.c_str() : 0; } return 0; } |