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
5
namespace
nah
{
6
7
enum class
PathError
{
8
None
,
9
ContainsNul
,
10
AbsoluteNotAllowed
,
11
EscapesRoot
,
12
};
13
14
struct
PathResult
{
15
bool
ok
;
16
std::string
path
;
// normalized absolute path when ok
17
PathError
error
;
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
25
PathResult
normalize_under_root
(
const
std::string& root,
26
const
std::string&
relative_path
,
27
bool
allow_absolute
=
false
);
28
29
}
// namespace nah
30
nah::Result
Result type for fallible operations.
Definition
nahhost.hpp:109
nah
Definition
capabilities.hpp:11
nah::normalize_under_root
PathResult normalize_under_root(const std::string &root, const std::string &relative_path, bool allow_absolute=false)
nah::PathError
PathError
Definition
path_utils.hpp:7
nah::PathError::ContainsNul
@ ContainsNul
nah::PathError::None
@ None
nah::PathError::EscapesRoot
@ EscapesRoot
nah::PathError::AbsoluteNotAllowed
@ AbsoluteNotAllowed
nah::PathResult
Definition
path_utils.hpp:14
nah::PathResult::path
std::string path
Definition
path_utils.hpp:16
nah::PathResult::ok
bool ok
Definition
path_utils.hpp:15
nah::PathResult::error
PathError error
Definition
path_utils.hpp:17
include
nah
path_utils.hpp
Generated by
1.9.8