-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdirectory.cpp
More file actions
57 lines (43 loc) · 1.52 KB
/
directory.cpp
File metadata and controls
57 lines (43 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
Copyright (C) 2017-2026 Topological Manifold
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "directory.h"
#include "name.h"
#include <src/com/file/path.h>
#include <filesystem>
#include <string_view>
namespace ns::settings
{
namespace
{
constexpr std::string_view TEST_DIRECTORY_NAME = "test";
void create_dir(const std::filesystem::path& directory)
{
std::filesystem::create_directory(directory);
std::filesystem::permissions(directory, std::filesystem::perms::owner_all);
}
std::filesystem::path test_directory()
{
std::filesystem::path directory = std::filesystem::temp_directory_path();
directory /= path_from_utf8(APPLICATION_NAME);
create_dir(directory);
directory /= path_from_utf8(TEST_DIRECTORY_NAME);
create_dir(directory);
return directory;
}
}
std::filesystem::path test_path(const std::string_view utf8_name)
{
return settings::test_directory() / path_from_utf8(utf8_name);
}
}