summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pacman/package.c5
-rw-r--r--src/pacman/util.c6
-rw-r--r--src/util/testdb.c8
3 files changed, 7 insertions, 12 deletions
diff --git a/src/pacman/package.c b/src/pacman/package.c
index 1698806f..06800378 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -22,8 +22,8 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#include <limits.h>
-#include <sys/stat.h>
#include <wchar.h>
#include <alpm.h>
@@ -176,7 +176,6 @@ void dump_pkg_backups(pmpkg_t *pkg)
if(alpm_pkg_get_backup(pkg)) {
/* package has backup files, so print them */
for(i = alpm_pkg_get_backup(pkg); i; i = alpm_list_next(i)) {
- struct stat buf;
char path[PATH_MAX];
char *str = strdup(alpm_list_getdata(i));
char *ptr = index(str, '\t');
@@ -188,7 +187,7 @@ void dump_pkg_backups(pmpkg_t *pkg)
ptr++;
snprintf(path, PATH_MAX-1, "%s%s", root, str);
/* if we find the file, calculate checksums, otherwise it is missing */
- if(!stat(path, &buf)) {
+ if(access(path, R_OK) == 0) {
char *md5sum = alpm_get_md5sum(path);
if(md5sum == NULL) {
diff --git a/src/pacman/util.c b/src/pacman/util.c
index e702886b..d7ac9e38 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -22,7 +22,6 @@
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/time.h>
-#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
@@ -125,7 +124,7 @@ int makepath(const char *path)
* orig - a copy of path so we can safely butcher it with strsep
* str - the current position in the path string (after the delimiter)
* ptr - the original position of str after calling strsep
- * incr - incrementally generated path for use in stat/mkdir call
+ * incr - incrementally generated path for use in access/mkdir call
*/
char *orig, *str, *ptr, *incr;
mode_t oldmask = umask(0000);
@@ -136,12 +135,11 @@ int makepath(const char *path)
str = orig;
while((ptr = strsep(&str, "/"))) {
if(strlen(ptr)) {
- struct stat buf;
/* we have another path component- append the newest component to
* existing string and create one more level of dir structure */
strcat(incr, "/");
strcat(incr, ptr);
- if(stat(incr, &buf)) {
+ if(access(incr, F_OK)) {
if(mkdir(incr, 0755)) {
ret = 1;
break;
diff --git a/src/util/testdb.c b/src/util/testdb.c
index f354ecab..87bfcf96 100644
--- a/src/util/testdb.c
+++ b/src/util/testdb.c
@@ -23,7 +23,6 @@
#include <errno.h>
#include <limits.h>
#include <string.h>
-#include <sys/stat.h>
#include <dirent.h>
#include <libgen.h>
@@ -61,7 +60,6 @@ static int db_test(char *dbpath)
{
struct dirent *ent;
char path[PATH_MAX];
- struct stat buf;
int ret = 0;
DIR *dir;
@@ -77,17 +75,17 @@ static int db_test(char *dbpath)
}
/* check for desc, depends, and files */
snprintf(path, PATH_MAX, "%s/%s/desc", dbpath, ent->d_name);
- if(stat(path, &buf)) {
+ if(access(path, F_OK)) {
printf("%s: description file is missing\n", ent->d_name);
ret++;
}
snprintf(path, PATH_MAX, "%s/%s/depends", dbpath, ent->d_name);
- if(stat(path, &buf)) {
+ if(access(path, F_OK)) {
printf("%s: dependency file is missing\n", ent->d_name);
ret++;
}
snprintf(path, PATH_MAX, "%s/%s/files", dbpath, ent->d_name);
- if(stat(path, &buf)) {
+ if(access(path, F_OK)) {
printf("%s: file list is missing\n", ent->d_name);
ret++;
}