summaryrefslogtreecommitdiff
path: root/dviware/dvisvgm/src/FileSystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dviware/dvisvgm/src/FileSystem.cpp')
-rw-r--r--dviware/dvisvgm/src/FileSystem.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/dviware/dvisvgm/src/FileSystem.cpp b/dviware/dvisvgm/src/FileSystem.cpp
index e1db59fa03..ada3f8e47c 100644
--- a/dviware/dvisvgm/src/FileSystem.cpp
+++ b/dviware/dvisvgm/src/FileSystem.cpp
@@ -2,7 +2,7 @@
** FileSystem.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2021 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -135,16 +135,38 @@ string FileSystem::ensureForwardSlashes (string path) {
}
+/** Returns the absolute path of the current working directory. */
string FileSystem::getcwd () {
char buf[1024];
#ifdef _WIN32
- return ensureForwardSlashes(_getcwd(buf, 1024));
+ GetCurrentDirectoryA(1024, buf);
+ return ensureForwardSlashes(buf);
#else
return ::getcwd(buf, 1024);
#endif
}
+#ifdef _WIN32
+/** Returns the absolute path of the current directory of a given drive.
+ * Windows keeps a current directory for every drive, i.e. when accessing a drive
+ * without specifying a path (e.g. with "cd z:"), the current directory of that
+ * drive is used.
+ * @param[in] drive letter of drive to get the current directory from
+ * @return absolute path of the directory */
+string FileSystem::getcwd (char drive) {
+ string cwd = getcwd();
+ if (cwd.length() > 1 && cwd[1] == ':' && tolower(cwd[0]) != tolower(drive)) {
+ chdir(string(1, drive)+":");
+ string cwd2 = cwd;
+ cwd = getcwd();
+ chdir(string(1, cwd2[0])+":");
+ }
+ return cwd;
+}
+#endif
+
+
/** Changes the work directory.
* @param[in] dir path to new work directory
* @return true on success */