Merge pull request #906 from zxkmm/fix_fileman_refactor

fix last commit aka fileman refactor exception
This commit is contained in:
jLynx 2023-04-23 19:12:40 +12:00 committed by GitHub
commit cd1f1bd388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 22 deletions

View File

@ -268,17 +268,21 @@ void FileManagerView::on_refactor(NavigationView& nav) {
if (destination_path.back() != '/') if (destination_path.back() != '/')
destination_path += '/'; destination_path += '/';
destination_path = destination_path + buffer; destination_path = destination_path + buffer;
rename_file(get_selected_path(), destination_path); //rename the selected file rename_file(get_selected_path(), destination_path); //rename the selected file
if (get_selected_path().extension().string().substr(1) == "C16") {//rename it's partner ( C16 <-> TXT ) file.
auto selected_path = get_selected_path(); auto selected_path = get_selected_path();
auto partner_file_path = selected_path.string().substr(0, selected_path.string().size()-4) + ".TXT"; auto extension = selected_path.extension().string();
destination_path = destination_path.substr(0, destination_path.size()-4) + ".TXT";
if (!extension.empty() && selected_path.string().back() != '/' && extension.substr(1) == "C16") {
// Rename its partner ( C16 <-> TXT ) file.
auto partner_file_path = selected_path.string().substr(0, selected_path.string().size() - 4) + ".TXT";
destination_path = destination_path.substr(0, destination_path.size() - 4) + ".TXT";
rename_file(partner_file_path, destination_path); rename_file(partner_file_path, destination_path);
}else if (get_selected_path().extension().string().substr(1) == "TXT") {//If the file user choose is a TXT file } else if (!extension.empty() && selected_path.string().back() != '/' && extension.substr(1) == "TXT") {
auto selected_path = get_selected_path(); // If the file user choose is a TXT file.
auto partner_file_path = selected_path.string().substr(0, selected_path.string().size()-4) + ".C16"; auto partner_file_path = selected_path.string().substr(0, selected_path.string().size() - 4) + ".C16";
destination_path = destination_path.substr(0, destination_path.size()-4) + ".C16"; destination_path = destination_path.substr(0, destination_path.size() - 4) + ".C16";
rename_file(partner_file_path, destination_path); rename_file(partner_file_path, destination_path);
} }

View File

@ -159,7 +159,7 @@ private:
}; };
Button button_rename { Button button_rename {
{ 0 * 8, 29 * 8, 10 * 8, 32 }, { 0 * 8, 29 * 8, 9 * 8, 32 },
"Rename" "Rename"
}; };
@ -169,7 +169,7 @@ private:
}; };
Button button_delete { Button button_delete {
{ 20 * 8, 29 * 8, 10 * 8, 32 }, { 21 * 8, 29 * 8, 9 * 8, 32 },
"Delete" "Delete"
}; };