mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
Replace all calls to stat by gnupg_stat.
* common/sysutils.c (gnupg_stat): New.
* common/sysutils.h: Include sys/stat.h.
--
Yet another wrapper for Unicode support on Windows.
GnuPG-bug-id: 5098
Signed-off-by: Werner Koch <wk@gnupg.org>
Backported-from-master: 18e5dd7b03
)
This commit is contained in:
parent
86e52e3c33
commit
157030271f
20 changed files with 77 additions and 28 deletions
|
@ -78,7 +78,7 @@ gnupg_amkdir_p (const char **directory_components)
|
|||
|
||||
/* log_debug ("%s: stat(%s)\n", __func__, dirs[i]); */
|
||||
|
||||
if (!stat (dirs[i], &s))
|
||||
if (!gnupg_stat (dirs[i], &s))
|
||||
{
|
||||
if ( ! S_ISDIR (s.st_mode))
|
||||
{
|
||||
|
|
|
@ -1107,6 +1107,49 @@ gnupg_access (const char *name, int mode)
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* A wrapper around stat to handle Unicode file names under Windows. */
|
||||
#ifdef HAVE_STAT
|
||||
int
|
||||
gnupg_stat (const char *name, struct stat *statbuf)
|
||||
{
|
||||
# ifdef HAVE_W32_SYSTEM
|
||||
if (any8bitchar (name))
|
||||
{
|
||||
wchar_t *wname;
|
||||
struct _stat32 st32;
|
||||
int ret;
|
||||
|
||||
wname = utf8_to_wchar (name);
|
||||
if (!wname)
|
||||
return -1;
|
||||
ret = _wstat (wname, &st32);
|
||||
xfree (wname);
|
||||
if (!ret)
|
||||
{
|
||||
statbuf->st_dev = st32.st_dev;
|
||||
statbuf->st_ino = st32.st_ino;
|
||||
statbuf->st_mode = st32.st_mode;
|
||||
statbuf->st_nlink = st32.st_nlink;
|
||||
statbuf->st_uid = st32.st_uid;
|
||||
statbuf->st_gid = st32.st_gid;
|
||||
statbuf->st_rdev = st32.st_rdev;
|
||||
statbuf->st_size = st32.st_size;
|
||||
statbuf->st_atime = st32.st_atime;
|
||||
statbuf->st_mtime = st32.st_mtime;
|
||||
statbuf->st_ctime = st32.st_ctime;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
return stat (name, statbuf);
|
||||
# else
|
||||
return stat (name, statbuf);
|
||||
# endif
|
||||
}
|
||||
#endif /*HAVE_STAT*/
|
||||
|
||||
|
||||
/* A wrapper around open to handle Unicode file names under Windows. */
|
||||
int
|
||||
gnupg_open (const char *name, int flags, unsigned int mode)
|
||||
|
|
|
@ -46,6 +46,9 @@ typedef int gnupg_fd_t;
|
|||
#define FD2INT(h) (h)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STAT
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
void trap_unaligned (void);
|
||||
int disable_core_dumps (void);
|
||||
|
@ -73,6 +76,9 @@ int gnupg_setenv (const char *name, const char *value, int overwrite);
|
|||
int gnupg_unsetenv (const char *name);
|
||||
char *gnupg_getcwd (void);
|
||||
gpg_err_code_t gnupg_access (const char *name, int mode);
|
||||
#ifdef HAVE_STAT
|
||||
int gnupg_stat (const char *name, struct stat *statbuf);
|
||||
#endif /*HAVE_STAT*/
|
||||
int gnupg_open (const char *name, int flags, unsigned int mode);
|
||||
char *gnupg_get_socket_name (int fd);
|
||||
int gnupg_fd_valid (int fd);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue