summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorSiep Kroonenberg <siepo@cybercomm.nl>2022-01-08 21:20:29 +0000
committerSiep Kroonenberg <siepo@cybercomm.nl>2022-01-08 21:20:29 +0000
commitec5f4af9bdabc124bbe09abfefdb38c50f2aa823 (patch)
treeccc36020161585a5b69631de58d896352ded6506 /Build
parentbedc9a5694f7c40a2645919601638d2dbef4145b (diff)
Slightly modified patch for dvisvgm from Naveen for gcc 11
git-svn-id: svn://tug.org/texlive/trunk@61533 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-src/src/FileSystem.cpp28
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-src/src/FileSystem.hpp3
2 files changed, 28 insertions, 3 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/FileSystem.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/FileSystem.cpp
index 476c0c8e58e..92960138e71 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-src/src/FileSystem.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/FileSystem.cpp
@@ -34,8 +34,6 @@
#endif
-using namespace std;
-
#ifdef _WIN32
#include <direct.h>
#include "windows.hpp"
@@ -52,6 +50,8 @@ using namespace std;
#endif
+using namespace std;
+
string FileSystem::TMPDIR;
FileSystem::TemporaryDirectory FileSystem::_tmpdir;
@@ -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 */
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/FileSystem.hpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/FileSystem.hpp
index ad0e70f9737..0c13f178e96 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-src/src/FileSystem.hpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/FileSystem.hpp
@@ -48,6 +48,9 @@ class FileSystem {
static uint64_t filesize (const std::string &fname);
static std::string ensureForwardSlashes (std::string path);
static std::string getcwd ();
+#ifdef _WIN32
+ static std::string getcwd (char drive);
+#endif
static std::string tmpdir ();
static bool chdir (const std::string &dir);
static bool exists (const std::string &fname);