mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-23 06:30:04 +00:00
Sort devices list by ID *and unit*
This commit is contained in:
parent
665ad92b2c
commit
5ed6673429
@ -593,11 +593,10 @@ void GetDeviceTypeFeatures(PbServerInfo& serverInfo)
|
||||
|
||||
void GetAvailableImages(PbServerInfo& serverInfo)
|
||||
{
|
||||
if (access(default_image_folder.c_str(), F_OK) != -1) {
|
||||
if (!access(default_image_folder.c_str(), F_OK)) {
|
||||
for (const auto& entry : filesystem::directory_iterator(default_image_folder)) {
|
||||
if (entry.is_regular_file()) {
|
||||
PbImageFile *image_file = serverInfo.add_image_files();
|
||||
GetImageFile(image_file, entry.path().filename());
|
||||
GetImageFile(serverInfo.add_image_files(), entry.path().filename());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ void CommandServerInfo(const string& hostname, int port)
|
||||
}
|
||||
else {
|
||||
list<PbImageFile> files = { serverInfo.image_files().begin(), serverInfo.image_files().end() };
|
||||
files.sort([](const PbImageFile& a, const PbImageFile& b) { return a.name() < b.name(); });
|
||||
files.sort([](const auto& a, const auto& b) { return a.name() < b.name(); });
|
||||
|
||||
cout << "Available image files:" << endl;
|
||||
for (const auto& file : files) {
|
||||
@ -293,7 +293,7 @@ void CommandServerInfo(const string& hostname, int port)
|
||||
}
|
||||
else {
|
||||
list<PbDevice> sorted_devices = { serverInfo.devices().devices().begin(), serverInfo.devices().devices().end() };
|
||||
sorted_devices.sort([](const PbDevice& a, const PbDevice& b) { return a.id() < b.id(); });
|
||||
sorted_devices.sort([](const auto& a, const auto& b) { return a.id() < b.id(); });
|
||||
|
||||
cout << "Attached devices:" << endl;
|
||||
|
||||
|
@ -33,11 +33,8 @@ string ListDevices(const PbDevices& devices)
|
||||
return "No images currently attached.";
|
||||
}
|
||||
|
||||
list<PbDevice> sorted_devices;
|
||||
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(); });
|
||||
list<PbDevice> sorted_devices = { devices.devices().begin(), devices.devices().end() };
|
||||
sorted_devices.sort([](const PbDevice& a, const PbDevice& b) { return a.id() < b.id() && a.unit() < b.unit(); });
|
||||
|
||||
for (const auto& device : sorted_devices) {
|
||||
string filename;
|
||||
|
Loading…
Reference in New Issue
Block a user