1 /*
2  * Copyright (C) 2021 The Android Open Source Project
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 
17 #ifndef ART_ODREFRESH_ODR_FS_UTILS_H_
18 #define ART_ODREFRESH_ODR_FS_UTILS_H_
19 
20 #include <cstdint>
21 #include <iosfwd>
22 
23 #include <android-base/macros.h>
24 
25 namespace art {
26 namespace odrefresh {
27 
28 // Cleans directory by removing all files and sub-directories under `dir_path`.
29 // Returns true on success, false otherwise.
30 WARN_UNUSED bool CleanDirectory(const std::string& dir_path);
31 
32 // Create all directories on `absolute_dir_path`.
33 // Returns true on success, false otherwise.
34 WARN_UNUSED bool EnsureDirectoryExists(const std::string& absolute_dir_path);
35 
36 // Get free space for filesystem containing `path`.
37 // Returns true on success, false otherwise.
38 WARN_UNUSED bool GetFreeSpace(const std::string& path, uint64_t* bytes);
39 
40 // Gets space used under directory `dir_path`.
41 // Returns true on success, false otherwise.
42 WARN_UNUSED bool GetUsedSpace(const std::string& dir_path, uint64_t* bytes);
43 
44 }  // namespace odrefresh
45 }  // namespace art
46 
47 #endif  // ART_ODREFRESH_ODR_FS_UTILS_H_
48