aboutsummaryrefslogtreecommitdiff
path: root/src/os/os.h
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2014-05-09 15:33:00 -0400
committerJustin M. Keyes <justinkz@gmail.com>2014-05-09 15:33:00 -0400
commit1a3ee71de258b416ca6b80f0a9e3b91460df8dc7 (patch)
treea59167e50add55b51ed31c65944cfa78ddd1c290 /src/os/os.h
parentf3dda65de157f2d7c35286018c20cbc7597ed748 (diff)
parenteae498c4c5d34c1d0af40ecb430cbbc23b0a8e97 (diff)
downloadrneovim-1a3ee71de258b416ca6b80f0a9e3b91460df8dc7.tar.gz
rneovim-1a3ee71de258b416ca6b80f0a9e3b91460df8dc7.tar.bz2
rneovim-1a3ee71de258b416ca6b80f0a9e3b91460df8dc7.zip
Merge pull request #619 from stefan991/mch_stat-cleanup
Replace `struct stat` with `FileInfo`
Diffstat (limited to 'src/os/os.h')
-rw-r--r--src/os/os.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/os/os.h b/src/os/os.h
index 67cda28348..b30872f06d 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.
@@ -105,4 +111,36 @@ char *os_get_user_directory(const char *name);
/// @return OK on success, FAIL if an failure occured.
int os_stat(const char_u *name, uv_stat_t *statbuf);
+/// Struct which encapsulates stat information.
+typedef struct {
+ // TODO(stefan991): make stat private
+ uv_stat_t stat;
+} FileInfo;
+
+/// Get the file information for a given path
+///
+/// @param file_descriptor File descriptor of the file.
+/// @param[out] file_info Pointer to a FileInfo to put the information in.
+/// @return `true` on sucess, `false` for failure.
+bool os_get_file_info(const char *path, FileInfo *file_info);
+
+/// Get the file information for a given path without following links
+///
+/// @param path Path to the file.
+/// @param[out] file_info Pointer to a FileInfo to put the information in.
+/// @return `true` on sucess, `false` for failure.
+bool os_get_file_info_link(const char *path, FileInfo *file_info);
+
+/// Get the file information for a given file descriptor
+///
+/// @param file_descriptor File descriptor of the file.
+/// @param[out] file_info Pointer to a FileInfo to put the information in.
+/// @return `true` on sucess, `false` for failure.
+bool os_get_file_info_fd(int file_descriptor, FileInfo *file_info);
+
+/// Compare the inodes of two FileInfos
+///
+/// @return `true` if the two FileInfos represent the same file.
+bool os_file_info_id_equal(FileInfo *file_info_1, FileInfo *file_info_2);
+
#endif // NEOVIM_OS_OS_H