• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "disk.h"
17 
18 namespace OHOS {
19 namespace StorageManager {
Disk()20 Disk::Disk() {}
21 
Disk(std::string diskId,int64_t sizeBytes,std::string sysPath,std::string vendor,int32_t flag)22 Disk::Disk(std::string diskId, int64_t sizeBytes, std::string sysPath, std::string vendor, int32_t flag)
23     : diskId_(diskId), sizeBytes_(sizeBytes), sysPath_(sysPath), vendor_(vendor), flag_(flag) {}
24 
GetDiskId()25 std::string Disk::GetDiskId()
26 {
27     return diskId_;
28 }
29 
GetSizeBytes()30 int64_t Disk::GetSizeBytes()
31 {
32     return sizeBytes_;
33 }
34 
GetSysPath()35 std::string Disk::GetSysPath()
36 {
37     return sysPath_;
38 }
39 
GetVendor()40 std::string Disk::GetVendor()
41 {
42     return vendor_;
43 }
44 
GetFlag()45 int32_t Disk::GetFlag()
46 {
47     return flag_;
48 }
49 
SetFlag(int32_t flag)50 void Disk::SetFlag(int32_t flag)
51 {
52     flag_ = flag;
53 }
54 
Marshalling(Parcel & parcel) const55 bool Disk::Marshalling(Parcel &parcel) const
56 {
57     parcel.WriteString(diskId_);
58     parcel.WriteInt32(sizeBytes_);
59     parcel.WriteString(sysPath_);
60     parcel.WriteString(vendor_);
61     parcel.WriteInt32(flag_);
62     return true;
63 }
64 
Unmarshalling(Parcel & parcel)65 std::unique_ptr<Disk> Disk::Unmarshalling(Parcel &parcel)
66 {
67     auto obj = std::make_unique<Disk>();
68     obj->diskId_ = parcel.ReadString();
69     obj->sizeBytes_ = parcel.ReadInt32();
70     obj->sysPath_ = parcel.ReadString();
71     obj->vendor_ = parcel.ReadString();
72     obj->flag_ = parcel.ReadInt32();
73     return obj;
74 }
75 }
76 }