summaryrefslogtreecommitdiff
path: root/Build/source/libs/xpdf/xpdf-src/goo
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/xpdf/xpdf-src/goo')
-rw-r--r--Build/source/libs/xpdf/xpdf-src/goo/CMakeLists.txt2
-rw-r--r--Build/source/libs/xpdf/xpdf-src/goo/gfile.cc48
-rw-r--r--Build/source/libs/xpdf/xpdf-src/goo/gfile.h17
3 files changed, 55 insertions, 12 deletions
diff --git a/Build/source/libs/xpdf/xpdf-src/goo/CMakeLists.txt b/Build/source/libs/xpdf/xpdf-src/goo/CMakeLists.txt
index 0a1c56b0ebd..f3f6932eaed 100644
--- a/Build/source/libs/xpdf/xpdf-src/goo/CMakeLists.txt
+++ b/Build/source/libs/xpdf/xpdf-src/goo/CMakeLists.txt
@@ -22,6 +22,8 @@ add_library(goo_objs OBJECT
parseargs.c
Trace.cc
)
+set_property(TARGET goo_objs
+ PROPERTY POSITION_INDEPENDENT_CODE True)
add_library(goo
$<TARGET_OBJECTS:goo_objs>
diff --git a/Build/source/libs/xpdf/xpdf-src/goo/gfile.cc b/Build/source/libs/xpdf/xpdf-src/goo/gfile.cc
index 570f4e7ab13..c2e7512e188 100644
--- a/Build/source/libs/xpdf/xpdf-src/goo/gfile.cc
+++ b/Build/source/libs/xpdf/xpdf-src/goo/gfile.cc
@@ -54,16 +54,23 @@ GString *getHomeDir() {
//---------- VMS ----------
return new GString("SYS$LOGIN:");
-#elif defined(__EMX__) || defined(_WIN32)
- //---------- OS/2+EMX and Win32 ----------
+#elif defined(_WIN32)
+ //---------- Win32 ----------
char *s;
GString *ret;
-#ifdef _WIN32
if ((s = getenv("USERPROFILE")))
-#else
+ ret = new GString(s);
+ else
+ ret = new GString(".");
+ return ret;
+
+#elif defined(__EMX__)
+ //---------- OS/2+EMX ----------
+ char *s;
+ GString *ret;
+
if ((s = getenv("HOME")))
-#endif
ret = new GString(s);
else
ret = new GString(".");
@@ -335,11 +342,11 @@ GString *makePathAbsolute(GString *path) {
#elif defined(_WIN32)
//---------- Win32 ----------
- char buf[_MAX_PATH];
+ char buf[MAX_PATH];
char *fp;
buf[0] = '\0';
- if (!GetFullPathNameA(path->getCString(), _MAX_PATH, buf, &fp)) {
+ if (!GetFullPathNameA(path->getCString(), MAX_PATH, buf, &fp)) {
path->clear();
return path;
}
@@ -398,6 +405,19 @@ GString *makePathAbsolute(GString *path) {
#endif
}
+GBool pathIsFile(const char *path) {
+#ifdef _WIN32
+ wchar_t wPath[winMaxLongPath + 1];
+ fileNameToUCS2(path, wPath, winMaxLongPath + 1);
+ DWORD attr = GetFileAttributesW(wPath);
+ return attr != INVALID_FILE_ATTRIBUTES &&
+ !(attr & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE));
+#else
+ struct stat statBuf;
+ return stat(path, &statBuf) == 0 && S_ISREG(statBuf.st_mode);
+#endif
+}
+
time_t getModTime(char *fileName) {
#ifdef _WIN32
//~ should implement this, but it's (currently) only used in xpdf
@@ -613,16 +633,16 @@ FILE *openFile(const char *path, const char *mode) {
#if defined(_WIN32)
return fopen(path, mode);
#if 0
- wchar_t wPath[_MAX_PATH + 1];
+ wchar_t wPath[winMaxLongPath + 1];
wchar_t wMode[8];
int i;
- fileNameToUCS2(path, wPath, sizeof(wPath) / sizeof(wchar_t));
+ fileNameToUCS2(path, wPath, winMaxLongPath + 1);
for (i = 0; mode[i] && i < sizeof(wMode)/sizeof(wchar_t) - 1; ++i) {
wMode[i] = (wchar_t)(mode[i] & 0xff);
}
wMode[i] = (wchar_t)0;
- readWindowsShortcut(wPath, _MAX_PATH + 1);
+ readWindowsShortcut(wPath, winMaxLongPath + 1);
return _wfopen(wPath, wMode);
#endif /* 0 */
#elif defined(VMS)
@@ -663,8 +683,8 @@ void readWindowsShortcut(wchar_t *wPath, size_t wPathSize) {
fprintf(stderr, "IPersistFile.Load failed: 0x%08x\n", hres);
exit(1);
}
- wchar_t target[_MAX_PATH + 1];
- hres = shellLink->GetPath(target, _MAX_PATH + 1, NULL, 0);
+ wchar_t target[winMaxLongPath + 1];
+ hres = shellLink->GetPath(target, winMaxLongPath + 1, NULL, 0);
if (FAILED(hres)) {
return;
}
@@ -682,6 +702,10 @@ void readWindowsShortcut(wchar_t *wPath, size_t wPathSize) {
int makeDir(const char *path, int mode) {
#ifdef _WIN32
+ /*
+ wchar_t wPath[winMaxLongPath + 1];
+ return _wmkdir(fileNameToUCS2(path, wPath, winMaxLongPath + 1));
+ */
return _mkdir(path);
#else
return mkdir(path, (mode_t)mode);
diff --git a/Build/source/libs/xpdf/xpdf-src/goo/gfile.h b/Build/source/libs/xpdf/xpdf-src/goo/gfile.h
index 2075d731a6c..d0d2ad6f9e1 100644
--- a/Build/source/libs/xpdf/xpdf-src/goo/gfile.h
+++ b/Build/source/libs/xpdf/xpdf-src/goo/gfile.h
@@ -30,6 +30,12 @@
#endif
#include "gtypes.h"
+// Windows 10 supports long paths - with a registry setting, and only
+// with Unicode (...W) functions.
+#ifdef _WIN32
+# define winMaxLongPath 32767
+#endif
+
class GString;
//------------------------------------------------------------------------
@@ -55,6 +61,9 @@ extern GBool isAbsolutePath(char *path);
// relative) or prepending user's directory (if path starts with '~').
extern GString *makePathAbsolute(GString *path);
+// Returns true if [path] exists and is a regular file.
+extern GBool pathIsFile(const char *path);
+
// Get the modification time for <fileName>. Returns 0 if there is an
// error.
extern time_t getModTime(char *fileName);
@@ -91,6 +100,14 @@ extern wchar_t *fileNameToUCS2(const char *path, wchar_t *out, size_t outSize);
// UCS-2 and calls _wfopen(). On other OSes, this simply calls fopen().
extern FILE *openFile(const char *path, const char *mode);
+#if 0
+#ifdef _WIN32
+// If [wPath] is a Windows shortcut (.lnk file), read the target path
+// and store it back into [wPath].
+extern void readWindowsShortcut(wchar_t *wPath, size_t wPathSize);
+#endif
+#endif /* 0 */
+
// Create a directory. On Windows, this converts the path from UTF-8
// to UCS-2 and calls _wmkdir(), ignoring the mode argument. On other
// OSes, this simply calls mkdir().