-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.hpp
More file actions
83 lines (72 loc) · 2.59 KB
/
Copy pathutil.hpp
File metadata and controls
83 lines (72 loc) · 2.59 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
//
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2025-Present Datadog, Inc.
#pragma once
#include <string_view>
#include "datadog/impl/core/storage/filesystem.hpp"
#include "datadog/impl/core/storage/filesystem_wrapper.hpp"
namespace datadog::impl {
/**
* Returns the string literal representation of the given FilesystemResult enum value.
*/
const char* FilesystemResultStr(FilesystemResult result);
/**
* Wraps a call to `dst.Append(name)`, logging a descriptive error message in the event
* that the resulting path exceeds the maxmimum supported path length.
*/
bool AppendPath(
class StoragePath& dst,
std::string_view name,
const class DiagnosticLogger& logger,
const char* failure_message
);
/**
* Wraps a call to `dst.AppendExt(ext)`, logging a descriptive error message in the
* event that the resulting path exceeds the maximum supported path length.
*/
bool AppendExtensionToPath(
class StoragePath& dst,
std::string_view ext,
const class DiagnosticLogger& logger,
const char* failure_message
);
/**
* Populates `dst` with the result of appending `parent` + `name`, logging a descriptive
* error message if either the `dst.Set(parent)` or `dst.Append(name)` operation fails
* due to the path length limit.
*/
bool JoinPaths(
class StoragePath& dst,
std::string_view parent,
std::string_view name,
const class DiagnosticLogger& logger,
const char* failure_message
);
/**
* Encodes path into the provided PlatformPath buffer, then wraps a call to
* `fs.CreateDirectory` using that path, logging a descriptive error message if either
* path encoding or the CreateDirectory call fail. Returns true if the desired directory
* exists, either because it was successfully created or because there was already a
* directory at the given path.
*/
bool EnsureDirectoryExists(
const class StoragePath& path,
FilesystemWrapper& fsw,
const class DiagnosticLogger& logger,
const char* failure_message
);
/**
* Encodes path into the provided PlatformPath buffer, then wraps a call to
* `fs.DeleteDirectory` using that path, logging a descriptived error message if either
* path encoding or the DeleteDirectory call fail. Returns true if the directory was
* successfully deleted.
*/
bool DeleteEmptyDirectory(
const class StoragePath& path,
FilesystemWrapper& fsw,
const class DiagnosticLogger& logger,
const char* failure_message
);
} // namespace datadog::impl