From da0bd89b5b6a847d51a755909f694c5e89a6d751 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Sun, 22 Oct 2006 18:16:32 +0000 Subject: [PATCH] Use stat instead of access --- src/pad.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pad.c b/src/pad.c index 636b6b5..83891f1 100644 --- a/src/pad.c +++ b/src/pad.c @@ -38,13 +38,14 @@ static FILE *pusb_pad_open_device(t_pusb_options *opts, FILE *f; char path[PATH_MAX]; const char *mnt_point; + struct stat sb; mnt_point = (char *)libhal_volume_get_mount_point(volume); if (!mnt_point) return (NULL); memset(path, 0x00, PATH_MAX); snprintf(path, PATH_MAX, "%s/%s", mnt_point, opts->device_pad_directory); - if (access(path, F_OK) != 0) + if (stat(path, &sb) != 0) { log_debug("Directory %s does not exist, creating one.\n", path); if (mkdir(path, S_IRUSR | S_IWUSR | S_IXUSR) != 0) @@ -73,6 +74,7 @@ static FILE *pusb_pad_open_system(t_pusb_options *opts, FILE *f; char path[PATH_MAX]; struct passwd *user_ent = NULL; + struct stat sb; if (!(user_ent = getpwnam(user)) || !(user_ent->pw_dir)) { @@ -83,7 +85,7 @@ static FILE *pusb_pad_open_system(t_pusb_options *opts, memset(path, 0x00, PATH_MAX); snprintf(path, PATH_MAX, "%s/%s", user_ent->pw_dir, opts->system_pad_directory); - if (access(path, F_OK) != 0) + if (stat(path, &sb) != 0) { log_debug("Directory %s does not exist, creating one.\n", path); if (mkdir(path, S_IRUSR | S_IWUSR | S_IXUSR) != 0)