diff options
author | Norbert Preining <norbert@preining.info> | 2019-10-29 03:00:39 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-10-29 03:00:39 +0000 |
commit | 97f5151099967e6c823d640a90d87bca92c44035 (patch) | |
tree | 685caa49488599f87d0caa4e972833b2263d8567 /dviware/dvisvgm/src/FilePath.cpp | |
parent | 25a647b97ef526aefcc75269dd19c46dbe3ae4c1 (diff) |
CTAN sync 201910290300
Diffstat (limited to 'dviware/dvisvgm/src/FilePath.cpp')
-rw-r--r-- | dviware/dvisvgm/src/FilePath.cpp | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/dviware/dvisvgm/src/FilePath.cpp b/dviware/dvisvgm/src/FilePath.cpp index 98449c101b..95fdab8c25 100644 --- a/dviware/dvisvgm/src/FilePath.cpp +++ b/dviware/dvisvgm/src/FilePath.cpp @@ -87,10 +87,28 @@ FilePath::FilePath (const string &path, bool isfile, const string ¤t_dir) } -/** Assigns a new path. Relative paths are relative to the current working directory. +/** Assigns a new path of a file or directory that already exists. + * Relative paths are relative to the current working directory. * @param[in] path absolute or relative path to a file or directory */ -void FilePath::set(const string &path) { - init(path, !FileSystem::isDirectory(path), FileSystem::getcwd()); +void FilePath::set (const string &path) { + set(path, !FileSystem::isDirectory(path)); +} + + +/** Assigns a new path. Relative paths are relative to the current working directory. + * @param[in] path absolute or relative path to a file or directory + * @param[in] isfile true if 'path' references a file, false if a directory is referenced */ +void FilePath::set (const string &path, bool isfile) { + init(path, isfile, FileSystem::getcwd()); +} + + +/** Assigns a new path. Relative paths are relative to the current working directory. + * @param[in] path absolute or relative path to a file or directory + * @param[in] isfile true if 'path' references a file, false if a directory is referenced + * @param[in] current_dir if 'path' is a relative path expression it will be related to 'current_dir' */ +void FilePath::set (const string &path, bool isfile, const string ¤t_dir) { + init(path, isfile, current_dir); } @@ -257,3 +275,18 @@ string FilePath::relative (string reldir, bool with_filename) const { path = "."; return single_slashes(path); } + + +/** 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 */ +string FilePath::shorterAbsoluteOrRelative (string reldir, bool with_filename) const { + string abs = absolute(with_filename); + string rel = relative(reldir, with_filename); + return abs.length() < rel.length() ? abs : rel; +} + + +bool FilePath::exists () const { + return empty() ? false : FileSystem::exists(absolute()); +}
\ No newline at end of file |