mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
Replace all calls to access by gnupg_access
* common/sysutils.c (gnupg_access): New. Replace all calls to access by this wrapper. * common/homedir.c (w32_shgetfolderpath): Change to return UTF-8 directory name. (standard_homedir): Adjust for change. (w32_commondir, gnupg_cachedir): Ditto. -- Also use SHGetFolderPathW instead of SHGetFolderPathA on Windows. This is required to correctly handle non-ascii filenames on Windows. GnuPG-bug-id: 5098
This commit is contained in:
parent
228836f79f
commit
c94ee1386e
28 changed files with 151 additions and 128 deletions
|
@ -811,7 +811,7 @@ gnupg_mkdir (const char *name, const char *modestr)
|
|||
int
|
||||
gnupg_chdir (const char *name)
|
||||
{
|
||||
/* Note that gpgrt_chdir also sets ERRNO in addition to returing an
|
||||
/* Note that gpgrt_chdir also sets ERRNO in addition to returning an
|
||||
* gpg-error style error code. */
|
||||
return gpgrt_chdir (name);
|
||||
}
|
||||
|
@ -1033,30 +1033,37 @@ gnupg_unsetenv (const char *name)
|
|||
|
||||
|
||||
/* Return the current working directory as a malloced string. Return
|
||||
NULL and sets ERRNo on error. */
|
||||
NULL and sets ERRNO on error. */
|
||||
char *
|
||||
gnupg_getcwd (void)
|
||||
{
|
||||
char *buffer;
|
||||
size_t size = 100;
|
||||
return gpgrt_getcwd ();
|
||||
}
|
||||
|
||||
for (;;)
|
||||
|
||||
/* A simple wrapper around access. NAME is expected to be utf8
|
||||
* encoded. This function returns an error code and sets ERRNO. */
|
||||
gpg_err_code_t
|
||||
gnupg_access (const char *name, int mode)
|
||||
{
|
||||
#if GPGRT_VERSION_NUMBER < 0x012800 /* 1.39 */
|
||||
# ifdef HAVE_W32_SYSTEM
|
||||
wchar_t *wfname;
|
||||
|
||||
wfname = utf8_to_wchar (fname);
|
||||
if (!wfname)
|
||||
ec = gpg_err_code_from_syserror ();
|
||||
else
|
||||
{
|
||||
buffer = xtrymalloc (size+1);
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
strcpy (buffer, "/"); /* Always "/". */
|
||||
return buffer;
|
||||
#else
|
||||
if (getcwd (buffer, size) == buffer)
|
||||
return buffer;
|
||||
xfree (buffer);
|
||||
if (errno != ERANGE)
|
||||
return NULL;
|
||||
size *= 2;
|
||||
#endif
|
||||
ec = _waccess (wfname, mode)? gpg_err_code_from_syserror () : 0;
|
||||
xfree (wfname);
|
||||
}
|
||||
# else
|
||||
return access (name, mode)? gpg_err_code_from_syserror () : 0;
|
||||
# endif
|
||||
#else
|
||||
return gpgrt_access (name, mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue