Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
temporary_file.hpp
Go to the documentation of this file.
1#pragma once
2
3// RAII temporary file — creates a temp file on construction, deletes on destruction.
4
5#include <filesystem>
6#include <string>
7
8namespace pulp::runtime {
9
11public:
13 explicit TemporaryFile(std::string_view extension = "");
14
16
18 const std::filesystem::path& path() const { return path_; }
19
21 std::string path_string() const { return path_.string(); }
22
24 void release() { active_ = false; }
25
28 static bool create_exclusive(const std::filesystem::path& path);
29
30 // No copy
31 TemporaryFile(const TemporaryFile&) = delete;
33
34 // Move
37
38private:
39 std::filesystem::path path_;
40 bool active_ = true;
41};
42
43} // namespace pulp::runtime
static bool create_exclusive(const std::filesystem::path &path)
Create path as an empty file readable and writable by the owner only.
TemporaryFile(TemporaryFile &&other) noexcept
TemporaryFile(const TemporaryFile &)=delete
std::string path_string() const
String version of the path.
Definition temporary_file.hpp:21
TemporaryFile & operator=(TemporaryFile &&other) noexcept
TemporaryFile(std::string_view extension="")
Create a temporary file with optional extension (e.g., ".wav").
void release()
Prevent auto-deletion (e.g., if you want to keep the file).
Definition temporary_file.hpp:24
TemporaryFile & operator=(const TemporaryFile &)=delete
const std::filesystem::path & path() const
Full path to the temporary file.
Definition temporary_file.hpp:18
Definition generated_event_source.hpp:33
@ other
Definition udev_monitor.hpp:26