diff options
author | Norbert Preining <norbert@preining.info> | 2019-11-16 03:00:48 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-11-16 03:00:48 +0000 |
commit | bad81a00a2943d1fb7ff2de3d0ae48c049dac302 (patch) | |
tree | ca23b6ca941037d20dce638d0859309f3c48c66d /dviware/dvisvgm/src/FilePath.cpp | |
parent | 0e223aaa93c5ee0c0e937c23f75535269324d217 (diff) |
CTAN sync 201911160300
Diffstat (limited to 'dviware/dvisvgm/src/FilePath.cpp')
-rw-r--r-- | dviware/dvisvgm/src/FilePath.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/dviware/dvisvgm/src/FilePath.cpp b/dviware/dvisvgm/src/FilePath.cpp index 95fdab8c25..c859d30469 100644 --- a/dviware/dvisvgm/src/FilePath.cpp +++ b/dviware/dvisvgm/src/FilePath.cpp @@ -277,6 +277,11 @@ string FilePath::relative (string reldir, bool with_filename) const { } +string FilePath::relative (const FilePath &filepath, bool with_filename) const { + return relative(filepath.absolute(false), with_filename); +} + + /** Return the absolute or relative path whichever is shorter. * @param[in] reldir absolute path to a directory * @param[in] with_filename if false, the filename is omitted */ @@ -289,4 +294,18 @@ string FilePath::shorterAbsoluteOrRelative (string reldir, bool with_filename) c bool FilePath::exists () const { return empty() ? false : FileSystem::exists(absolute()); -}
\ No newline at end of file +} + + +/** Checks if a given path is absolute or relative. + * @param[in] path path string to check + * @return true if path is absolute */ +bool FilePath::isAbsolute (string path) { + path = util::trim(path); +#ifdef _WIN32 + path = FileSystem::adaptPathSeperators(path); + if (path.length() >= 2 && path[1] == ':' && isalpha(path[0])) + path.erase(0, 2); // remove drive letter and colon +#endif + return !path.empty() && path[0] == '/'; +} |