diff options
author | Chris Lattner <sabre@nondot.org> | 2009-08-23 02:51:22 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-08-23 02:51:22 +0000 |
commit | 17e9edc4a7bbeadf756494cf39fcacc9eff72202 (patch) | |
tree | 9aace188da0c44dfbbedde8b592702b9dcbc2cc0 /include | |
parent | 1d7fb4eae53c7ec5f9c5c18d603b50dfb9425862 (diff) | |
download | llvm-17e9edc4a7bbeadf756494cf39fcacc9eff72202.tar.gz llvm-17e9edc4a7bbeadf756494cf39fcacc9eff72202.tar.bz2 llvm-17e9edc4a7bbeadf756494cf39fcacc9eff72202.tar.xz |
Change raw_fd_ostream to take flags as an optional bitmask
instead of as two bools. Use this to add a F_Append flag
which has the obvious behavior.
Other unrelated changes conflated into this patch:
1. REmove EH stuff from llvm-dis and llvm-as, the try blocks
are dead.
2. Simplify the filename inference code in llvm-as/llvm-dis,
because raw_fd_ostream does the right thing with '-'.
3. Switch machine verifier to use raw_ostream instead of ostream
(Which is the thing that needed append in the first place).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79807 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Support/raw_ostream.h | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h index c9a8787429..d9d023cc27 100644 --- a/include/llvm/Support/raw_ostream.h +++ b/include/llvm/Support/raw_ostream.h @@ -334,19 +334,32 @@ class raw_fd_ostream : public raw_ostream { virtual size_t preferred_buffer_size(); public: - /// raw_fd_ostream - Open the specified file for writing. If an - /// error occurs, information about the error is put into ErrorInfo, - /// and the stream should be immediately destroyed; the string will - /// be empty if no error occurred. + + enum { + /// F_Force - When opening a file, this flag makes raw_fd_ostream overwrite + /// a file if it already exists instead of emitting an error. This may not + /// be specified with F_Append. + F_Force = 1, + + /// F_Append - When opening a file, if it already exists append to the + /// existing file instead of returning an error. This may not be specified + /// with F_Force. + F_Append = 2, + + /// F_Binary - The file should be opened in binary mode on platforms that + /// support this distinction. + F_Binary = 4 + }; + + /// raw_fd_ostream - Open the specified file for writing. If an error occurs, + /// information about the error is put into ErrorInfo, and the stream should + /// be immediately destroyed; the string will be empty if no error occurred. + /// This allows optional flags to control how the file will be opened. /// /// \param Filename - The file to open. If this is "-" then the /// stream will use stdout instead. - /// \param Binary - The file should be opened in binary mode on - /// platforms that support this distinction. - /// \param Force - Don't consider the case where the file already - /// exists to be an error. - raw_fd_ostream(const char *Filename, bool Binary, bool Force, - std::string &ErrorInfo); + raw_fd_ostream(const char *Filename, std::string &ErrorInfo, + unsigned Flags = 0); /// raw_fd_ostream ctor - FD is the file descriptor that this writes to. If /// ShouldClose is true, this closes the file when the stream is destroyed. |