GCC Code Coverage Report


Directory: src/gate/
File: src/gate/system/cxx_storagevolumes.cpp
Date: 2025-09-14 13:10:38
Exec Total Coverage
Lines: 0 88 0.0%
Functions: 0 23 0.0%
Branches: 0 64 0.0%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright(c) 2018-2025, Stefan Meislinger |
4 | All rights reserved. |
5 | |
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met:|
8 | |
9 | 1. Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. |
11 | 2. Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. |
14 | |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"|
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | THE POSSIBILITY OF SUCH DAMAGE. |
26 +----------------------------------------------------------------------------+
27 */
28
29 #include "gate/system/storagevolumes.hpp"
30
31 namespace gate
32 {
33 namespace sys
34 {
35
36 enumint_t const StorageVolume::Flag_Online = GATE_STORAGEVOLUME_FLAG_ONLINE;
37 enumint_t const StorageVolume::Flag_ReadOnly = GATE_STORAGEVOLUME_FLAG_READONLY;
38
39 StorageVolume::StorageVolume(StorageVolume const& src)
40 : cached_path(src.cached_path),
41 cached_name(src.cached_name),
42 cached_uid(src.cached_uid),
43 cached_device_path(src.cached_device_path),
44 cached_serial(src.cached_serial),
45 cached_device_name(src.cached_device_name),
46 cached_fs_name(src.cached_fs_name)
47 {
48 gate_mem_copy(&this->impl, &src.impl, sizeof(this->impl));
49 }
50 StorageVolume& StorageVolume::operator=(StorageVolume const& src)
51 {
52 if (this != &src)
53 {
54 gate_mem_copy(&this->impl, &src.impl, sizeof(this->impl));
55 this->cached_path = src.cached_path;
56 this->cached_name = src.cached_name;
57 this->cached_uid = src.cached_uid;
58 this->cached_device_path = src.cached_device_path;
59 this->cached_serial = src.cached_serial;
60 this->cached_device_name = src.cached_device_name;
61 this->cached_fs_name = src.cached_fs_name;
62 }
63 return *this;
64 }
65 StorageVolume::~StorageVolume() noexcept
66 {
67 }
68 ControlStream StorageVolume::openStream(enumint_t openFlags)
69 {
70 gate_controlstream_t* ptr_stream = NULL;
71 result_t res = gate_storagevolume_openstream(&this->impl, openFlags, &ptr_stream);
72 GATEXX_CHECK_EXCEPTION(res);
73 ControlStream strm(ptr_stream);
74 return strm;
75 }
76
77 StorageVolume::StorageVolume(gate_storagevolume_t const& impl)
78 : cached_path(impl.path),
79 cached_name(impl.name),
80 cached_uid(impl.uid),
81 cached_device_path(impl.devicepath),
82 cached_serial(impl.serial),
83 cached_device_name(impl.devicename),
84 cached_fs_name(impl.fsname)
85 {
86 gate_mem_copy(&this->impl, &impl, sizeof(impl));
87 }
88
89 String StorageVolume::Path() const
90 {
91 return this->cached_path;
92 }
93 String StorageVolume::Name() const
94 {
95 return this->cached_name;
96 }
97 String StorageVolume::Uid() const
98 {
99 return this->cached_uid;
100 }
101 String StorageVolume::DevicePath() const
102 {
103 return this->cached_device_path;
104 }
105 String StorageVolume::Serial() const
106 {
107 return this->cached_serial;
108 }
109 String StorageVolume::DeviceName() const
110 {
111 return this->cached_device_name;
112 }
113 String StorageVolume::FileSystemName() const
114 {
115 return this->cached_fs_name;
116 }
117 uint64_t StorageVolume::Size() const
118 {
119 return this->impl.size;
120 }
121 uint64_t StorageVolume::SizeUsed() const
122 {
123 return this->impl.sizeused;
124 }
125 uint64_t StorageVolume::SizeFree() const
126 {
127 return this->impl.sizefree;
128 }
129 StorageVolume::TypeEnum StorageVolume::VolumeType() const
130 {
131 return (TypeEnum)this->impl.volumetype;
132 }
133 enumint_t StorageVolume::Flags() const
134 {
135 return this->impl.flags;
136 }
137
138 gate_storagevolume_t const* StorageVolume::c_impl() const
139 {
140 return &this->impl;
141 }
142
143 gate_bool_t StorageVolume::findAllCallback(gate_storagevolume_t const* volume, void* user_param)
144 {
145 ArrayList<StorageVolume>* vol_list = static_cast<ArrayList<StorageVolume>*>(user_param);
146 try
147 {
148 StorageVolume vol(*volume);
149 vol_list->add(vol);
150 }
151 catch (...)
152 {
153 }
154 return true;
155 }
156
157 Array<StorageVolume> StorageVolume::findAll()
158 {
159 ArrayList<StorageVolume> vol_list;
160
161 result_t res = gate_storagevolume_enum(&StorageVolume::findAllCallback, &vol_list);
162 GATEXX_CHECK_EXCEPTION(res);
163
164 return vol_list.toArray();
165 }
166
167 StorageVolume StorageVolume::findByPath(String const& path)
168 {
169 gate_storagevolume_t vol;
170 result_t res = gate_storagevolume_find(path.c_impl(), GATE_STORAGEVOLUME_PATH, &vol);
171 GATEXX_CHECK_EXCEPTION(res);
172 return StorageVolume(vol);
173 }
174 StorageVolume StorageVolume::findByUid(String const& path)
175 {
176 gate_storagevolume_t vol;
177 result_t res = gate_storagevolume_find(path.c_impl(), GATE_STORAGEVOLUME_UID, &vol);
178 GATEXX_CHECK_EXCEPTION(res);
179 return StorageVolume(vol);
180 }
181 StorageVolume StorageVolume::findByName(String const& path)
182 {
183 gate_storagevolume_t vol;
184 result_t res = gate_storagevolume_find(path.c_impl(), GATE_STORAGEVOLUME_NAME, &vol);
185 GATEXX_CHECK_EXCEPTION(res);
186 return StorageVolume(vol);
187 }
188
189 } // end of namespace sys
190 } // end of namespace gate
191