summaryrefslogtreecommitdiffstats
path: root/common/sysutils.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 21:21:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 21:21:03 +0000
commit3675f65888fde5fddde20ff811638a338bf08ca6 (patch)
tree065688bbb6355a8a4784ec9c8e112cec342eac5e /common/sysutils.c
parentAdding upstream version 2.2.40. (diff)
downloadgnupg2-upstream.tar.xz
gnupg2-upstream.zip
Adding upstream version 2.2.43.upstream/2.2.43upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--common/sysutils.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/common/sysutils.c b/common/sysutils.c
index 5f54ae1..0cd5f49 100644
--- a/common/sysutils.c
+++ b/common/sysutils.c
@@ -244,6 +244,9 @@ map_w32_to_errno (DWORD w32_err)
case ERROR_ALREADY_EXISTS:
return EEXIST;
+ case ERROR_FILE_INVALID:
+ return EIO;
+
/* This mapping has been taken from reactOS. */
case ERROR_TOO_MANY_OPEN_FILES: return EMFILE;
case ERROR_ARENA_TRASHED: return ENOMEM;
@@ -316,15 +319,17 @@ map_w32_to_errno (DWORD w32_err)
#endif /*HAVE_W32_SYSTEM*/
-/* Set ERRNO from the Windows error. EC may be -1 to use the last error. */
+/* Set ERRNO from the Windows error. EC may be -1 to use the last
+ * error. Returns the Windows error code. */
#ifdef HAVE_W32_SYSTEM
-void
+int
gnupg_w32_set_errno (int ec)
{
/* FIXME: Replace by gpgrt_w32_set_errno. */
if (ec == -1)
ec = GetLastError ();
_set_errno (map_w32_to_errno (ec));
+ return ec;
}
#endif /*HAVE_W32_SYSTEM*/
@@ -809,7 +814,12 @@ gnupg_remove (const char *fname)
return -1;
return 0;
#else
- return remove (fname);
+ /* It is common to use /dev/null for testing. We better don't
+ * remove that file. */
+ if (fname && !strcmp (fname, "/dev/null"))
+ return 0;
+ else
+ return remove (fname);
#endif
}