1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

common: New functions gnupg_opendir et al.

* common/sysutils.h (struct gnupg_dirent_s): New.
* common/sysutils.c: Include dirent.h.
(struct gnupg_dir_s): New.
(gnupg_opendir, gnupg_readdir, gnupg_closedir): New.  Change all
callers of opendir, readdir, and closedir to use these functions.
--

GnuPG-bug-id: 5098
This commit is contained in:
Werner Koch 2020-10-21 16:59:38 +02:00
parent 9a0197b6fe
commit 7e22e08e2a
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
9 changed files with 217 additions and 43 deletions

View file

@ -1701,8 +1701,8 @@ expire_old_states (void)
{
gpg_error_t err = 0;
const char *dirname;
DIR *dir = NULL;
struct dirent *dir_entry;
gnupg_dir_t dir = NULL;
gnupg_dirent_t dir_entry;
char *fname = NULL;
estream_t fp = NULL;
nvc_t nvc = NULL;
@ -1712,14 +1712,14 @@ expire_old_states (void)
unsigned long now = gnupg_get_time ();
dirname = get_pairing_statedir ();
dir = opendir (dirname);
dir = gnupg_opendir (dirname);
if (!dir)
{
err = gpg_error_from_syserror ();
goto leave;
}
while ((dir_entry = readdir (dir)))
while ((dir_entry = gnupg_readdir (dir)))
{
if (strlen (dir_entry->d_name) != 16+4
|| strcmp (dir_entry->d_name + 16, ".pa1"))
@ -1781,8 +1781,7 @@ expire_old_states (void)
if (err)
log_error ("expiring old states in '%s' failed: %s\n",
dirname, gpg_strerror (err));
if (dir)
closedir (dir);
gnupg_closedir (dir);
es_fclose (fp);
xfree (fname);
}