olp-cpp-sdk 1.24.0
Loading...
Searching...
No Matches
Dir.h
1/*
2 * Copyright (C) 2019-2024 HERE Europe B.V.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 * License-Filename: LICENSE
18 */
19
20#pragma once
21
22#include <cstdint>
23#include <functional>
24#include <string>
25
26#include <olp/core/CoreApi.h>
27
28namespace olp {
29namespace utils {
30
33class CORE_API Dir {
34 public:
36 using FilterFunction = std::function<bool(const std::string&)>;
37
39 using PathCallback = std::function<void(const std::string&)>;
40
48 static bool Exists(const std::string& path);
49
57 static bool Remove(const std::string& path);
58
71 static bool Create(const std::string& path, bool extend_permissions = false);
72
78 static std::string TempDirectory();
79
87 static bool FileExists(const std::string& file_path);
88
103 static uint64_t Size(const std::string& path, FilterFunction filter_fn = {});
104
114 static bool IsReadOnly(const std::string& path);
115
123 static void ForEachDirectory(const std::string& path, PathCallback path_fn);
124};
125
126} // namespace utils
127} // namespace olp
Manages directories.
Definition Dir.h:33
static bool Create(const std::string &path, bool extend_permissions=false)
Creates a directory and all required directories specified in the path.
static bool FileExists(const std::string &file_path)
Checks whether the provided file exists.
static uint64_t Size(const std::string &path, FilterFunction filter_fn={})
Calculates the size of a directory.
static bool Exists(const std::string &path)
Checks whether a directory exists.
static bool IsReadOnly(const std::string &path)
Checks if the current application and user has a read only access to given path.
std::function< void(const std::string &)> PathCallback
An alias for the path callback function.
Definition Dir.h:39
static bool Remove(const std::string &path)
Removes a directory and deletes all its subfolders and files.
static void ForEachDirectory(const std::string &path, PathCallback path_fn)
Iterates through top-level directories in the provided path and calls the provided callback function ...
static std::string TempDirectory()
Gets a platform-specific temporary path.
std::function< bool(const std::string &)> FilterFunction
An alias for the filter function.
Definition Dir.h:36
Rules all the other namespaces.
Definition AppleSignInProperties.h:24