diff options
author | Bruno Haible <bruno@clisp.org> | 2023-04-20 23:21:42 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2023-04-20 23:21:42 +0200 |
commit | dd0a48f50a97ca1185c957b0846e715be7777bcb (patch) | |
tree | 196f96c02a3f149e31223a3146aeab16dc428ebd /lib | |
parent | 876ad6af66851d4e25bb8475e1cd1ec46680b703 (diff) | |
download | gnulib-dd0a48f50a97ca1185c957b0846e715be7777bcb.tar.gz |
getumask: Make it work on native Windows.
* lib/getumask.c (getumask): When TMPDIR is unset, try TMP and TEMP.
* tests/test-getumask.c (ASSUME_UMASK_CONSTANT): Define to 1 on native
Windows.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/getumask.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/getumask.c b/lib/getumask.c index 203d6dc869..e979f9b874 100644 --- a/lib/getumask.c +++ b/lib/getumask.c @@ -106,6 +106,16 @@ getumask (void) { /* Create a temporary file and inspect its access permissions. */ const char *tmpdir = getenv ("TMPDIR"); +# if defined _WIN32 && !defined __CYGWIN__ + if (tmpdir == NULL || *tmpdir == '\0') + { + /* On native Windows, TMPDIR is typically not set, and /tmp does not + exist. $TMP and $TEMP can be used instead. */ + tmpdir = getenv ("TMP"); + if (tmpdir == NULL || *tmpdir == '\0') + tmpdir = getenv ("TEMP"); + } +# endif if (tmpdir == NULL || *tmpdir == '\0') tmpdir = "/tmp"; size_t tmpdir_length = strlen (tmpdir); |