• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef TIME_FILE_UTILS_H
17 #define TIME_FILE_UTILS_H
18 
19 #include <cstdint>
20 #include <string>
21 
22 #include "nocopyable.h"
23 
24 namespace OHOS {
25 namespace MiscServices {
26 namespace {
27 const char PATH_SEPARATOR = '/';
28 }
29 class TimeFileUtils : public NoCopyable {
30 public:
31     static bool MkRecursiveDir(const char *dir, bool isReadOthers);
32     static bool IsExistDir(const char *path);
33     static bool IsExistFile(const char *file);
34     static bool RemoveFile(const char *path);
35     static bool RenameFile(const char *oldDir, const char *newDir);
36     static bool ChownFile(const char *file, int32_t uid, int32_t gid);
37     static bool WriteFile(const char *file, const void *buffer, uint32_t size);
38     static bool IsValidPath(const std::string &rootDir, const std::string &path);
39     static std::string GetPathDir(const std::string &path);
40 };
41 } // MiscServices
42 } // OHOS
43 #endif // TIME_FILE_UTILS_H
44