X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=fd.h;h=7fdff916cec60425719772e55bc44027f1d54f86;hb=3c96f3b4f7bb1be1c630085981e83eb0260b99a7;hp=55f1cacb6897c7012aa342eb1130449e3b5e2109;hpb=093138ba762b3179f4d0375bbaf4250b9e016289;p=osl.git diff --git a/fd.h b/fd.h index 55f1cac..7fdff91 100644 --- a/fd.h +++ b/fd.h @@ -11,7 +11,10 @@ int para_opendir(const char *dirname, DIR **dir, int *cwd); 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); +int truncate_file(const char *filename, off_t size); /** * A wrapper for mkdir(2). @@ -28,3 +31,26 @@ static inline int osl_mkdir(const char *path, mode_t mode) 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; +} + +_static_inline_ int osl_stat(const char *path, struct stat *buf) +{ + if (stat(path, buf) >= 0) + return 1; + return -ERRNO_TO_ERROR(errno); +}