Add project files
This commit is contained in:
commit
f2fe6b8855
114 files changed
+20525
No files matched your search
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/// File system and host helpers. Paths are std::filesystem::path throughout; text files are read
|
||||
/// and written as bytes, so the line endings a file has are the ones it keeps.
|
||||
namespace breeze::fs
|
||||
{
|
||||
|
||||
using std::filesystem::path;
|
||||
|
||||
/// Throws Error when the file can't be read.
|
||||
std::string readText(const path& file);
|
||||
std::optional<std::string> tryReadText(const path& file);
|
||||
|
||||
/// Creates the parent directories, then writes the file (replacing it).
|
||||
void writeText(const path& file, const std::string& text);
|
||||
|
||||
/// Copies `from` into `to` (merging into what is there, overwriting files). Entries whose name
|
||||
/// is in `skipNames` are left out at every level.
|
||||
void copyTree(const path& from, const path& to, const std::vector<std::string>& skipNames = {});
|
||||
|
||||
/// Removes the file or directory tree if it exists. Throws Error on failure.
|
||||
void removeTree(const path& p);
|
||||
|
||||
/// A new, empty directory under the system's temp directory.
|
||||
path makeTempDir(const std::string& prefix);
|
||||
|
||||
/// The user's home directory (HOME, or USERPROFILE on Windows).
|
||||
path homeDir();
|
||||
|
||||
/// Where the running program's executable is.
|
||||
path executablePath();
|
||||
|
||||
/// "linux", "macos" or "windows".
|
||||
std::string hostPlatform();
|
||||
|
||||
/// "x64", "arm64", "arm32" or "x86".
|
||||
std::string hostArch();
|
||||
|
||||
/// chmod +x on POSIX; nothing on Windows.
|
||||
void makeExecutable(const path& file);
|
||||
|
||||
/// True for a regular file that can be run.
|
||||
bool isExecutable(const path& file);
|
||||
|
||||
/// The path with forward slashes, for messages that read the same on every OS.
|
||||
std::string generic(const path& p);
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user