summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratedFileStream.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2005-04-05 12:25:21 (GMT)
committerBrad King <brad.king@kitware.com>2005-04-05 12:25:21 (GMT)
commit389f24f777b790b12759184c96c4690a771f941b (patch)
treee5c4106ba13859b4fd1047f0de051b2689de814c /Source/cmGeneratedFileStream.h
parent2681215256835253cf18d47d314b3202df8e9651 (diff)
downloadCMake-389f24f777b790b12759184c96c4690a771f941b.zip
CMake-389f24f777b790b12759184c96c4690a771f941b.tar.gz
CMake-389f24f777b790b12759184c96c4690a771f941b.tar.bz2
ENH: Added Close method and updated Open method to allow streams to be reused.
Diffstat (limited to 'Source/cmGeneratedFileStream.h')
-rw-r--r--Source/cmGeneratedFileStream.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h
index e9b1bb7..90ea51e 100644
--- a/Source/cmGeneratedFileStream.h
+++ b/Source/cmGeneratedFileStream.h
@@ -35,8 +35,12 @@ protected:
// The destructor renames the temporary output file to the real name.
~cmGeneratedFileStreamBase();
- // Internal method to setup the instance for a given file name.
+ // Internal methods to handle the temporary file. Open is always
+ // called before the real stream is opened. Close is always called
+ // after the real stream is closed and m_Okay is set to whether the
+ // real stream was still valid for writing when it was closed.
void Open(const char* name);
+ void Close();
// Internal file replacement implementation.
int RenameFile(const char* oldname, const char* newname);
@@ -53,7 +57,7 @@ protected:
// Whether to do a copy-if-different.
bool m_CopyIfDifferent;
- // Whether the destination file should be replaced.
+ // Whether the real file stream was valid when it was closed.
bool m_Okay;
// Whether the destionation file is compressed
@@ -99,13 +103,21 @@ public:
/**
* Open an output file by name. This should be used only with a
- * default-constructed stream. It automatically generates a name
- * for the temporary file. If the file cannot be opened an error
- * message is produced unless the second argument is set to true.
+ * non-open stream. It automatically generates a name for the
+ * temporary file. If the file cannot be opened an error message is
+ * produced unless the second argument is set to true.
*/
cmGeneratedFileStream& Open(const char* name, bool quiet=false);
/**
+ * Close the output file. This should be used only with an open
+ * stream. The temporary file is atomically renamed to the
+ * destionation file if the stream is still valid when this method
+ * is called.
+ */
+ cmGeneratedFileStream& Close();
+
+ /**
* Set whether copy-if-different is done.
*/
void SetCopyIfDifferent(bool copy_if_different);