• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2025 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 "hiview_file_info.h"
17 
18 namespace OHOS {
19 namespace HiviewDFX {
Marshalling(Parcel & outParcel) const20 bool HiviewFileInfo::Marshalling(Parcel& outParcel) const
21 {
22     if (!outParcel.WriteString(name)) {
23         return false;
24     }
25     if (!outParcel.WriteInt64(mtime)) {
26         return false;
27     }
28     if (!outParcel.WriteUint64(size)) {
29         return false;
30     }
31     return true;
32 }
33 
Unmarshalling(Parcel & inParcel)34 HiviewFileInfo* HiviewFileInfo::Unmarshalling(Parcel& inParcel)
35 {
36     std::string name;
37     if (!inParcel.ReadString(name)) {
38         return nullptr;
39     }
40     time_t mtime = 0;
41     if (!inParcel.ReadInt64(mtime)) {
42         return nullptr;
43     }
44     uint64_t size = 0;
45     if (!inParcel.ReadUint64(size)) {
46         return nullptr;
47     }
48     return new HiviewFileInfo(name, mtime, size);
49 }
50 } // namespace HiviewDFX
51 } // namespace OHOS