fileio.h (1514B)
1 #pragma once 2 3 #include <stddef.h> // IWYU pragma: keep 4 5 #include "nvim/memory_defs.h" 6 #include "nvim/os/fileio_defs.h" // IWYU pragma: keep 7 8 /// file_open() flags 9 typedef enum { 10 kFileReadOnly = 1, ///< Open file read-only. Default. 11 kFileCreate = 2, ///< Create file if it does not exist yet. 12 ///< Implies kFileWriteOnly. 13 kFileWriteOnly = 4, ///< Open file for writing only. 14 ///< Cannot be used with kFileReadOnly. 15 kFileNoSymlink = 8, ///< Do not allow symbolic links. 16 kFileCreateOnly = 16, ///< Only create the file, failing if it already 17 ///< exists. Implies kFileWriteOnly. Cannot be used 18 ///< with kFileCreate. 19 kFileTruncate = 32, ///< Truncate the file if it exists. 20 ///< Implies kFileWriteOnly. Cannot be used with 21 ///< kFileCreateOnly. 22 kFileAppend = 64, ///< Append to the file. Implies kFileWriteOnly. Cannot 23 ///< be used with kFileCreateOnly. 24 kFileNonBlocking = 128, ///< Do not restart read() or write() syscall if 25 ///< EAGAIN was encountered. 26 kFileMkDir = 256, 27 } FileOpenFlags; 28 29 enum { 30 /// Read or write buffer size 31 /// 32 /// Currently equal to (IOSIZE - 1), but they do not need to be connected. 33 kRWBufferSize = 1024, 34 }; 35 36 static inline size_t file_space(FileDescriptor *fp) 37 { 38 return (size_t)((fp->buffer + ARENA_BLOCK_SIZE) - fp->write_pos); 39 } 40 41 #include "os/fileio.h.generated.h"