X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=fd.c;h=7079b51cc95c683af1187f0b4af1412b07e40950;hp=dc4fd59c93320929bd7e7f781a37f3e903a13c8f;hb=a35c113e0bb9fa9ac02b77eb01dd32f49cd5c8d0;hpb=10a62b85c43319d9cdefd7d04823aaed47b3817e diff --git a/fd.c b/fd.c index dc4fd59c..7079b51c 100644 --- a/fd.c +++ b/fd.c @@ -1,8 +1,4 @@ -/* - * Copyright (C) 2006 Andre Noll - * - * Licensed under the GPL v2. For licencing details see COPYING. - */ +/* Copyright (C) 2006 Andre Noll , see file COPYING. */ /** \file fd.c Helper functions for file descriptor handling. */ @@ -320,9 +316,9 @@ out: * * \param fn The file name. * - * \return Non-zero iff file exists. + * \return True iff file exists. */ -int file_exists(const char *fn) +bool file_exists(const char *fn) { struct stat statbuf; @@ -573,20 +569,6 @@ close_cwd: return ret; } -/** - * A wrapper for fchdir(). - * - * \param fd An open file descriptor. - * - * \return Standard. - */ -static int para_fchdir(int fd) -{ - if (fchdir(fd) < 0) - return -ERRNO_TO_PARA_ERROR(errno); - return 1; -} - /** * A wrapper for mkdir(2). * @@ -749,7 +731,7 @@ int for_each_file_in_dir(const char *dirname, { DIR *dir; struct dirent *entry; - int cwd_fd, ret2, ret = para_opendir(dirname, &dir, &cwd_fd); + int cwd_fd, ret = para_opendir(dirname, &dir, &cwd_fd); if (ret < 0) return ret == -ERRNO_TO_PARA_ERROR(EACCES)? 1 : ret; @@ -785,9 +767,8 @@ int for_each_file_in_dir(const char *dirname, ret = 1; out: closedir(dir); - ret2 = para_fchdir(cwd_fd); - if (ret2 < 0 && ret >= 0) - ret = ret2; + if (fchdir(cwd_fd) < 0 && ret >= 0) + ret = -ERRNO_TO_PARA_ERROR(errno); close(cwd_fd); return ret; }