• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 "backup_file_info.h"
17 
18 #include "filemgmt_libhilog.h"
19 
20 namespace OHOS {
21 namespace FileManagement {
22 namespace Backup {
23 using namespace std;
24 
Marshalling(Parcel & parcel) const25 bool BFileInfo::Marshalling(Parcel &parcel) const
26 {
27     if (!parcel.WriteString(owner) || !parcel.WriteString(fileName) || !parcel.WriteUint32(sn)) {
28         HILOGE("Failed");
29         return false;
30     }
31     return true;
32 }
33 
ReadFromParcel(Parcel & parcel)34 bool BFileInfo::ReadFromParcel(Parcel &parcel)
35 {
36     if (!parcel.ReadString(owner) || !parcel.ReadString(fileName) || !parcel.ReadUint32(sn)) {
37         HILOGE("Failed");
38         return false;
39     }
40     return true;
41 }
42 
Unmarshalling(Parcel & parcel)43 BFileInfo *BFileInfo::Unmarshalling(Parcel &parcel)
44 {
45     try {
46         auto result = make_unique<BFileInfo>();
47         if (!result->ReadFromParcel(parcel)) {
48             return nullptr;
49         }
50         return result.release();
51     } catch (const bad_alloc &e) {
52         HILOGE("Failed to unmarshall BFileInfo because of %{public}s", e.what());
53     }
54     return nullptr;
55 }
56 } // namespace Backup
57 } // namespace FileManagement
58 } // namespace OHOS