diff options
author | Stefan Hoffmann <stefan991@gmail.com> | 2014-04-25 18:46:50 +0200 |
---|---|---|
committer | Stefan Hoffmann <stefan991@gmail.com> | 2014-05-09 15:49:33 +0200 |
commit | 9784dabb505f736907c17a92885756e4175bd513 (patch) | |
tree | 980892c6a206e03ecfd35d29eca650535dcf72cb /src/os | |
parent | d936bb82ad1833ce3b5170ee89fb6cd9f4b749d7 (diff) | |
download | rneovim-9784dabb505f736907c17a92885756e4175bd513.tar.gz rneovim-9784dabb505f736907c17a92885756e4175bd513.tar.bz2 rneovim-9784dabb505f736907c17a92885756e4175bd513.zip |
implemented os_file_get_size()
Diffstat (limited to 'src/os')
-rw-r--r-- | src/os/fs.c | 10 | ||||
-rw-r--r-- | src/os/os.h | 6 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/os/fs.c b/src/os/fs.c index e03d06669d..c245890873 100644 --- a/src/os/fs.c +++ b/src/os/fs.c @@ -189,6 +189,16 @@ int os_file_is_writable(const char *name) return 0; } +bool os_get_file_size(const char *name, off_t *size) +{ + uv_stat_t statbuf; + if (os_stat((char_u *)name, &statbuf) == OK) { + *size = statbuf.st_size; + return true; + } + return false; +} + int os_rename(const char_u *path, const char_u *new_path) { uv_fs_t request; diff --git a/src/os/os.h b/src/os/os.h index 67cda28348..6fa7fbc7ae 100644 --- a/src/os/os.h +++ b/src/os/os.h @@ -58,6 +58,12 @@ bool os_file_is_readonly(const char *name); /// @return `2` for a directory which we have rights to write into. int os_file_is_writable(const char *name); +/// Get the size of a file in bytes. +/// +/// @param[out] size pointer to an off_t to put the size into. +/// @return `true` for success, `false` for failure. +bool os_get_file_size(const char *name, off_t *size); + /// Rename a file or directory. /// /// @return `OK` for success, `FAIL` for failure. |