diff options
author | ZyX <kp-pav@yandex.ru> | 2016-06-21 22:18:03 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2016-06-23 21:17:51 +0300 |
commit | a8f3849bc04cee5d7166138a28cb1e7bbf300803 (patch) | |
tree | 640f647982f1745bf5b26d19e5896a92f00b87a7 /src/nvim/file.h | |
parent | 2ac5f1138b5c4c5540479e26ca9b9755cf7b784d (diff) | |
download | rneovim-a8f3849bc04cee5d7166138a28cb1e7bbf300803.tar.gz rneovim-a8f3849bc04cee5d7166138a28cb1e7bbf300803.tar.bz2 rneovim-a8f3849bc04cee5d7166138a28cb1e7bbf300803.zip |
file: Use own constants, do not rely on fcntl.h
One of the reasons is that O_RDONLY is zero, which makes checking whether file
is opened read- or write-only harder. It is not guaranteed that on other system
O_WRONLY will not be zero (e.g. because file can only be opened in read-write
mode).
Diffstat (limited to 'src/nvim/file.h')
-rw-r--r-- | src/nvim/file.h | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/nvim/file.h b/src/nvim/file.h index c6def673c2..5ee572750d 100644 --- a/src/nvim/file.h +++ b/src/nvim/file.h @@ -3,7 +3,6 @@ #include <stdbool.h> #include <stddef.h> -#include <fcntl.h> #include "nvim/func_attr.h" #include "nvim/rbuffer.h" @@ -19,17 +18,18 @@ typedef struct { /// file_open() flags typedef enum { - FILE_READ_ONLY = O_RDONLY, ///< Open file read-only. - FILE_CREATE = O_CREAT, ///< Create file if it does not exist yet. - FILE_WRITE_ONLY = O_WRONLY, ///< Open file for writing only. -#ifdef O_NOFOLLOW - FILE_NOSYMLINK = O_NOFOLLOW, ///< Do not allow symbolic links. -#else - FILE_NOSYMLINK = 0, -#endif - FILE_CREATE_ONLY = O_CREAT|O_EXCL, ///< Only create the file, failing - ///< if it already exists. - FILE_TRUNCATE = O_TRUNC, ///< Truncate the file if it exists. + kFileReadOnly = 1, ///< Open file read-only. Default. + kFileCreate = 2, ///< Create file if it does not exist yet. + ///< Implies kFileWriteOnly. + kFileWriteOnly = 4, ///< Open file for writing only. + ///< Cannot be used with kFileReadOnly. + kFileNoSymlink = 8, ///< Do not allow symbolic links. + kFileCreateOnly = 16, ///< Only create the file, failing if it already + ///< exists. Implies kFileWriteOnly. Cannot be used + ///< with kFileCreate. + kFileTruncate = 32, ///< Truncate the file if it exists. + ///< Implies kFileWriteOnly. Cannot be used with + ///< kFileCreateOnly. } FileOpenFlags; /// Check whether end of file was encountered |