mirror of
https://github.com/akuker/RASCSI.git
synced 2025-01-11 09:29:53 +00:00
Fixed filename size handling
This commit is contained in:
parent
07c08945db
commit
3c40e6a188
@ -257,10 +257,12 @@ void GetImageFile(PbImageFile *image_file, const string& filename)
|
||||
{
|
||||
image_file->set_name(filename);
|
||||
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;
|
||||
stat(filename.c_str(), &st);
|
||||
stat(f.c_str(), &st);
|
||||
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;
|
||||
}
|
||||
else {
|
||||
list<string> sorted_files;
|
||||
list<PbImageFile> sorted_files;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user