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 OHOS_BUNDLE_DAEMON_HANDLER_H
17 #define OHOS_BUNDLE_DAEMON_HANDLER_H
18 
19 #include <cstdint>
20 
21 #include "nocopyable.h"
22 #include "ohos_types.h"
23 
24 namespace OHOS {
25 class BundleDaemonHandler : public NoCopyable {
26 public:
27     int32_t ExtractHap(const char *hapPath, const char *codePath);
28     int32_t RenameFile(const char *oldFile, const char *newFile);
29     int32_t CreatePermissionDir();
30     int32_t CreateDataDirectory(const char *dataPath, int32_t uid, int32_t gid, bool isChown);
31     int32_t StoreContentToFile(const char *filePath, const void *buffer, uint32_t size);
32     int32_t MoveFile(const char *oldFile, const char *newFile);
33     int32_t RemoveFile(const char *file);
34     int32_t RemoveInstallDirectory(const char *codePath, const char *dataPath, bool keepData);
35 private:
36     bool IsValideCodePath(const char *codePath);
37     bool IsValideDataPath(const char *codePath);
38     bool IsValideJsonPath(const char *jsonPath);
39     bool IsValideSystemPath(const char *jsonPath);
40 };
41 } // OHOS
42 #endif // OHOS_BUNDLE_DAEMON_HANDLER_H
43