1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
From: YOKOTA Hiroshi <yokota.hgml@gmail.com>
Date: Wed, 15 Sep 2021 00:02:36 +0900
Subject: Use getcwd(3) POSIX extension to avoid PATH_MAX macro
Forwarded: https://sourceforge.net/p/sevenzip/patches/369/
This fix helps GNU Hurd.
---
CPP/Windows/FileDir.cpp | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/CPP/Windows/FileDir.cpp b/CPP/Windows/FileDir.cpp
index 4a4bf52..e1747fc 100644
--- a/CPP/Windows/FileDir.cpp
+++ b/CPP/Windows/FileDir.cpp
@@ -1141,22 +1141,11 @@ bool GetCurrentDir(FString &path)
{
path.Empty();
- #define MY_PATH_MAX PATH_MAX
- // #define MY_PATH_MAX 1024
-
- char s[MY_PATH_MAX + 1];
- char *res = getcwd(s, MY_PATH_MAX);
- if (res)
- {
- path = fas2fs(s);
- return true;
- }
{
- // if (errno != ERANGE) return false;
#if defined(__GLIBC__) || defined(__APPLE__)
/* As an extension to the POSIX.1-2001 standard, glibc's getcwd()
allocates the buffer dynamically using malloc(3) if buf is NULL. */
- res = getcwd(NULL, 0);
+ char *res = getcwd(NULL, 0);
if (res)
{
path = fas2fs(res);
|