diff --git a/libc/src/__support/File/file.h b/libc/src/__support/File/file.h --- a/libc/src/__support/File/file.h +++ b/libc/src/__support/File/file.h @@ -21,6 +21,8 @@ // suitable for their platform. class File { public: + static constexpr size_t DEFAULT_BUFFER_SIZE = 1024; + using LockFunc = void(File *); using UnlockFunc = void(File *); @@ -41,6 +43,7 @@ READ = 0x1, WRITE = 0x2, APPEND = 0x4, + PLUS = 0x8, }; // Denotes a file opened in binary mode (which is specified by including @@ -97,11 +100,13 @@ protected: bool write_allowed() const { return mode & (static_cast(OpenMode::WRITE) | - static_cast(OpenMode::APPEND)); + static_cast(OpenMode::APPEND) | + static_cast(OpenMode::PLUS)); } bool read_allowed() const { - return mode & static_cast(OpenMode::READ); + return mode & (static_cast(OpenMode::READ) | + static_cast(OpenMode::PLUS)); } public: @@ -185,6 +190,10 @@ FileLock(FileLock &&) = delete; }; +// The implementaiton of this function is provided by the platfrom_file +// library. +File *openfile(const char *path, const char *mode); + } // namespace __llvm_libc #endif // LLVM_LIBC_SRC_SUPPORT_OSUTIL_FILE_H diff --git a/libc/src/__support/File/file.cpp b/libc/src/__support/File/file.cpp --- a/libc/src/__support/File/file.cpp +++ b/libc/src/__support/File/file.cpp @@ -215,8 +215,7 @@ ++main_mode_count; break; case '+': - flags |= (static_cast(OpenMode::WRITE) | - static_cast(OpenMode::READ)); + flags |= static_cast(OpenMode::PLUS); break; case 'b': flags |= static_cast(ContentType::BINARY);