24#ifndef PXR_BASE_TF_SAFE_OUTPUT_FILE_H
25#define PXR_BASE_TF_SAFE_OUTPUT_FILE_H
31#include "pxr/base/tf/api.h"
37PXR_NAMESPACE_OPEN_SCOPE
58 , _targetFileName(std::move(other._targetFileName))
59 , _tempFileName(std::move(other._tempFileName))
60 { other._file =
nullptr; }
64 _targetFileName = std::move(other._targetFileName);
65 _tempFileName = std::move(other._tempFileName);
66 other._file =
nullptr;
91 FILE *
Get()
const {
return _file; }
103 FILE *_file =
nullptr;
104 std::string _targetFileName;
105 std::string _tempFileName;
108PXR_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().