++main_mode_count;
break;
case '+':
- flags |= (static_cast<ModeFlags>(OpenMode::WRITE) |
- static_cast<ModeFlags>(OpenMode::READ));
+ flags |= static_cast<ModeFlags>(OpenMode::PLUS);
break;
case 'b':
flags |= static_cast<ModeFlags>(ContentType::BINARY);
// suitable for their platform.
class File {
public:
+ static constexpr size_t DEFAULT_BUFFER_SIZE = 1024;
+
using LockFunc = void(File *);
using UnlockFunc = void(File *);
READ = 0x1,
WRITE = 0x2,
APPEND = 0x4,
+ PLUS = 0x8,
};
// Denotes a file opened in binary mode (which is specified by including
protected:
bool write_allowed() const {
return mode & (static_cast<ModeFlags>(OpenMode::WRITE) |
- static_cast<ModeFlags>(OpenMode::APPEND));
+ static_cast<ModeFlags>(OpenMode::APPEND) |
+ static_cast<ModeFlags>(OpenMode::PLUS));
}
bool read_allowed() const {
- return mode & static_cast<ModeFlags>(OpenMode::READ);
+ return mode & (static_cast<ModeFlags>(OpenMode::READ) |
+ static_cast<ModeFlags>(OpenMode::PLUS));
}
public:
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