1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16:27:35 +00:00

AK+Everywhere: Rename String to DeprecatedString

We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
This commit is contained in:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -27,7 +27,7 @@
namespace FileManager {
void spawn_terminal(String const& directory)
void spawn_terminal(DeprecatedString const& directory)
{
posix_spawn_file_actions_t spawn_actions;
posix_spawn_file_actions_init(&spawn_actions);
@ -86,7 +86,7 @@ NonnullRefPtrVector<LauncherHandler> DirectoryView::get_launch_handlers(URL cons
return handlers;
}
NonnullRefPtrVector<LauncherHandler> DirectoryView::get_launch_handlers(String const& path)
NonnullRefPtrVector<LauncherHandler> DirectoryView::get_launch_handlers(DeprecatedString const& path)
{
return get_launch_handlers(URL::create_with_file_scheme(path));
}
@ -120,11 +120,11 @@ void DirectoryView::handle_activation(GUI::ModelIndex const& index)
if (default_launcher) {
auto launch_origin_rect = current_view().to_widget_rect(current_view().content_rect(index)).translated(current_view().screen_relative_rect().location());
setenv("__libgui_launch_origin_rect", String::formatted("{},{},{},{}", launch_origin_rect.x(), launch_origin_rect.y(), launch_origin_rect.width(), launch_origin_rect.height()).characters(), 1);
setenv("__libgui_launch_origin_rect", DeprecatedString::formatted("{},{},{},{}", launch_origin_rect.x(), launch_origin_rect.y(), launch_origin_rect.width(), launch_origin_rect.height()).characters(), 1);
launch(url, *default_launcher);
unsetenv("__libgui_launch_origin_rect");
} else {
auto error_message = String::formatted("Could not open {}", path);
auto error_message = DeprecatedString::formatted("Could not open {}", path);
GUI::MessageBox::show(window(), error_message, "File Manager"sv, GUI::MessageBox::Type::Error);
}
}
@ -162,7 +162,7 @@ void DirectoryView::setup_model()
{
m_model->on_directory_change_error = [this](int, char const* error_string) {
auto failed_path = m_model->root_path();
auto error_message = String::formatted("Could not read {}:\n{}", failed_path, error_string);
auto error_message = DeprecatedString::formatted("Could not read {}:\n{}", failed_path, error_string);
m_error_label->set_text(error_message);
set_active_widget(m_error_label);
@ -176,7 +176,7 @@ void DirectoryView::setup_model()
};
m_model->on_rename_error = [this](int, char const* error_string) {
GUI::MessageBox::show_error(window(), String::formatted("Unable to rename file: {}", error_string));
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Unable to rename file: {}", error_string));
};
m_model->on_complete = [this] {
@ -340,7 +340,7 @@ void DirectoryView::model_did_update(unsigned flags)
update_statusbar();
}
void DirectoryView::set_view_mode_from_string(String const& mode)
void DirectoryView::set_view_mode_from_string(DeprecatedString const& mode)
{
if (m_mode == Mode::Desktop)
return;
@ -357,7 +357,7 @@ void DirectoryView::set_view_mode_from_string(String const& mode)
}
}
void DirectoryView::config_string_did_change(String const& domain, String const& group, String const& key, String const& value)
void DirectoryView::config_string_did_change(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value)
{
if (domain != "FileManager" || group != "DirectoryView")
return;
@ -389,7 +389,7 @@ void DirectoryView::set_view_mode(ViewMode mode)
VERIFY_NOT_REACHED();
}
void DirectoryView::add_path_to_history(String path)
void DirectoryView::add_path_to_history(DeprecatedString path)
{
if (m_path_history.size() && m_path_history.at(m_path_history_position) == path)
return;
@ -401,7 +401,7 @@ void DirectoryView::add_path_to_history(String path)
m_path_history_position = m_path_history.size() - 1;
}
bool DirectoryView::open(String const& path)
bool DirectoryView::open(DeprecatedString const& path)
{
auto real_path = Core::File::real_path_for(path);
if (real_path.is_null() || !Core::File::is_directory(path))
@ -525,9 +525,9 @@ void DirectoryView::launch(URL const&, LauncherHandler const& launcher_handler)
}
}
Vector<String> DirectoryView::selected_file_paths() const
Vector<DeprecatedString> DirectoryView::selected_file_paths() const
{
Vector<String> paths;
Vector<DeprecatedString> paths;
auto& view = current_view();
auto& model = *view.model();
view.selection().for_each_index([&](GUI::ModelIndex const& index) {
@ -567,36 +567,36 @@ void DirectoryView::handle_selection_change()
void DirectoryView::setup_actions()
{
m_mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
String value;
DeprecatedString value;
if (GUI::InputBox::show(window(), value, "Enter name:"sv, "New directory"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) {
auto new_dir_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", path(), value));
auto new_dir_path = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", path(), value));
int rc = mkdir(new_dir_path.characters(), 0777);
if (rc < 0) {
auto saved_errno = errno;
GUI::MessageBox::show(window(), String::formatted("mkdir(\"{}\") failed: {}", new_dir_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), DeprecatedString::formatted("mkdir(\"{}\") failed: {}", new_dir_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error);
}
}
});
m_touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
String value;
DeprecatedString value;
if (GUI::InputBox::show(window(), value, "Enter name:"sv, "New file"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) {
auto new_file_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", path(), value));
auto new_file_path = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", path(), value));
struct stat st;
int rc = stat(new_file_path.characters(), &st);
if ((rc < 0 && errno != ENOENT)) {
auto saved_errno = errno;
GUI::MessageBox::show(window(), String::formatted("stat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), DeprecatedString::formatted("stat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error);
return;
}
if (rc == 0) {
GUI::MessageBox::show(window(), String::formatted("{}: Already exists", new_file_path), "Error"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), DeprecatedString::formatted("{}: Already exists", new_file_path), "Error"sv, GUI::MessageBox::Type::Error);
return;
}
int fd = creat(new_file_path.characters(), 0666);
if (fd < 0) {
auto saved_errno = errno;
GUI::MessageBox::show(window(), String::formatted("creat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), DeprecatedString::formatted("creat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error);
return;
}
rc = close(fd);
@ -663,11 +663,11 @@ void DirectoryView::handle_drop(GUI::ModelIndex const& index, GUI::DropEvent con
return;
bool had_accepted_drop = false;
Vector<String> paths_to_copy;
Vector<DeprecatedString> paths_to_copy;
for (auto& url_to_copy : urls) {
if (!url_to_copy.is_valid() || url_to_copy.path() == target_node.full_path())
continue;
auto new_path = String::formatted("{}/{}", target_node.full_path(), LexicalPath::basename(url_to_copy.path()));
auto new_path = DeprecatedString::formatted("{}/{}", target_node.full_path(), LexicalPath::basename(url_to_copy.path()));
if (url_to_copy.path() == new_path)
continue;

View file

@ -21,7 +21,7 @@
namespace FileManager {
void spawn_terminal(String const& directory);
void spawn_terminal(DeprecatedString const& directory);
class LauncherHandler : public RefCounted<LauncherHandler> {
public:
@ -51,8 +51,8 @@ public:
virtual ~DirectoryView() override;
bool open(String const& path);
String path() const { return model().root_path(); }
bool open(DeprecatedString const& path);
DeprecatedString path() const { return model().root_path(); }
void open_parent_directory();
void open_previous_directory();
void open_next_directory();
@ -60,7 +60,7 @@ public:
int path_history_position() const { return m_path_history_position; }
static RefPtr<LauncherHandler> get_default_launch_handler(NonnullRefPtrVector<LauncherHandler> const& handlers);
static NonnullRefPtrVector<LauncherHandler> get_launch_handlers(URL const& url);
static NonnullRefPtrVector<LauncherHandler> get_launch_handlers(String const& path);
static NonnullRefPtrVector<LauncherHandler> get_launch_handlers(DeprecatedString const& path);
void refresh();
@ -82,7 +82,7 @@ public:
void set_view_mode(ViewMode);
ViewMode view_mode() const { return m_view_mode; }
void set_view_mode_from_string(String const&);
void set_view_mode_from_string(DeprecatedString const&);
GUI::AbstractView& current_view()
{
@ -120,7 +120,7 @@ public:
bool is_desktop() const { return m_mode == Mode::Desktop; }
Vector<String> selected_file_paths() const;
Vector<DeprecatedString> selected_file_paths() const;
GUI::Action& mkdir_action() { return *m_mkdir_action; }
GUI::Action& touch_action() { return *m_touch_action; }
@ -133,7 +133,7 @@ public:
GUI::Action& view_as_columns_action() { return *m_view_as_columns_action; }
// ^Config::Listener
virtual void config_string_did_change(String const& domain, String const& group, String const& key, String const& value) override;
virtual void config_string_did_change(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value) override;
private:
explicit DirectoryView(Mode);
@ -166,8 +166,8 @@ private:
NonnullRefPtr<GUI::FileSystemModel> m_model;
NonnullRefPtr<GUI::SortingProxyModel> m_sorting_model;
size_t m_path_history_position { 0 };
Vector<String> m_path_history;
void add_path_to_history(String);
Vector<DeprecatedString> m_path_history;
void add_path_to_history(DeprecatedString);
RefPtr<GUI::Label> m_error_label;

View file

@ -129,11 +129,11 @@ void FileOperationProgressWidget::did_error(StringView message)
{
// FIXME: Communicate more with the user about errors.
close_pipe();
GUI::MessageBox::show(window(), String::formatted("An error occurred: {}", message), "Error"sv, GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK);
GUI::MessageBox::show(window(), DeprecatedString::formatted("An error occurred: {}", message), "Error"sv, GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK);
window()->close();
}
String FileOperationProgressWidget::estimate_time(off_t bytes_done, off_t total_byte_count)
DeprecatedString FileOperationProgressWidget::estimate_time(off_t bytes_done, off_t total_byte_count)
{
int elapsed = m_elapsed_timer.elapsed() / 1000;
@ -144,7 +144,7 @@ String FileOperationProgressWidget::estimate_time(off_t bytes_done, off_t total_
int seconds_remaining = (bytes_left * elapsed) / bytes_done;
if (seconds_remaining < 30)
return String::formatted("{} seconds", 5 + seconds_remaining - seconds_remaining % 5);
return DeprecatedString::formatted("{} seconds", 5 + seconds_remaining - seconds_remaining % 5);
if (seconds_remaining < 60)
return "About a minute";
if (seconds_remaining < 90)
@ -157,14 +157,14 @@ String FileOperationProgressWidget::estimate_time(off_t bytes_done, off_t total_
if (minutes_remaining < 60) {
if (seconds_remaining < 30)
return String::formatted("About {} minutes", minutes_remaining);
return String::formatted("Over {} minutes", minutes_remaining);
return DeprecatedString::formatted("About {} minutes", minutes_remaining);
return DeprecatedString::formatted("Over {} minutes", minutes_remaining);
}
time_t hours_remaining = minutes_remaining / 60;
minutes_remaining %= 60;
return String::formatted("{} hours and {} minutes", hours_remaining, minutes_remaining);
return DeprecatedString::formatted("{} hours and {} minutes", hours_remaining, minutes_remaining);
}
void FileOperationProgressWidget::did_progress(off_t bytes_done, off_t total_byte_count, size_t files_done, size_t total_file_count, [[maybe_unused]] off_t current_file_done, [[maybe_unused]] off_t current_file_size, StringView current_filename)
@ -178,13 +178,13 @@ void FileOperationProgressWidget::did_progress(off_t bytes_done, off_t total_byt
switch (m_operation) {
case FileOperation::Copy:
files_copied_label.set_text(String::formatted("Copying file {} of {}", files_done, total_file_count));
files_copied_label.set_text(DeprecatedString::formatted("Copying file {} of {}", files_done, total_file_count));
break;
case FileOperation::Move:
files_copied_label.set_text(String::formatted("Moving file {} of {}", files_done, total_file_count));
files_copied_label.set_text(DeprecatedString::formatted("Moving file {} of {}", files_done, total_file_count));
break;
case FileOperation::Delete:
files_copied_label.set_text(String::formatted("Deleting file {} of {}", files_done, total_file_count));
files_copied_label.set_text(DeprecatedString::formatted("Deleting file {} of {}", files_done, total_file_count));
break;
default:
VERIFY_NOT_REACHED();

View file

@ -29,7 +29,7 @@ private:
void close_pipe();
String estimate_time(off_t bytes_done, off_t total_byte_count);
DeprecatedString estimate_time(off_t bytes_done, off_t total_byte_count);
Core::ElapsedTimer m_elapsed_timer;
FileOperation m_operation;

View file

@ -17,13 +17,13 @@ namespace FileManager {
HashTable<NonnullRefPtr<GUI::Window>> file_operation_windows;
void delete_paths(Vector<String> const& paths, bool should_confirm, GUI::Window* parent_window)
void delete_paths(Vector<DeprecatedString> const& paths, bool should_confirm, GUI::Window* parent_window)
{
String message;
DeprecatedString message;
if (paths.size() == 1) {
message = String::formatted("Are you sure you want to delete {}?", LexicalPath::basename(paths[0]));
message = DeprecatedString::formatted("Are you sure you want to delete {}?", LexicalPath::basename(paths[0]));
} else {
message = String::formatted("Are you sure you want to delete {} files?", paths.size());
message = DeprecatedString::formatted("Are you sure you want to delete {} files?", paths.size());
}
if (should_confirm) {
@ -40,7 +40,7 @@ void delete_paths(Vector<String> const& paths, bool should_confirm, GUI::Window*
_exit(1);
}
ErrorOr<void> run_file_operation(FileOperation operation, Vector<String> const& sources, String const& destination, GUI::Window* parent_window)
ErrorOr<void> run_file_operation(FileOperation operation, Vector<DeprecatedString> const& sources, DeprecatedString const& destination, GUI::Window* parent_window)
{
auto pipe_fds = TRY(Core::System::pipe2(0));

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <LibCore/Forward.h>
#include <LibGUI/Forward.h>
@ -19,7 +19,7 @@ enum class FileOperation {
Delete,
};
void delete_paths(Vector<String> const&, bool should_confirm, GUI::Window*);
void delete_paths(Vector<DeprecatedString> const&, bool should_confirm, GUI::Window*);
ErrorOr<void> run_file_operation(FileOperation, Vector<String> const& sources, String const& destination, GUI::Window*);
ErrorOr<void> run_file_operation(FileOperation, Vector<DeprecatedString> const& sources, DeprecatedString const& destination, GUI::Window*);
}

View file

@ -26,7 +26,7 @@
#include <string.h>
#include <unistd.h>
PropertiesWindow::PropertiesWindow(String const& path, bool disable_rename, Window* parent_window)
PropertiesWindow::PropertiesWindow(DeprecatedString const& path, bool disable_rename, Window* parent_window)
: Window(parent_window)
{
auto lexical_path = LexicalPath(path);
@ -67,8 +67,8 @@ PropertiesWindow::PropertiesWindow(String const& path, bool disable_rename, Wind
return;
}
String owner_name;
String group_name;
DeprecatedString owner_name;
DeprecatedString group_name;
if (auto* pw = getpwuid(st.st_uid)) {
owner_name = pw->pw_name;
@ -116,10 +116,10 @@ PropertiesWindow::PropertiesWindow(String const& path, bool disable_rename, Wind
size->set_text(human_readable_size_long(st.st_size));
auto owner = general_tab.find_descendant_of_type_named<GUI::Label>("owner");
owner->set_text(String::formatted("{} ({})", owner_name, st.st_uid));
owner->set_text(DeprecatedString::formatted("{} ({})", owner_name, st.st_uid));
auto group = general_tab.find_descendant_of_type_named<GUI::Label>("group");
group->set_text(String::formatted("{} ({})", group_name, st.st_gid));
group->set_text(DeprecatedString::formatted("{} ({})", group_name, st.st_gid));
auto created_at = general_tab.find_descendant_of_type_named<GUI::Label>("created_at");
created_at->set_text(GUI::FileSystemModel::timestamp_string(st.st_ctime));
@ -167,7 +167,7 @@ PropertiesWindow::PropertiesWindow(String const& path, bool disable_rename, Wind
void PropertiesWindow::update()
{
m_icon->set_bitmap(GUI::FileIconProvider::icon_for_path(make_full_path(m_name), m_mode).bitmap_for_size(32));
set_title(String::formatted("{} - Properties", m_name));
set_title(DeprecatedString::formatted("{} - Properties", m_name));
}
void PropertiesWindow::permission_changed(mode_t mask, bool set)
@ -182,24 +182,24 @@ void PropertiesWindow::permission_changed(mode_t mask, bool set)
m_apply_button->set_enabled(m_name_dirty || m_permissions_dirty);
}
String PropertiesWindow::make_full_path(String const& name)
DeprecatedString PropertiesWindow::make_full_path(DeprecatedString const& name)
{
return String::formatted("{}/{}", m_parent_path, name);
return DeprecatedString::formatted("{}/{}", m_parent_path, name);
}
bool PropertiesWindow::apply_changes()
{
if (m_name_dirty) {
String new_name = m_name_box->text();
String new_file = make_full_path(new_name).characters();
DeprecatedString new_name = m_name_box->text();
DeprecatedString new_file = make_full_path(new_name).characters();
if (Core::File::exists(new_file)) {
GUI::MessageBox::show(this, String::formatted("A file \"{}\" already exists!", new_name), "Error"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(this, DeprecatedString::formatted("A file \"{}\" already exists!", new_name), "Error"sv, GUI::MessageBox::Type::Error);
return false;
}
if (rename(make_full_path(m_name).characters(), new_file.characters())) {
GUI::MessageBox::show(this, String::formatted("Could not rename file: {}!", strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(this, DeprecatedString::formatted("Could not rename file: {}!", strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error);
return false;
}
@ -210,7 +210,7 @@ bool PropertiesWindow::apply_changes()
if (m_permissions_dirty) {
if (chmod(make_full_path(m_name).characters(), m_mode)) {
GUI::MessageBox::show(this, String::formatted("Could not update permissions: {}!", strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(this, DeprecatedString::formatted("Could not update permissions: {}!", strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error);
return false;
}
@ -249,7 +249,7 @@ void PropertiesWindow::setup_permission_checkboxes(GUI::CheckBox& box_read, GUI:
box_execute.set_enabled(can_edit_checkboxes);
}
GUI::Button& PropertiesWindow::make_button(String text, GUI::Widget& parent)
GUI::Button& PropertiesWindow::make_button(DeprecatedString text, GUI::Widget& parent)
{
auto& button = parent.add<GUI::Button>(text);
button.set_fixed_size(70, 22);

View file

@ -22,11 +22,11 @@ public:
virtual ~PropertiesWindow() override = default;
private:
PropertiesWindow(String const& path, bool disable_rename, Window* parent = nullptr);
PropertiesWindow(DeprecatedString const& path, bool disable_rename, Window* parent = nullptr);
struct PropertyValuePair {
String property;
String value;
DeprecatedString property;
DeprecatedString value;
Optional<URL> link = {};
};
@ -36,7 +36,7 @@ private:
mode_t execute;
};
static String const get_description(mode_t const mode)
static DeprecatedString const get_description(mode_t const mode)
{
if (S_ISREG(mode))
return "File";
@ -58,19 +58,19 @@ private:
return "Unknown";
}
GUI::Button& make_button(String, GUI::Widget& parent);
GUI::Button& make_button(DeprecatedString, GUI::Widget& parent);
void setup_permission_checkboxes(GUI::CheckBox& box_read, GUI::CheckBox& box_write, GUI::CheckBox& box_execute, PermissionMasks masks, mode_t mode);
void permission_changed(mode_t mask, bool set);
bool apply_changes();
void update();
String make_full_path(String const& name);
DeprecatedString make_full_path(DeprecatedString const& name);
RefPtr<GUI::Button> m_apply_button;
RefPtr<GUI::TextBox> m_name_box;
RefPtr<GUI::ImageWidget> m_icon;
String m_name;
String m_parent_path;
String m_path;
DeprecatedString m_name;
DeprecatedString m_parent_path;
DeprecatedString m_path;
mode_t m_mode { 0 };
mode_t m_old_mode { 0 };
bool m_permissions_dirty { false };

View file

@ -56,15 +56,15 @@
using namespace FileManager;
static ErrorOr<int> run_in_desktop_mode();
static ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& entry_focused_on_init);
static void do_copy(Vector<String> const& selected_file_paths, FileOperation file_operation);
static void do_paste(String const& target_directory, GUI::Window* window);
static void do_create_link(Vector<String> const& selected_file_paths, GUI::Window* window);
static void do_create_archive(Vector<String> const& selected_file_paths, GUI::Window* window);
static void do_set_wallpaper(String const& file_path, GUI::Window* window);
static void do_unzip_archive(Vector<String> const& selected_file_paths, GUI::Window* window);
static void show_properties(String const& container_dir_path, String const& path, Vector<String> const& selected, GUI::Window* window);
static bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, String const& full_path, RefPtr<GUI::Action>& default_action, NonnullRefPtrVector<LauncherHandler>& current_file_launch_handlers);
static ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, DeprecatedString const& entry_focused_on_init);
static void do_copy(Vector<DeprecatedString> const& selected_file_paths, FileOperation file_operation);
static void do_paste(DeprecatedString const& target_directory, GUI::Window* window);
static void do_create_link(Vector<DeprecatedString> const& selected_file_paths, GUI::Window* window);
static void do_create_archive(Vector<DeprecatedString> const& selected_file_paths, GUI::Window* window);
static void do_set_wallpaper(DeprecatedString const& file_path, GUI::Window* window);
static void do_unzip_archive(Vector<DeprecatedString> const& selected_file_paths, GUI::Window* window);
static void show_properties(DeprecatedString const& container_dir_path, DeprecatedString const& path, Vector<DeprecatedString> const& selected, GUI::Window* window);
static bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr<GUI::Action>& default_action, NonnullRefPtrVector<LauncherHandler>& current_file_launch_handlers);
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
@ -79,7 +79,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
bool is_desktop_mode { false };
bool is_selection_mode { false };
bool ignore_path_resolution { false };
String initial_location;
DeprecatedString initial_location;
args_parser.add_option(is_desktop_mode, "Run in desktop mode", "desktop", 'd');
args_parser.add_option(is_selection_mode, "Show entry in parent folder", "select", 's');
args_parser.add_option(ignore_path_resolution, "Use raw path, do not resolve real path", "raw", 'r');
@ -120,7 +120,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (initial_location.is_empty())
initial_location = "/";
String focused_entry;
DeprecatedString focused_entry;
if (is_selection_mode) {
LexicalPath path(initial_location);
initial_location = path.dirname();
@ -130,7 +130,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return run_in_windowed_mode(initial_location, focused_entry);
}
void do_copy(Vector<String> const& selected_file_paths, FileOperation file_operation)
void do_copy(Vector<DeprecatedString> const& selected_file_paths, FileOperation file_operation)
{
VERIFY(!selected_file_paths.is_empty());
@ -145,14 +145,14 @@ void do_copy(Vector<String> const& selected_file_paths, FileOperation file_opera
GUI::Clipboard::the().set_data(copy_text.build().bytes(), "text/uri-list");
}
void do_paste(String const& target_directory, GUI::Window* window)
void do_paste(DeprecatedString const& target_directory, GUI::Window* window)
{
auto data_and_type = GUI::Clipboard::the().fetch_data_and_type();
if (data_and_type.mime_type != "text/uri-list") {
dbgln("Cannot paste clipboard type {}", data_and_type.mime_type);
return;
}
auto copied_lines = String::copy(data_and_type.data).split('\n');
auto copied_lines = DeprecatedString::copy(data_and_type.data).split('\n');
if (copied_lines.is_empty()) {
dbgln("No files to paste");
return;
@ -164,7 +164,7 @@ void do_paste(String const& target_directory, GUI::Window* window)
copied_lines.remove(0);
}
Vector<String> source_paths;
Vector<DeprecatedString> source_paths;
for (auto& uri_as_string : copied_lines) {
if (uri_as_string.is_empty())
continue;
@ -182,19 +182,19 @@ void do_paste(String const& target_directory, GUI::Window* window)
}
}
void do_create_link(Vector<String> const& selected_file_paths, GUI::Window* window)
void do_create_link(Vector<DeprecatedString> const& selected_file_paths, GUI::Window* window)
{
auto path = selected_file_paths.first();
auto destination = String::formatted("{}/{}", Core::StandardPaths::desktop_directory(), LexicalPath::basename(path));
auto destination = DeprecatedString::formatted("{}/{}", Core::StandardPaths::desktop_directory(), LexicalPath::basename(path));
if (auto result = Core::File::link_file(destination, path); result.is_error()) {
GUI::MessageBox::show(window, String::formatted("Could not create desktop shortcut:\n{}", result.error()), "File Manager"sv,
GUI::MessageBox::show(window, DeprecatedString::formatted("Could not create desktop shortcut:\n{}", result.error()), "File Manager"sv,
GUI::MessageBox::Type::Error);
}
}
void do_create_archive(Vector<String> const& selected_file_paths, GUI::Window* window)
void do_create_archive(Vector<DeprecatedString> const& selected_file_paths, GUI::Window* window)
{
String archive_name;
DeprecatedString archive_name;
if (GUI::InputBox::show(window, archive_name, "Enter name:"sv, "Create Archive"sv) != GUI::InputBox::ExecResult::OK)
return;
@ -220,7 +220,7 @@ void do_create_archive(Vector<String> const& selected_file_paths, GUI::Window* w
}
if (!zip_pid) {
Vector<String> relative_paths;
Vector<DeprecatedString> relative_paths;
Vector<char const*> arg_list;
arg_list.append("/bin/zip");
arg_list.append("-r");
@ -244,10 +244,10 @@ void do_create_archive(Vector<String> const& selected_file_paths, GUI::Window* w
}
}
void do_set_wallpaper(String const& file_path, GUI::Window* window)
void do_set_wallpaper(DeprecatedString const& file_path, GUI::Window* window)
{
auto show_error = [&] {
GUI::MessageBox::show(window, String::formatted("Failed to set {} as wallpaper.", file_path), "Failed to set wallpaper"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window, DeprecatedString::formatted("Failed to set {} as wallpaper.", file_path), "Failed to set wallpaper"sv, GUI::MessageBox::Type::Error);
};
auto bitmap_or_error = Gfx::Bitmap::try_load_from_file(file_path);
@ -260,10 +260,10 @@ void do_set_wallpaper(String const& file_path, GUI::Window* window)
show_error();
}
void do_unzip_archive(Vector<String> const& selected_file_paths, GUI::Window* window)
void do_unzip_archive(Vector<DeprecatedString> const& selected_file_paths, GUI::Window* window)
{
String archive_file_path = selected_file_paths.first();
String output_directory_path = archive_file_path.substring(0, archive_file_path.length() - 4);
DeprecatedString archive_file_path = selected_file_paths.first();
DeprecatedString output_directory_path = archive_file_path.substring(0, archive_file_path.length() - 4);
pid_t unzip_pid = fork();
if (unzip_pid < 0) {
@ -286,7 +286,7 @@ void do_unzip_archive(Vector<String> const& selected_file_paths, GUI::Window* wi
}
}
void show_properties(String const& container_dir_path, String const& path, Vector<String> const& selected, GUI::Window* window)
void show_properties(DeprecatedString const& container_dir_path, DeprecatedString const& path, Vector<DeprecatedString> const& selected, GUI::Window* window)
{
RefPtr<PropertiesWindow> properties;
if (selected.is_empty()) {
@ -301,7 +301,7 @@ void show_properties(String const& container_dir_path, String const& path, Vecto
properties->show();
}
bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, String const& full_path, RefPtr<GUI::Action>& default_action, NonnullRefPtrVector<LauncherHandler>& current_file_launch_handlers)
bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr<GUI::Action>& default_action, NonnullRefPtrVector<LauncherHandler>& current_file_launch_handlers)
{
current_file_launch_handlers = directory_view.get_launch_handlers(full_path);
@ -312,9 +312,9 @@ bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView c
directory_view.launch(URL::create_with_file_scheme(full_path), launcher_handler);
});
if (default_file_handler->details().launcher_type == Desktop::Launcher::LauncherType::Application)
file_open_action->set_text(String::formatted("Run {}", file_open_action->text()));
file_open_action->set_text(DeprecatedString::formatted("Run {}", file_open_action->text()));
else
file_open_action->set_text(String::formatted("Open in {}", file_open_action->text()));
file_open_action->set_text(DeprecatedString::formatted("Open in {}", file_open_action->text()));
default_action = file_open_action;
@ -421,8 +421,8 @@ ErrorOr<int> run_in_desktop_mode()
auto properties_action = GUI::CommonActions::make_properties_action(
[&](auto&) {
String path = directory_view->path();
Vector<String> selected = directory_view->selected_file_paths();
DeprecatedString path = directory_view->path();
Vector<DeprecatedString> selected = directory_view->selected_file_paths();
show_properties(path, path, selected, directory_view->window());
},
@ -435,7 +435,7 @@ ErrorOr<int> run_in_desktop_mode()
window);
paste_action->set_enabled(GUI::Clipboard::the().fetch_mime_type() == "text/uri-list" && access(directory_view->path().characters(), W_OK) == 0);
GUI::Clipboard::the().on_change = [&](String const& data_type) {
GUI::Clipboard::the().on_change = [&](DeprecatedString const& data_type) {
paste_action->set_enabled(data_type == "text/uri-list" && access(directory_view->path().characters(), W_OK) == 0);
};
@ -537,7 +537,7 @@ ErrorOr<int> run_in_desktop_mode()
};
struct BackgroundWallpaperListener : Config::Listener {
virtual void config_string_did_change(String const& domain, String const& group, String const& key, String const& value) override
virtual void config_string_did_change(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value) override
{
if (domain == "WindowManager" && group == "Background" && key == "Wallpaper") {
auto wallpaper_bitmap_or_error = Gfx::Bitmap::try_load_from_file(value);
@ -563,7 +563,7 @@ ErrorOr<int> run_in_desktop_mode()
return GUI::Application::the()->exec();
}
ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& entry_focused_on_init)
ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, DeprecatedString const& entry_focused_on_init)
{
auto window = TRY(GUI::Window::try_create());
window->set_title("File Manager");
@ -753,7 +753,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
view_type_action_group->add_action(directory_view->view_as_columns_action());
auto tree_view_selected_file_paths = [&] {
Vector<String> paths;
Vector<DeprecatedString> paths;
auto& view = tree_view;
view.selection().for_each_index([&](GUI::ModelIndex const& index) {
paths.append(directories_model->full_path(index));
@ -797,7 +797,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
{},
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png"sv).release_value_but_fixme_should_propagate_errors(),
[&](GUI::Action const& action) {
Vector<String> paths;
Vector<DeprecatedString> paths;
if (action.activator() == tree_view_directory_context_menu)
paths = tree_view_selected_file_paths();
else
@ -816,7 +816,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
{},
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"sv).release_value_but_fixme_should_propagate_errors(),
[&](GUI::Action const& action) {
Vector<String> paths;
Vector<DeprecatedString> paths;
if (action.activator() == tree_view_directory_context_menu)
paths = tree_view_selected_file_paths();
else
@ -886,9 +886,9 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
auto properties_action = GUI::CommonActions::make_properties_action(
[&](auto& action) {
String container_dir_path;
String path;
Vector<String> selected;
DeprecatedString container_dir_path;
DeprecatedString path;
Vector<DeprecatedString> selected;
if (action.activator() == directory_context_menu || directory_view->active_widget()->is_focused()) {
path = directory_view->path();
container_dir_path = path;
@ -905,7 +905,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
auto paste_action = GUI::CommonActions::make_paste_action(
[&](GUI::Action const& action) {
String target_directory;
DeprecatedString target_directory;
if (action.activator() == directory_context_menu)
target_directory = directory_view->selected_file_paths()[0];
else
@ -917,7 +917,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
auto folder_specific_paste_action = GUI::CommonActions::make_paste_action(
[&](GUI::Action const& action) {
String target_directory;
DeprecatedString target_directory;
if (action.activator() == directory_context_menu)
target_directory = directory_view->selected_file_paths()[0];
else
@ -945,7 +945,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
},
window);
GUI::Clipboard::the().on_change = [&](String const& data_type) {
GUI::Clipboard::the().on_change = [&](DeprecatedString const& data_type) {
auto current_location = directory_view->path();
paste_action->set_enabled(data_type == "text/uri-list" && access(current_location.characters(), W_OK) == 0);
};
@ -1090,13 +1090,13 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
}
};
directory_view->on_path_change = [&](String const& new_path, bool can_read_in_path, bool can_write_in_path) {
directory_view->on_path_change = [&](DeprecatedString const& new_path, bool can_read_in_path, bool can_write_in_path) {
auto icon = GUI::FileIconProvider::icon_for_path(new_path);
auto* bitmap = icon.bitmap_for_size(16);
window->set_icon(bitmap);
location_textbox.set_icon(bitmap);
window->set_title(String::formatted("{} - File Manager", new_path));
window->set_title(DeprecatedString::formatted("{} - File Manager", new_path));
location_textbox.set_text(new_path);
{
@ -1298,7 +1298,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
}
};
auto copy_urls_to_directory = [&](Vector<URL> const& urls, String const& directory) {
auto copy_urls_to_directory = [&](Vector<URL> const& urls, DeprecatedString const& directory) {
if (urls.is_empty()) {
dbgln("No files to copy");
return;
@ -1307,12 +1307,12 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
for (auto& url_to_copy : urls) {
if (!url_to_copy.is_valid() || url_to_copy.path() == directory)
continue;
auto new_path = String::formatted("{}/{}", directory, LexicalPath::basename(url_to_copy.path()));
auto new_path = DeprecatedString::formatted("{}/{}", directory, LexicalPath::basename(url_to_copy.path()));
if (url_to_copy.path() == new_path)
continue;
if (auto result = Core::File::copy_file_or_directory(url_to_copy.path(), new_path); result.is_error()) {
auto error_message = String::formatted("Could not copy {} into {}:\n {}", url_to_copy.to_string(), new_path, static_cast<Error const&>(result.error()));
auto error_message = DeprecatedString::formatted("Could not copy {} into {}:\n {}", url_to_copy.to_string(), new_path, static_cast<Error const&>(result.error()));
GUI::MessageBox::show(window, error_message, "File Manager"sv, GUI::MessageBox::Type::Error);
} else {
had_accepted_copy = true;