Orion Hodson | f96c916 | 2021-04-07 10:43:01 +0100 | [diff] [blame] | 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 | |
Alan Stokes | 2c96673 | 2021-07-02 12:04:15 +0100 | [diff] [blame] | 28 | // Removes the directory at `dir_path`, first removing all files and sub-directories in it. |
Orion Hodson | f96c916 | 2021-04-07 10:43:01 +0100 | [diff] [blame] | 29 | // Returns true on success, false otherwise. |
Alan Stokes | 2c96673 | 2021-07-02 12:04:15 +0100 | [diff] [blame] | 30 | WARN_UNUSED bool RemoveDirectory(const std::string& dir_path); |
Orion Hodson | f96c916 | 2021-04-07 10:43:01 +0100 | [diff] [blame] | 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_ |