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 #include "string_ex.h"
20
21 namespace OHOS {
22 namespace AppExecFwk {
ReadFromParcel(Parcel & parcel)23 bool FileStat::ReadFromParcel(Parcel &parcel)
24 {
25 uid = parcel.ReadInt32();
26 gid = parcel.ReadInt32();
27 lastModifyTime = parcel.ReadInt64();
28 isDir = parcel.ReadBool();
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 return true;
39 }
40
Unmarshalling(Parcel & parcel)41 FileStat *FileStat::Unmarshalling(Parcel &parcel)
42 {
43 FileStat *info = new (std::nothrow) FileStat();
44 if (info) {
45 info->ReadFromParcel(parcel);
46 }
47 return info;
48 }
49 } // namespace AppExecFwk
50 } // namespace OHOS
51