1 /*
2 * Copyright (c) 2023 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 #include "ipc/create_dir_param.h"
17
18 #include "parcel_macro.h"
19 #include "string_ex.h"
20
21 namespace OHOS {
22 namespace AppExecFwk {
ReadFromParcel(Parcel & parcel)23 bool CreateDirParam::ReadFromParcel(Parcel &parcel)
24 {
25 bundleName = Str16ToStr8(parcel.ReadString16());
26 apl = Str16ToStr8(parcel.ReadString16());
27 userId = parcel.ReadInt32();
28 uid = parcel.ReadInt32();
29 gid = parcel.ReadInt32();
30 isPreInstallApp = parcel.ReadBool();
31 debug = parcel.ReadBool();
32 createDirFlag = static_cast<CreateDirFlag>(parcel.ReadInt32());
33 return true;
34 }
35
Marshalling(Parcel & parcel) const36 bool CreateDirParam::Marshalling(Parcel &parcel) const
37 {
38 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName));
39 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(apl));
40 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, userId);
41 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, uid);
42 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, gid);
43 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isPreInstallApp);
44 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, debug);
45 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(createDirFlag));
46 return true;
47 }
48
Unmarshalling(Parcel & parcel)49 CreateDirParam *CreateDirParam::Unmarshalling(Parcel &parcel)
50 {
51 CreateDirParam *info = new (std::nothrow) CreateDirParam();
52 if (info) {
53 info->ReadFromParcel(parcel);
54 }
55 return info;
56 }
57 } // namespace AppExecFwk
58 } // namespace OHOS
59