blob: c5f9c948d68fd8115dd17028b859d93a42bb0ddc [file] [log] [blame]
Dmitrii Merkurev91297172023-02-09 02:08:14 +00001/*
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
23using android::base::unique_fd;
24
25// TODO(b/175635923): remove after enabling libc++fs for windows
26const char kPathSeparator =
27#ifdef _WIN32
Dmitrii Merkurev0ee285a2023-02-11 00:02:22 +000028 '\\';
Dmitrii Merkurev91297172023-02-09 02:08:14 +000029#else
Dmitrii Merkurev0ee285a2023-02-11 00:02:22 +000030 '/';
Dmitrii Merkurev91297172023-02-09 02:08:14 +000031#endif
32
33std::string GetHomeDirPath();
Dmitrii Merkurev6c008ff2023-06-02 12:44:31 +010034bool FileExists(const std::string& path);
Dmitrii Merkurev91297172023-02-09 02:08:14 +000035bool EnsureDirectoryExists(const std::string& directory_path);
36
37class FileLock {
38 public:
39 FileLock() = delete;
40 FileLock(const std::string& path);
41
42 private:
43 unique_fd fd_;
44};