mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-22 19:24:13 +00:00
[libc][NFC] Add a separate flag for capturing the '+' in fopen mode string.
Having a separate flag helps in setting up proper flags when implementing, say the Linux specialization of File. Along the way, a signature for a function which is to be used to open files has been added. The implementation of the function is to be included in platform specializations. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D121889
This commit is contained in:
parent
295172ef51
commit
29a631a273
@ -215,8 +215,7 @@ File::ModeFlags File::mode_flags(const char *mode) {
|
||||
++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);
|
||||
|
@ -21,6 +21,8 @@ namespace __llvm_libc {
|
||||
// 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 @@ public:
|
||||
READ = 0x1,
|
||||
WRITE = 0x2,
|
||||
APPEND = 0x4,
|
||||
PLUS = 0x8,
|
||||
};
|
||||
|
||||
// Denotes a file opened in binary mode (which is specified by including
|
||||
@ -97,11 +100,13 @@ private:
|
||||
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:
|
||||
@ -185,6 +190,10 @@ 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user