X-Git-Url: http://git.tuebingen.mpg.de/?p=osl.git;a=blobdiff_plain;f=fd.h;h=4b802062d7207344ef3441542a3fe090ba18bd67;hp=80f484a4427d8c5042af45e6ad6d4aef5be4f8ed;hb=a88534cd677dcd6cb2847060ec4f39d56e219bf7;hpb=5952112a37ecdaedf3b76e08f97d307f1056c512 diff --git a/fd.h b/fd.h index 80f484a..4b80206 100644 --- a/fd.h +++ b/fd.h @@ -6,11 +6,43 @@ /** \file fd.h exported symbols from fd.c */ -int write_all(int fd, const char *buf, size_t *len); -int para_open(const char *path, int flags, mode_t mode); +int osl_open(const char *path, int flags, mode_t mode); int para_opendir(const char *dirname, DIR **dir, int *cwd); -int para_mkdir(const char *path, mode_t mode); int para_fchdir(int fd); 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); +int osl_munmap(void *start, size_t length); +int write_all(int fd, const char *buf, size_t *len); +int write_file(const char *filename, const void *buf, size_t size); + +/** + * A wrapper for mkdir(2). + * + * \param path Name of the directory to create. + * \param mode The permissions to use. + * + * \return Standard. + */ +static inline int osl_mkdir(const char *path, mode_t mode) +{ + if (!mkdir(path, mode)) + return 1; + return -ERRNO_TO_ERROR(errno); +} + +/** + * A wrapper for rename(2). + * + * \param old_path The source path. + * \param new_path The destination path. + * + * \return Standard. + * + * \sa rename(2). + */ +_static_inline_ int osl_rename(const char *old_path, const char *new_path) +{ + if (rename(old_path, new_path) < 0) + return -ERRNO_TO_ERROR(errno); + return 1; +}