mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-23 06:30:04 +00:00
Cleaned list handling
This commit is contained in:
parent
d099f31ccb
commit
665ad92b2c
@ -537,9 +537,7 @@ void GetDeviceTypeFeatures(PbServerInfo& serverInfo)
|
|||||||
types_properties->set_allocated_properties(properties);
|
types_properties->set_allocated_properties(properties);
|
||||||
properties->set_supports_file(true);
|
properties->set_supports_file(true);
|
||||||
auto block_sizes = device_factory.GetSasiSectorSizes();
|
auto block_sizes = device_factory.GetSasiSectorSizes();
|
||||||
for (const auto& block_size : block_sizes) {
|
properties->mutable_block_sizes()->Add(block_sizes.begin(), block_sizes.end());
|
||||||
properties->add_block_sizes(block_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
types_properties = serverInfo.add_types_properties();
|
types_properties = serverInfo.add_types_properties();
|
||||||
types_properties->set_type(SCHD);
|
types_properties->set_type(SCHD);
|
||||||
@ -548,9 +546,7 @@ void GetDeviceTypeFeatures(PbServerInfo& serverInfo)
|
|||||||
properties->set_protectable(true);
|
properties->set_protectable(true);
|
||||||
properties->set_supports_file(true);
|
properties->set_supports_file(true);
|
||||||
block_sizes = device_factory.GetScsiSectorSizes();
|
block_sizes = device_factory.GetScsiSectorSizes();
|
||||||
for (const auto& block_size : block_sizes) {
|
properties->mutable_block_sizes()->Add(block_sizes.begin(), block_sizes.end());
|
||||||
properties->add_block_sizes(block_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
types_properties = serverInfo.add_types_properties();
|
types_properties = serverInfo.add_types_properties();
|
||||||
types_properties->set_type(SCRM);
|
types_properties->set_type(SCRM);
|
||||||
@ -560,9 +556,7 @@ void GetDeviceTypeFeatures(PbServerInfo& serverInfo)
|
|||||||
properties->set_removable(true);
|
properties->set_removable(true);
|
||||||
properties->set_lockable(true);
|
properties->set_lockable(true);
|
||||||
properties->set_supports_file(true);
|
properties->set_supports_file(true);
|
||||||
for (const auto& block_size : block_sizes) {
|
properties->mutable_block_sizes()->Add(block_sizes.begin(), block_sizes.end());
|
||||||
properties->add_block_sizes(block_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
types_properties = serverInfo.add_types_properties();
|
types_properties = serverInfo.add_types_properties();
|
||||||
types_properties->set_type(SCMO);
|
types_properties->set_type(SCMO);
|
||||||
@ -573,9 +567,7 @@ void GetDeviceTypeFeatures(PbServerInfo& serverInfo)
|
|||||||
properties->set_lockable(true);
|
properties->set_lockable(true);
|
||||||
properties->set_supports_file(true);
|
properties->set_supports_file(true);
|
||||||
auto capacities = device_factory.GetMoCapacities();
|
auto capacities = device_factory.GetMoCapacities();
|
||||||
for (const auto& capacity : capacities) {
|
properties->mutable_capacities()->Add(capacities.begin(), capacities.end());
|
||||||
properties->add_capacities(capacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
types_properties = serverInfo.add_types_properties();
|
types_properties = serverInfo.add_types_properties();
|
||||||
types_properties->set_type(SCCD);
|
types_properties->set_type(SCCD);
|
||||||
|
@ -198,30 +198,29 @@ void CommandServerInfo(const string& hostname, int port)
|
|||||||
|
|
||||||
cout << "Default image file folder: " << serverInfo.default_image_folder() << endl;
|
cout << "Default image file folder: " << serverInfo.default_image_folder() << endl;
|
||||||
if (!serverInfo.image_files_size()) {
|
if (!serverInfo.image_files_size()) {
|
||||||
cout << " No image files available in the default folder" << endl;
|
cout << " No image files available" << endl;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
list<PbImageFile> files;
|
list<PbImageFile> files = { serverInfo.image_files().begin(), serverInfo.image_files().end() };
|
||||||
for (int i = 0; i < serverInfo.image_files_size(); i++) {
|
|
||||||
files.push_back(serverInfo.image_files(i));
|
|
||||||
}
|
|
||||||
files.sort([](const PbImageFile& a, const PbImageFile& b) { return a.name() < b.name(); });
|
files.sort([](const PbImageFile& a, const PbImageFile& b) { return a.name() < b.name(); });
|
||||||
|
|
||||||
cout << "Image files available in the default folder:" << endl;
|
cout << "Available image files:" << endl;
|
||||||
for (const auto& file : files) {
|
for (const auto& file : files) {
|
||||||
cout << " " << file.name() << " (" << file.size() << " bytes)" << (file.read_only() ? ", read-only": "")
|
cout << " " << file.name() << " (" << file.size() << " bytes)";
|
||||||
<< endl;
|
if (file.read_only()) {
|
||||||
|
cout << ", read-only";
|
||||||
|
}
|
||||||
|
cout << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "Supported device types and their properties:" << endl;
|
cout << "Supported device types and their properties:" << endl;
|
||||||
for (int i = 0; i < serverInfo.types_properties_size(); i++) {
|
for (auto it = serverInfo.types_properties().begin(); it != serverInfo.types_properties().end(); ++it) {
|
||||||
PbDeviceTypeProperties types_properties = serverInfo.types_properties(i);
|
cout << " " << PbDeviceType_Name(it->type());
|
||||||
cout << " " << PbDeviceType_Name(types_properties.type());
|
|
||||||
|
|
||||||
cout << " Properties: ";
|
cout << " Properties: ";
|
||||||
bool has_property = false;
|
bool has_property = false;
|
||||||
const PbDeviceProperties& properties = types_properties.properties();
|
const PbDeviceProperties& properties = it->properties();
|
||||||
if (properties.read_only()) {
|
if (properties.read_only()) {
|
||||||
cout << "Read-only";
|
cout << "Read-only";
|
||||||
has_property = true;
|
has_property = true;
|
||||||
@ -252,12 +251,8 @@ void CommandServerInfo(const string& hostname, int port)
|
|||||||
}
|
}
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
list<uint32_t> block_sizes;
|
if (properties.block_sizes_size()) {
|
||||||
for (int k = 0 ; k < properties.block_sizes_size(); k++) {
|
list<uint32_t> block_sizes = { properties.block_sizes().begin(), properties.block_sizes().end() };
|
||||||
block_sizes.push_back(properties.block_sizes(k));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!block_sizes.empty()) {
|
|
||||||
block_sizes.sort([](const auto& a, const auto& b) { return a < b; });
|
block_sizes.sort([](const auto& a, const auto& b) { return a < b; });
|
||||||
|
|
||||||
cout << " Configurable block sizes in bytes: ";
|
cout << " Configurable block sizes in bytes: ";
|
||||||
@ -274,12 +269,8 @@ void CommandServerInfo(const string& hostname, int port)
|
|||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
list<uint64_t> capacities;
|
if (properties.capacities_size()) {
|
||||||
for (int k = 0; k < properties.capacities_size(); k++) {
|
list<uint64_t> capacities = { properties.capacities().begin(), properties.capacities().end() };
|
||||||
capacities.push_back(properties.capacities(k));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!capacities.empty()) {
|
|
||||||
capacities.sort([](const auto& a, const auto& b) { return a < b; });
|
capacities.sort([](const auto& a, const auto& b) { return a < b; });
|
||||||
|
|
||||||
cout << " Media capacities in bytes: ";
|
cout << " Media capacities in bytes: ";
|
||||||
@ -297,18 +288,15 @@ void CommandServerInfo(const string& hostname, int port)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "Attached devices:" << endl;
|
if (!serverInfo.devices().devices_size()) {
|
||||||
const PbDevices& devices = serverInfo.devices();
|
|
||||||
if (!devices.devices_size()) {
|
|
||||||
cout << "No devices attached" << endl;
|
cout << "No devices attached" << endl;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
list<PbDevice> sorted_devices;
|
list<PbDevice> sorted_devices = { serverInfo.devices().devices().begin(), serverInfo.devices().devices().end() };
|
||||||
for (int i = 0; i < devices.devices_size(); i++) {
|
|
||||||
sorted_devices.push_back(devices.devices(i));
|
|
||||||
}
|
|
||||||
sorted_devices.sort([](const PbDevice& a, const PbDevice& b) { return a.id() < b.id(); });
|
sorted_devices.sort([](const PbDevice& a, const PbDevice& b) { return a.id() < b.id(); });
|
||||||
|
|
||||||
|
cout << "Attached devices:" << endl;
|
||||||
|
|
||||||
for (const auto& device : sorted_devices) {
|
for (const auto& device : sorted_devices) {
|
||||||
cout << " " << device.id() << ":" << device.unit() << " " << PbDeviceType_Name(device.type())
|
cout << " " << device.id() << ":" << device.unit() << " " << PbDeviceType_Name(device.type())
|
||||||
<< " " << device.vendor() << ":" << device.product() << ":" << device.revision();
|
<< " " << device.vendor() << ":" << device.product() << ":" << device.revision();
|
||||||
|
Loading…
Reference in New Issue
Block a user