1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-07 23:27:48 +02:00

common,w32: Support file names longer than MAX_PATH in iobuf.

* common/iobuf.c (direct_open): Use gpgrt_fname_to_wchar.
(any8bitchar): Remove.
This commit is contained in:
Werner Koch 2022-03-04 14:52:05 +01:00
parent 9116fd1e9a
commit 4122896a39
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -194,18 +194,6 @@ fd_cache_strcmp (const char *a, const char *b)
} }
#ifdef HAVE_W32_SYSTEM
static int
any8bitchar (const char *string)
{
if (string)
for ( ; *string; string++)
if ((*string & 0x80))
return 1;
return 0;
}
#endif /*HAVE_W32_SYSTEM*/
/* /*
* Invalidate (i.e. close) a cached iobuf * Invalidate (i.e. close) a cached iobuf
*/ */
@ -307,11 +295,11 @@ direct_open (const char *fname, const char *mode, int mode700)
sm = FILE_SHARE_READ; sm = FILE_SHARE_READ;
} }
/* We use the Unicode version of the function only if needed to /* We always use the Unicode version because it supports file names
* avoid an extra conversion step. */ * longer than MAX_PATH. (requires gpgrt 1.45) */
if (any8bitchar (fname)) if (1)
{ {
wchar_t *wfname = utf8_to_wchar (fname); wchar_t *wfname = gpgrt_fname_to_wchar (fname);
if (wfname) if (wfname)
{ {
hfile = CreateFileW (wfname, da, sm, NULL, cd, hfile = CreateFileW (wfname, da, sm, NULL, cd,
@ -321,8 +309,6 @@ direct_open (const char *fname, const char *mode, int mode700)
else else
hfile = INVALID_HANDLE_VALUE; hfile = INVALID_HANDLE_VALUE;
} }
else
hfile = CreateFileA (fname, da, sm, NULL, cd, FILE_ATTRIBUTE_NORMAL, NULL);
return hfile; return hfile;