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 16 #include "volume_external.h" 17 18 namespace OHOS { 19 namespace StorageManager { VolumeExternal()20VolumeExternal::VolumeExternal() {} 21 VolumeExternal(VolumeCore vc)22VolumeExternal::VolumeExternal(VolumeCore vc) 23 : VolumeExternal::VolumeCore(vc.GetId(), vc.GetType(), vc.GetDiskId(), vc.GetState()) {} 24 SetFsType(int32_t fsType)25void VolumeExternal::SetFsType(int32_t fsType) 26 { 27 fsType_ = fsType; 28 } 29 SetFsUuid(std::string fsUuid)30void VolumeExternal::SetFsUuid(std::string fsUuid) 31 { 32 fsUuid_ = fsUuid; 33 } 34 SetPath(std::string path)35void VolumeExternal::SetPath(std::string path) 36 { 37 path_ = path; 38 } 39 SetDescription(std::string description)40void VolumeExternal::SetDescription(std::string description) 41 { 42 description_ = description; 43 } 44 GetFsType()45int32_t VolumeExternal::GetFsType() 46 { 47 return fsType_; 48 } 49 GetUuid()50std::string VolumeExternal::GetUuid() 51 { 52 return fsUuid_; 53 } 54 GetPath()55std::string VolumeExternal::GetPath() 56 { 57 return path_; 58 } 59 GetDescription()60std::string VolumeExternal::GetDescription() 61 { 62 return description_; 63 } 64 Reset()65void VolumeExternal::Reset() 66 { 67 path_ = ""; 68 } 69 Marshalling(Parcel & parcel) const70bool VolumeExternal::Marshalling(Parcel &parcel) const 71 { 72 if (!VolumeCore::Marshalling(parcel)) { 73 return false; 74 } 75 76 if (!parcel.WriteInt32(fsType_)) { 77 return false; 78 } 79 80 if (!parcel.WriteString(fsUuid_)) { 81 return false; 82 } 83 84 if (!parcel.WriteString(path_)) { 85 return false; 86 } 87 88 if (!parcel.WriteString(description_)) { 89 return false; 90 } 91 92 return true; 93 } 94 Unmarshalling(Parcel & parcel)95std::unique_ptr<VolumeExternal> VolumeExternal::Unmarshalling(Parcel &parcel) 96 { 97 auto obj = std::make_unique<VolumeExternal>(*VolumeCore::Unmarshalling(parcel)); 98 obj->fsType_ = parcel.ReadInt32(); 99 obj->fsUuid_ = parcel.ReadString(); 100 obj->path_ = parcel.ReadString(); 101 obj->description_ = parcel.ReadString(); 102 return obj; 103 } 104 } 105 } 106