@@ -15,7 +15,8 @@ namespace tmp {
1515/// deletes it when this handle goes out of scope
1616///
1717/// When a tmp::file object is created, it creates a unique temporary file using
18- /// the system's default location for temporary files
18+ /// the system's default location for temporary files and opens it for reading
19+ /// and writing
1920///
2021/// The managed file is deleted of when either of the following happens:
2122/// - the managing tmp::file object is destroyed
@@ -32,7 +33,7 @@ namespace tmp {
3233/// #include <tmp/file>
3334///
3435/// auto func(std::string_view content) {
35- /// auto tmpfile = tmp::file("org.example.product");
36+ /// auto tmpfile = tmp::file("org.example.product", ".txt" );
3637/// tmpfile.write(content);
3738///
3839/// // the temporary file is deleted recursively when the
@@ -52,7 +53,6 @@ public:
5253
5354 /// Creates a unique temporary file and opens it for reading and writing
5455 /// in binary mode
55- ///
5656 /// @param label A label to attach to the temporary file path
5757 /// @param extension An extension of the temporary file path
5858 /// @throws std::filesystem::filesystem_error if cannot create a file
@@ -61,7 +61,6 @@ public:
6161
6262 /// Creates a unique temporary file and opens it for reading and writing
6363 /// in text mode
64- ///
6564 /// @param label A label to attach to the temporary file path
6665 /// @param extension An extension of the temporary file path
6766 /// @throws std::filesystem::filesystem_error if cannot create a file
@@ -70,12 +69,11 @@ public:
7069 std::string_view extension = "");
7170
7271 /// Creates a unique temporary copy from the given path
73- ///
7472 /// @param path A path to make a temporary copy from
7573 /// @param label A label to attach to the temporary file path
7674 /// @param extension An extension of the temporary file path
7775 /// @returns The new temporary file
78- /// @throws std::filesystem::filesystem_error if path is not a file
76+ /// @throws std::filesystem::filesystem_error if given path is not a file
7977 /// @throws std::invalid_argument if arguments are ill-formatted
8078 static file copy(const std::filesystem::path& path,
8179 std::string_view label = "",
@@ -90,11 +88,11 @@ public:
9088 std::string read() const;
9189
9290 /// Writes the given content to this file discarding any previous content
93- /// @param content A string to write to this file
91+ /// @param content A string to write to this file
9492 void write(std::string_view content) const;
9593
9694 /// Appends the given content to the end of this file
97- /// @param content A string to append to this file
95+ /// @param content A string to append to this file
9896 void append(std::string_view content) const;
9997
10098 /// Deletes the managed file if its path is not empty
@@ -114,7 +112,6 @@ private:
114112
115113 /// Creates a unique temporary file and opens it for reading and writing
116114 /// in the specified mode
117- ///
118115 /// @param label A label to attach to the temporary file path
119116 /// @param extension An extension of the temporary file path
120117 /// @param binary Whether the managed file is opened in binary write mode
@@ -123,10 +120,8 @@ private:
123120 file(std::string_view label, std::string_view extension, bool binary);
124121
125122 /// Creates a unique temporary file
126- ///
127- /// @param handle A path to the created temporary file and its
128- /// implementation-defined handle
129- /// @param binary Whether the managed file is opened in binary write mode
123+ /// @param handle A path to the created temporary file and its handle
124+ /// @param binary Whether the managed file is opened in binary write mode
130125 file(std::pair<std::filesystem::path, native_handle_type> handle,
131126 bool binary) noexcept;
132127};
0 commit comments