1 /*
2 * Copyright (c) 2022 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/file_stat.h"
17
18 #include "parcel_macro.h"
19
20 namespace OHOS {
21 namespace AppExecFwk {
ReadFromParcel(Parcel & parcel)22 bool FileStat::ReadFromParcel(Parcel &parcel)
23 {
24 uid = parcel.ReadInt32();
25 gid = parcel.ReadInt32();
26 lastModifyTime = parcel.ReadInt64();
27 isDir = parcel.ReadBool();
28 mode = parcel.ReadInt32();
29 return true;
30 }
31
Marshalling(Parcel & parcel) const32 bool FileStat::Marshalling(Parcel &parcel) const
33 {
34 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, uid);
35 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, gid);
36 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, lastModifyTime);
37 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isDir);
38 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, mode);
39 return true;
40 }
41
Unmarshalling(Parcel & parcel)42 FileStat *FileStat::Unmarshalling(Parcel &parcel)
43 {
44 FileStat *info = new (std::nothrow) FileStat();
45 if (info) {
46 info->ReadFromParcel(parcel);
47 }
48 return info;
49 }
50 } // namespace AppExecFwk
51 } // namespace OHOS
52