NAH 1.0.6
Native Application Host - Library API Reference
Loading...
Searching...
No Matches
path_utils.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4
5namespace nah {
6
7enum class PathError {
8 None,
12};
13
14struct PathResult {
15 bool ok;
16 std::string path; // normalized absolute path when ok
18};
19
20// Normalize a path relative to a root without following symlinks (string-based).
21// - Rejects NUL bytes
22// - Rejects absolute relative_path when allow_absolute is false
23// - Collapses "." and ".." segments
24// - Fails if resulting path would escape root
25PathResult normalize_under_root(const std::string& root,
26 const std::string& relative_path,
27 bool allow_absolute = false);
28
29} // namespace nah
30
Result type for fallible operations.
Definition nahhost.hpp:109
PathResult normalize_under_root(const std::string &root, const std::string &relative_path, bool allow_absolute=false)
PathError
Definition path_utils.hpp:7
std::string path
PathError error