AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
FileSystemUtils.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
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  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #if defined(FILE_SYSTEM_UTILS_ENABLED)
17 
18 #ifndef ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_FILESYSTEM_FILESYSTEMUTILS_H_
19 #define ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_FILESYSTEM_FILESYSTEMUTILS_H_
20 
21 #include <string>
22 #include <vector>
23 
52 namespace alexaClientSDK {
53 namespace avsCommon {
54 namespace utils {
55 namespace filesystem {
56 
58 using Permissions = uint32_t;
59 
64 enum PermBits : Permissions {
65  NO_PERM = 0000,
66 
67  // Owner permissions
68  OWNER_ALL = 0700,
69  OWNER_READ = 0400,
70  OWNER_WRITE = 0200,
71  OWNER_EXEC = 0100,
72 
73  // Group permissions
74  GROUP_ALL = 0070,
75  GROUP_READ = 0040,
76  GROUP_WRITE = 0020,
77  GROUP_EXEC = 0010,
78 
79  // Everyone else's permissions
80  OTHERS_ALL = 0007,
81  OTHERS_READ = 0004,
82  OTHERS_WRITE = 0002,
83  OTHERS_EXEC = 0001
84 };
85 
87 extern const Permissions DEFAULT_DIRECTORY_PERMISSIONS;
89 extern const Permissions DEFAULT_FILE_PERMISSIONS;
90 
100 enum class FileType { REGULAR_FILE, DIRECTORY, ALL };
101 
110 bool changePermissions(const std::string& path, Permissions perms);
111 
120 bool exists(const std::string& path);
121 
129 std::string currentDirectory();
130 
143 bool makeDirectory(const std::string& path, Permissions perms = DEFAULT_DIRECTORY_PERMISSIONS);
144 
156 std::vector<std::string> list(const std::string& path, FileType type = FileType::ALL);
157 
165 bool move(const std::string& source, const std::string& destination);
166 
180 std::string basenameOf(const std::string& path);
181 
199 std::string parentDirNameOf(const std::string& path);
200 
209 bool removeAll(const std::string& path);
210 
221 size_t sizeOf(const std::string& path);
222 
232 size_t availableSpace(const std::string& path);
233 
241 bool pathContainsPrefix(const std::string& path, const std::string& prefix);
242 
243 } // namespace filesystem
244 } // namespace utils
245 } // namespace avsCommon
246 } // namespace alexaClientSDK
247 
248 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_FILESYSTEM_FILESYSTEMUTILS_H_
249 
250 #endif // FILE_SYSTEM_UTILS_ENABLED
::std::string string
Definition: gtest-port.h:1097
ALL
Definition: keywords.py:49
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
type
Definition: upload.py:443
const T & move(const T &t)
Definition: gtest-port.h:1317

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0