Another public trivial wrapper that can go away because it has only
a single caller. POSIX says
Upon successful completion, 0 shall be returned. Otherwise, −1 shall
be returned, the current working directory shall remain unchanged,
and errno shall be set to indicate the error.
So the new check against zero is equivalent to the old code which
checked whether the return value is non-negative.
return -ERRNO_TO_PARA_ERROR(errno);
}
-/**
- * Wrapper for chdir(2).
- *
- * \param path The specified directory.
- *
- * \return Standard.
- */
-int para_chdir(const char *path)
-{
- int ret = chdir(path);
-
- if (ret >= 0)
- return 1;
- return -ERRNO_TO_PARA_ERROR(errno);
-}
-
/**
* Save the cwd and open a given directory.
*
return ret;
*cwd = ret;
}
- ret = para_chdir(dirname);
- if (ret < 0)
+ if (chdir(dirname) != 0) {
+ ret = -ERRNO_TO_PARA_ERROR(errno);
goto close_cwd;
+ }
*dir = opendir(".");
if (*dir)
return 1;
int para_mmap(size_t length, int prot, int flags, int fd, void *map);
int para_open(const char *path, int flags, mode_t mode);
int para_mkdir(const char *path, mode_t mode);
-int para_chdir(const char *path);
int mmap_full_file(const char *filename, int open_mode, void **map,
size_t *size, int *fd_ptr);
int para_munmap(void *start, size_t length);