[libc-commits] [PATCH] D121889: [libc][NFC] Add a separate flag for capturing the '+' in fopen mode string.
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Thu Mar 17 08:44:21 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG29a631a273d7: [libc][NFC] Add a separate flag for capturing the '+' in fopen mode string. (authored by sivachandra).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121889/new/
https://reviews.llvm.org/D121889
Files:
libc/src/__support/File/file.cpp
libc/src/__support/File/file.h
Index: libc/src/__support/File/file.h
===================================================================
--- libc/src/__support/File/file.h
+++ 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<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 @@
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
Index: libc/src/__support/File/file.cpp
===================================================================
--- libc/src/__support/File/file.cpp
+++ libc/src/__support/File/file.cpp
@@ -215,8 +215,7 @@
++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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121889.416191.patch
Type: text/x-patch
Size: 1901 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20220317/e4ee5241/attachment.bin>
More information about the libc-commits
mailing list