7#ifndef PXR_BASE_TF_SAFE_OUTPUT_FILE_H
8#define PXR_BASE_TF_SAFE_OUTPUT_FILE_H
14#include "pxr/base/tf/api.h"
20PXR_NAMESPACE_OPEN_SCOPE
41 , _targetFileName(std::move(other._targetFileName))
42 , _tempFileName(std::move(other._tempFileName))
43 { other._file =
nullptr; }
47 _targetFileName = std::move(other._targetFileName);
48 _tempFileName = std::move(other._tempFileName);
49 other._file =
nullptr;
74 FILE *
Get()
const {
return _file; }
86 FILE *_file =
nullptr;
87 std::string _targetFileName;
88 std::string _tempFileName;
91PXR_NAMESPACE_CLOSE_SCOPE
Opens a file for output, either for update "r+" or to completely replace "w+".
TF_API bool IsOpenForUpdate() const
Return true if this TfSafeOutputFile was created by a call to Update(), false otherwise.
TF_API FILE * ReleaseUpdatedFile()
If the underlying file was opened by Update(), return it.
static TF_API TfSafeOutputFile Replace(std::string const &fileName)
Arrange for fileName to be replaced.
static TF_API TfSafeOutputFile Update(std::string const &fileName)
Open fileName for update ("r+").
FILE * Get() const
Return the opened FILE *.
TF_API void Discard()
Close the file.
TF_API void Close()
Close the file.
TF_API ~TfSafeOutputFile()
Destructor invokes Close().