mirror of
https://github.com/akuker/RASCSI.git
synced 2025-08-15 08:27:34 +00:00
Fixed filename size handling
This commit is contained in:
@@ -257,10 +257,12 @@ void GetImageFile(PbImageFile *image_file, const string& filename)
|
|||||||
{
|
{
|
||||||
image_file->set_name(filename);
|
image_file->set_name(filename);
|
||||||
if (!filename.empty()) {
|
if (!filename.empty()) {
|
||||||
image_file->set_read_only(access(filename.c_str(), W_OK));
|
string f = filename[0] == '/' ? filename : default_image_folder + "/" + filename;
|
||||||
|
|
||||||
|
image_file->set_read_only(access(f.c_str(), W_OK));
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
stat(filename.c_str(), &st);
|
stat(f.c_str(), &st);
|
||||||
image_file->set_size(st.st_size);
|
image_file->set_size(st.st_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -192,15 +192,16 @@ void CommandServerInfo(const string& hostname, int port)
|
|||||||
cout << " No image files available in the default folder" << endl;
|
cout << " No image files available in the default folder" << endl;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
list<string> sorted_files;
|
list<PbImageFile> sorted_files;
|
||||||
for (int i = 0; i < serverInfo.available_image_files_size(); i++) {
|
for (int i = 0; i < serverInfo.available_image_files_size(); i++) {
|
||||||
sorted_files.push_back(serverInfo.available_image_files(i).name());
|
sorted_files.push_back(serverInfo.available_image_files(i));
|
||||||
}
|
}
|
||||||
sorted_files.sort();
|
sorted_files.sort([](const PbImageFile& a, const PbImageFile& b) { return a.name() < b.name(); });
|
||||||
|
|
||||||
cout << "Image files available in the default folder:" << endl;
|
cout << "Image files available in the default folder:" << endl;
|
||||||
for (auto it = sorted_files.begin(); it != sorted_files.end(); ++it) {
|
for (auto it = sorted_files.begin(); it != sorted_files.end(); ++it) {
|
||||||
cout << " " << *it << endl;
|
cout << " " << (*it).name() << " (" << (*it).size() << " bytes)" << ((*it).read_only() ? ", read only": "")
|
||||||
|
<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user