| Dmitrii Merkurev | 9129717 | 2023-02-09 02:08:14 +0000 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2023 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 | #pragma once | 
|  | 18 |  | 
|  | 19 | #include <android-base/unique_fd.h> | 
|  | 20 |  | 
|  | 21 | #include <string> | 
|  | 22 |  | 
|  | 23 | using android::base::unique_fd; | 
|  | 24 |  | 
|  | 25 | // TODO(b/175635923): remove after enabling libc++fs for windows | 
|  | 26 | const char kPathSeparator = | 
|  | 27 | #ifdef _WIN32 | 
| Dmitrii Merkurev | 0ee285a | 2023-02-11 00:02:22 +0000 | [diff] [blame] | 28 | '\\'; | 
| Dmitrii Merkurev | 9129717 | 2023-02-09 02:08:14 +0000 | [diff] [blame] | 29 | #else | 
| Dmitrii Merkurev | 0ee285a | 2023-02-11 00:02:22 +0000 | [diff] [blame] | 30 | '/'; | 
| Dmitrii Merkurev | 9129717 | 2023-02-09 02:08:14 +0000 | [diff] [blame] | 31 | #endif | 
|  | 32 |  | 
|  | 33 | std::string GetHomeDirPath(); | 
|  | 34 | bool EnsureDirectoryExists(const std::string& directory_path); | 
|  | 35 |  | 
|  | 36 | class FileLock { | 
|  | 37 | public: | 
|  | 38 | FileLock() = delete; | 
|  | 39 | FileLock(const std::string& path); | 
|  | 40 |  | 
|  | 41 | private: | 
|  | 42 | unique_fd fd_; | 
|  | 43 | }; |