fileinfo: implement os_fileinfo_size

this replaces os_get_file_size and file_info.stat.st_size
This commit is contained in:
Stefan Hoffmann
2014-08-08 16:25:33 +02:00
parent 3051015f89
commit aa378acdf5
6 changed files with 35 additions and 23 deletions

View File

@@ -258,20 +258,6 @@ int os_file_is_writable(const char *name)
return 0;
}
/// 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)
{
uv_stat_t statbuf;
if (os_stat(name, &statbuf)) {
*size = statbuf.st_size;
return true;
}
return false;
}
/// Rename a file or directory.
///
/// @return `OK` for success, `FAIL` for failure.
@@ -408,6 +394,15 @@ uint64_t os_file_info_get_inode(const FileInfo *file_info)
return file_info->stat.st_ino;
}
/// Get the size of a file from a `FileInfo`.
///
/// @return filesize in bytes.
off_t os_fileinfo_size(const FileInfo *file_info)
FUNC_ATTR_NONNULL_ALL
{
return file_info->stat.st_size;
}
/// Get the `FileID` for a given path
///
/// @param path Path to the file.