libcruft-util/fs/tmp.hpp

36 lines
1.2 KiB
C++

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright 2022, Danny Robson <danny@nerdcruft.net>
*/
#pragma once
#include <filesystem>
namespace cruft::fs {
/// Create a temporary file and return the path to the a newly
/// created file (in a system appropriate location).
///
/// It is the caller's responsibility to clean up this file if
/// required.
///
/// No guarantees are made about the longevity of the file after
/// the application terminates.
std::filesystem::path mktempfile [[nodiscard]] (void);
std::filesystem::path mktempfile [[nodiscard]] (std::filesystem::path const &dir);
/// Create a temporary directory and return the path to the a newly
/// created directory (in a system appropriate location).
///
/// It is the caller's responsibility to clean up this directory if
/// required.
///
/// No guarantees are made about the longevity of the directory after
/// the application terminates.
std::filesystem::path mktmpdir [[nodiscard]] (void);
}