-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathproject_creation.hpp
More file actions
57 lines (45 loc) · 1.71 KB
/
Copy pathproject_creation.hpp
File metadata and controls
57 lines (45 loc) · 1.71 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
#pragma once
#include <cstddef>
#include <string>
namespace acecode::web {
inline constexpr std::size_t kProjectDirectoryNameMaxCodePoints = 60;
struct NormalizedProjectDirectoryName {
std::string value;
bool changed = false;
};
// Normalize a user-visible project name into one cross-platform path component.
// The Windows rules are intentionally used on every platform so projects can be
// moved between systems without renaming their root directory.
NormalizedProjectDirectoryName normalize_project_directory_name(
const std::string& requested_name);
// User source trees live beside, not inside, ACECode's hash-indexed projects
// metadata directory: <data-dir>/projects -> <data-dir>/workspaces.
std::string default_project_parent_directory(
const std::string& metadata_projects_dir);
enum class ProjectCreationError {
None,
NameRequired,
ParentMustBeAbsolute,
ParentNotFound,
ParentNotDirectory,
TargetExists,
CreateFailed,
};
const char* project_creation_error_code(ProjectCreationError error);
struct ProjectCreationResult {
ProjectCreationError error = ProjectCreationError::None;
std::string message;
std::string requested_name;
std::string directory_name;
std::string parent_dir;
std::string project_dir;
bool sanitized = false;
bool ok() const { return error == ProjectCreationError::None; }
};
// Creates exactly one project child. A custom parent must already exist; the
// ACECode default parent is the only parent that is created on demand.
ProjectCreationResult create_project_directory(
const std::string& requested_name,
const std::string& requested_parent_dir,
const std::string& metadata_projects_dir);
} // namespace acecode::web