From 71a87f8f41c191f4144a556f9158f17640cd5ad6 Mon Sep 17 00:00:00 2001 From: Alexander Batischev Date: Wed, 2 Oct 2024 20:56:15 +0300 Subject: Remove some implicit Filepath conversions from {File,Dir}BrowserFormAction --- src/filebrowserformaction.cpp | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'src/filebrowserformaction.cpp') diff --git a/src/filebrowserformaction.cpp b/src/filebrowserformaction.cpp index a91f4992..f55debf7 100644 --- a/src/filebrowserformaction.cpp +++ b/src/filebrowserformaction.cpp @@ -61,35 +61,20 @@ bool FileBrowserFormAction::process_operation(Operation op, selection.name, status); files_list.set_position(0); - std::string fn = utils::getcwd(); + auto fn = utils::getcwd(); update_title(fn); - if (fn.back() != NEWSBEUTER_PATH_SEP) { - fn.push_back(NEWSBEUTER_PATH_SEP); + const auto fnstr = Filepath::from_locale_string(f.get("filenametext")).file_name(); + if (fnstr) { + fn.push(*fnstr); } - - const std::string fnstr = - f.get("filenametext"); - const std::string::size_type base = - fnstr.find_last_of(NEWSBEUTER_PATH_SEP); - if (base == std::string::npos) { - fn.append(fnstr); - } else { - fn.append(fnstr, - base + 1, - std::string::npos); - } - set_value("filenametext", fn); + set_value("filenametext", fn.to_locale_string()); do_redraw = true; } break; case file_system::FileType::RegularFile: { - std::string fn = utils::getcwd(); - if (fn.back() != NEWSBEUTER_PATH_SEP) { - fn.push_back(NEWSBEUTER_PATH_SEP); - } - fn.append(selection.name); - set_value("filenametext", fn); + const auto filename = utils::getcwd().join(selection.name); + set_value("filenametext", filename.to_locale_string()); f.set_focus("filename"); } break; -- cgit v1.2.3