OpenVDB: openvdb/io/TempFile.h Source File

OpenVDB 12.1.1

Loading...
Searching...
No Matches
TempFile.h
Go to the documentation of this file.
1// Copyright Contributors to the OpenVDB Project
2// SPDX-License-Identifier: Apache-2.0
3
4/// @file TempFile.h
5
6#ifdef OPENVDB_USE_DELAYED_LOADING
7
8#ifndef OPENVDB_IO_TEMPFILE_HAS_BEEN_INCLUDED
9#define OPENVDB_IO_TEMPFILE_HAS_BEEN_INCLUDED
10
11#include <openvdb/version.h>
12#include <memory>
13#include <ostream>
14
15
16namespace openvdb {
17 OPENVDB_USE_VERSION_NAMESPACE
18namespace OPENVDB_VERSION_NAME {
19namespace io {
20
21/// Output stream to a unique temporary file
22class OPENVDB_API TempFile: public std::ostream
23{
24public:
25 /// @brief Create and open a unique file.
26 /// @details On UNIX systems, the file is created in the directory specified by
27 /// the environment variable @c OPENVDB_TEMP_DIR, if that variable is defined,
28 /// or else in the directory specified by @c TMPDIR, if that variable is defined.
29 /// Otherwise (and on non-UNIX systems), the file is created in the system default
30 /// temporary directory.
31 TempFile();
32 ~TempFile();
33
34 /// Return the path to the temporary file.
35 const std::string& filename() const;
36
37 /// Return @c true if the file is open for writing.
38 bool is_open() const;
39
40 /// Close the file.
41 void close();
42
43private:
44 struct TempFileImpl;
45 std::unique_ptr<TempFileImpl> mImpl;
46};
47
48} // namespace io
49} // namespace OPENVDB_VERSION_NAME
50} // namespace openvdb
51
52#endif // OPENVDB_IO_TEMPFILE_HAS_BEEN_INCLUDED
53
54#endif // OPENVDB_USE_DELAYED_LOADING
OPENVDB_API
#define OPENVDB_API
Definition Platform.h:291
openvdb
Definition Exceptions.h:13
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:218