1 /* 2 * Copyright (C) 2021 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 #include "file_info.h" 16 #include "log.h" 17 using namespace std; 18 19 namespace OHOS { 20 namespace FileManagerService { Marshalling(Parcel & parcel) const21bool FileInfo::Marshalling(Parcel &parcel) const 22 { 23 parcel.WriteString(path_); 24 parcel.WriteString(name_); 25 parcel.WriteString(type_); 26 parcel.WriteInt64(size_); 27 parcel.WriteInt64(addedTime_); 28 parcel.WriteInt64(modifiedTime_); 29 return true; 30 } 31 Unmarshalling(Parcel & parcel)32FileInfo* FileInfo::Unmarshalling(Parcel &parcel) 33 { 34 auto *obj = new (std::nothrow) FileInfo(); 35 if (obj == nullptr) { 36 ERR_LOG("Unmarshalling fail"); 37 return nullptr; 38 } 39 obj->path_ = parcel.ReadString(); 40 obj->name_ = parcel.ReadString(); 41 obj->type_ = parcel.ReadString(); 42 obj->size_ = parcel.ReadInt64(); 43 obj->addedTime_ = parcel.ReadInt64(); 44 obj->modifiedTime_ = parcel.ReadInt64(); 45 return obj; 46 } 47 } // namespace FileManagerService 48 } // namespace OHOS