mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:27:35 +00:00
Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -76,7 +76,7 @@ Vector<NonnullRefPtr<LauncherHandler>> DirectoryView::get_launch_handlers(URL co
|
|||
return handlers;
|
||||
}
|
||||
|
||||
Vector<NonnullRefPtr<LauncherHandler>> DirectoryView::get_launch_handlers(DeprecatedString const& path)
|
||||
Vector<NonnullRefPtr<LauncherHandler>> DirectoryView::get_launch_handlers(ByteString const& path)
|
||||
{
|
||||
return get_launch_handlers(URL::create_with_file_scheme(path));
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ void DirectoryView::handle_activation(GUI::ModelIndex const& index)
|
|||
struct stat st;
|
||||
if (stat(path.characters(), &st) < 0) {
|
||||
perror("stat");
|
||||
auto error_message = DeprecatedString::formatted("Could not stat {}: {}", path, strerror(errno));
|
||||
auto error_message = ByteString::formatted("Could not stat {}: {}", path, strerror(errno));
|
||||
GUI::MessageBox::show(window(), error_message, "File Manager"sv, GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
}
|
||||
|
@ -112,11 +112,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", DeprecatedString::formatted("{},{},{},{}", launch_origin_rect.x(), launch_origin_rect.y(), launch_origin_rect.width(), launch_origin_rect.height()).characters(), 1);
|
||||
setenv("__libgui_launch_origin_rect", ByteString::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 = DeprecatedString::formatted("Could not open {}", path);
|
||||
auto error_message = ByteString::formatted("Could not open {}", path);
|
||||
GUI::MessageBox::show(window(), error_message, "File Manager"sv, GUI::MessageBox::Type::Error);
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ void DirectoryView::setup_model()
|
|||
};
|
||||
|
||||
m_model->on_rename_error = [this](int, char const* error_string) {
|
||||
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Unable to rename file: {}", error_string));
|
||||
GUI::MessageBox::show_error(window(), ByteString::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(DeprecatedString const& mode)
|
||||
void DirectoryView::set_view_mode_from_string(ByteString const& mode)
|
||||
{
|
||||
if (m_mode == Mode::Desktop)
|
||||
return;
|
||||
|
@ -389,7 +389,7 @@ void DirectoryView::set_view_mode(ViewMode mode)
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
void DirectoryView::add_path_to_history(DeprecatedString path)
|
||||
void DirectoryView::add_path_to_history(ByteString 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(DeprecatedString path)
|
|||
m_path_history_position = m_path_history.size() - 1;
|
||||
}
|
||||
|
||||
bool DirectoryView::open(DeprecatedString const& path)
|
||||
bool DirectoryView::open(ByteString const& path)
|
||||
{
|
||||
auto error_or_real_path = FileSystem::real_path(path);
|
||||
if (error_or_real_path.is_error() || !FileSystem::is_directory(path))
|
||||
|
@ -413,11 +413,11 @@ bool DirectoryView::open(DeprecatedString const& path)
|
|||
warnln("Failed to open '{}': {}", real_path, result.error());
|
||||
}
|
||||
|
||||
if (model().root_path() == real_path.to_deprecated_string()) {
|
||||
if (model().root_path() == real_path.to_byte_string()) {
|
||||
refresh();
|
||||
} else {
|
||||
set_active_widget(¤t_view());
|
||||
model().set_root_path(real_path.to_deprecated_string());
|
||||
model().set_root_path(real_path.to_byte_string());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -528,15 +528,15 @@ void DirectoryView::launch(URL const&, LauncherHandler const& launcher_handler)
|
|||
}
|
||||
}
|
||||
|
||||
Vector<DeprecatedString> DirectoryView::selected_file_paths() const
|
||||
Vector<ByteString> DirectoryView::selected_file_paths() const
|
||||
{
|
||||
Vector<DeprecatedString> paths;
|
||||
Vector<ByteString> paths;
|
||||
auto& view = current_view();
|
||||
auto& model = *view.model();
|
||||
view.selection().for_each_index([&](GUI::ModelIndex const& index) {
|
||||
auto parent_index = model.parent_index(index);
|
||||
auto name_index = model.index(index.row(), GUI::FileSystemModel::Column::Name, parent_index);
|
||||
auto path = name_index.data(GUI::ModelRole::Custom).to_deprecated_string();
|
||||
auto path = name_index.data(GUI::ModelRole::Custom).to_byte_string();
|
||||
paths.append(path);
|
||||
});
|
||||
return paths;
|
||||
|
@ -580,11 +580,11 @@ void DirectoryView::setup_actions()
|
|||
String value;
|
||||
auto icon = Gfx::Bitmap::load_from_file("/res/icons/32x32/filetype-folder.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
if (GUI::InputBox::show(window(), value, "Enter a name:"sv, "New Directory"sv, GUI::InputType::NonemptyText, {}, move(icon)) == GUI::InputBox::ExecResult::OK) {
|
||||
auto new_dir_path = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", path(), value));
|
||||
auto new_dir_path = LexicalPath::canonicalized_path(ByteString::formatted("{}/{}", path(), value));
|
||||
int rc = mkdir(new_dir_path.characters(), 0777);
|
||||
if (rc < 0) {
|
||||
auto saved_errno = errno;
|
||||
GUI::MessageBox::show(window(), DeprecatedString::formatted("mkdir(\"{}\") failed: {}", new_dir_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(window(), ByteString::formatted("mkdir(\"{}\") failed: {}", new_dir_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -593,22 +593,22 @@ void DirectoryView::setup_actions()
|
|||
String value;
|
||||
auto icon = Gfx::Bitmap::load_from_file("/res/icons/32x32/filetype-unknown.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
if (GUI::InputBox::show(window(), value, "Enter a name:"sv, "New File"sv, GUI::InputType::NonemptyText, {}, move(icon)) == GUI::InputBox::ExecResult::OK) {
|
||||
auto new_file_path = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", path(), value));
|
||||
auto new_file_path = LexicalPath::canonicalized_path(ByteString::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(), DeprecatedString::formatted("stat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(window(), ByteString::formatted("stat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
}
|
||||
if (rc == 0) {
|
||||
GUI::MessageBox::show(window(), DeprecatedString::formatted("{}: Already exists", new_file_path), "Error"sv, GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(window(), ByteString::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(), DeprecatedString::formatted("creat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(window(), ByteString::formatted("creat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
}
|
||||
rc = close(fd);
|
||||
|
|
|
@ -51,8 +51,8 @@ public:
|
|||
|
||||
virtual ~DirectoryView() override;
|
||||
|
||||
bool open(DeprecatedString const& path);
|
||||
DeprecatedString path() const { return model().root_path(); }
|
||||
bool open(ByteString const& path);
|
||||
ByteString 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(Vector<NonnullRefPtr<LauncherHandler>> const& handlers);
|
||||
static Vector<NonnullRefPtr<LauncherHandler>> get_launch_handlers(URL const& url);
|
||||
static Vector<NonnullRefPtr<LauncherHandler>> get_launch_handlers(DeprecatedString const& path);
|
||||
static Vector<NonnullRefPtr<LauncherHandler>> get_launch_handlers(ByteString 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(DeprecatedString const&);
|
||||
void set_view_mode_from_string(ByteString const&);
|
||||
|
||||
GUI::AbstractView& current_view()
|
||||
{
|
||||
|
@ -120,7 +120,7 @@ public:
|
|||
|
||||
bool is_desktop() const { return m_mode == Mode::Desktop; }
|
||||
|
||||
Vector<DeprecatedString> selected_file_paths() const;
|
||||
Vector<ByteString> selected_file_paths() const;
|
||||
|
||||
GUI::Action& mkdir_action() { return *m_mkdir_action; }
|
||||
GUI::Action& touch_action() { return *m_touch_action; }
|
||||
|
@ -166,8 +166,8 @@ private:
|
|||
NonnullRefPtr<GUI::FileSystemModel> m_model;
|
||||
NonnullRefPtr<GUI::SortingProxyModel> m_sorting_model;
|
||||
size_t m_path_history_position { 0 };
|
||||
Vector<DeprecatedString> m_path_history;
|
||||
void add_path_to_history(DeprecatedString);
|
||||
Vector<ByteString> m_path_history;
|
||||
void add_path_to_history(ByteString);
|
||||
|
||||
RefPtr<GUI::Label> m_error_label;
|
||||
|
||||
|
|
|
@ -134,11 +134,11 @@ void FileOperationProgressWidget::did_error(StringView message)
|
|||
{
|
||||
// FIXME: Communicate more with the user about errors.
|
||||
close_pipe();
|
||||
GUI::MessageBox::show(window(), DeprecatedString::formatted("An error occurred: {}", message), "Error"sv, GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK);
|
||||
GUI::MessageBox::show(window(), ByteString::formatted("An error occurred: {}", message), "Error"sv, GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK);
|
||||
window()->close();
|
||||
}
|
||||
|
||||
DeprecatedString FileOperationProgressWidget::estimate_time(off_t bytes_done, off_t total_byte_count)
|
||||
ByteString FileOperationProgressWidget::estimate_time(off_t bytes_done, off_t total_byte_count)
|
||||
{
|
||||
i64 const elapsed_seconds = m_elapsed_timer.elapsed_time().to_seconds();
|
||||
|
||||
|
@ -149,7 +149,7 @@ DeprecatedString FileOperationProgressWidget::estimate_time(off_t bytes_done, of
|
|||
int seconds_remaining = (bytes_left * elapsed_seconds) / bytes_done;
|
||||
|
||||
if (seconds_remaining < 30)
|
||||
return DeprecatedString::formatted("{} seconds", 5 + seconds_remaining - seconds_remaining % 5);
|
||||
return ByteString::formatted("{} seconds", 5 + seconds_remaining - seconds_remaining % 5);
|
||||
if (seconds_remaining < 60)
|
||||
return "About a minute";
|
||||
if (seconds_remaining < 90)
|
||||
|
@ -162,14 +162,14 @@ DeprecatedString FileOperationProgressWidget::estimate_time(off_t bytes_done, of
|
|||
|
||||
if (minutes_remaining < 60) {
|
||||
if (seconds_remaining < 30)
|
||||
return DeprecatedString::formatted("About {} minutes", minutes_remaining);
|
||||
return DeprecatedString::formatted("Over {} minutes", minutes_remaining);
|
||||
return ByteString::formatted("About {} minutes", minutes_remaining);
|
||||
return ByteString::formatted("Over {} minutes", minutes_remaining);
|
||||
}
|
||||
|
||||
time_t hours_remaining = minutes_remaining / 60;
|
||||
minutes_remaining %= 60;
|
||||
|
||||
return DeprecatedString::formatted("{} hours and {} minutes", hours_remaining, minutes_remaining);
|
||||
return ByteString::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)
|
||||
|
@ -195,7 +195,7 @@ void FileOperationProgressWidget::did_progress(off_t bytes_done, off_t total_byt
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
estimated_time_label.set_text(String::from_deprecated_string(estimate_time(bytes_done, total_byte_count)).release_value_but_fixme_should_propagate_errors());
|
||||
estimated_time_label.set_text(String::from_byte_string(estimate_time(bytes_done, total_byte_count)).release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
if (total_byte_count) {
|
||||
window()->set_progress(100.0f * bytes_done / total_byte_count);
|
||||
|
|
|
@ -29,7 +29,7 @@ private:
|
|||
|
||||
void close_pipe();
|
||||
|
||||
DeprecatedString estimate_time(off_t bytes_done, off_t total_byte_count);
|
||||
ByteString estimate_time(off_t bytes_done, off_t total_byte_count);
|
||||
Core::ElapsedTimer m_elapsed_timer;
|
||||
|
||||
FileOperation m_operation;
|
||||
|
|
|
@ -19,13 +19,13 @@ namespace FileManager {
|
|||
|
||||
HashTable<NonnullRefPtr<GUI::Window>> file_operation_windows;
|
||||
|
||||
void delete_paths(Vector<DeprecatedString> const& paths, bool should_confirm, GUI::Window* parent_window)
|
||||
void delete_paths(Vector<ByteString> const& paths, bool should_confirm, GUI::Window* parent_window)
|
||||
{
|
||||
DeprecatedString message;
|
||||
ByteString message;
|
||||
if (paths.size() == 1) {
|
||||
message = DeprecatedString::formatted("Are you sure you want to delete \"{}\"?", LexicalPath::basename(paths[0]));
|
||||
message = ByteString::formatted("Are you sure you want to delete \"{}\"?", LexicalPath::basename(paths[0]));
|
||||
} else {
|
||||
message = DeprecatedString::formatted("Are you sure you want to delete {} files?", paths.size());
|
||||
message = ByteString::formatted("Are you sure you want to delete {} files?", paths.size());
|
||||
}
|
||||
|
||||
if (should_confirm) {
|
||||
|
@ -42,7 +42,7 @@ void delete_paths(Vector<DeprecatedString> const& paths, bool should_confirm, GU
|
|||
_exit(1);
|
||||
}
|
||||
|
||||
ErrorOr<void> run_file_operation(FileOperation operation, Vector<DeprecatedString> const& sources, DeprecatedString const& destination, GUI::Window* parent_window)
|
||||
ErrorOr<void> run_file_operation(FileOperation operation, Vector<ByteString> const& sources, ByteString const& destination, GUI::Window* parent_window)
|
||||
{
|
||||
auto pipe_fds = TRY(Core::System::pipe2(0));
|
||||
|
||||
|
@ -110,7 +110,7 @@ ErrorOr<void> run_file_operation(FileOperation operation, Vector<DeprecatedStrin
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<bool> handle_drop(GUI::DropEvent const& event, DeprecatedString const& destination, GUI::Window* window)
|
||||
ErrorOr<bool> handle_drop(GUI::DropEvent const& event, ByteString const& destination, GUI::Window* window)
|
||||
{
|
||||
bool has_accepted_drop = false;
|
||||
|
||||
|
@ -127,12 +127,12 @@ ErrorOr<bool> handle_drop(GUI::DropEvent const& event, DeprecatedString const& d
|
|||
if (!FileSystem::is_directory(target))
|
||||
return has_accepted_drop;
|
||||
|
||||
Vector<DeprecatedString> paths_to_copy;
|
||||
Vector<ByteString> paths_to_copy;
|
||||
for (auto& url_to_copy : urls) {
|
||||
auto file_path = url_to_copy.serialize_path();
|
||||
if (!url_to_copy.is_valid() || file_path == target)
|
||||
continue;
|
||||
auto new_path = DeprecatedString::formatted("{}/{}", target, LexicalPath::basename(file_path));
|
||||
auto new_path = ByteString::formatted("{}/{}", target, LexicalPath::basename(file_path));
|
||||
if (file_path == new_path)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <LibCore/Forward.h>
|
||||
#include <LibGUI/Forward.h>
|
||||
|
||||
|
@ -19,8 +19,8 @@ enum class FileOperation {
|
|||
Delete,
|
||||
};
|
||||
|
||||
void delete_paths(Vector<DeprecatedString> const&, bool should_confirm, GUI::Window*);
|
||||
void delete_paths(Vector<ByteString> const&, bool should_confirm, GUI::Window*);
|
||||
|
||||
ErrorOr<void> run_file_operation(FileOperation, Vector<DeprecatedString> const& sources, DeprecatedString const& destination, GUI::Window*);
|
||||
ErrorOr<bool> handle_drop(GUI::DropEvent const& event, DeprecatedString const& destination, GUI::Window* window);
|
||||
ErrorOr<void> run_file_operation(FileOperation, Vector<ByteString> const& sources, ByteString const& destination, GUI::Window*);
|
||||
ErrorOr<bool> handle_drop(GUI::DropEvent const& event, ByteString const& destination, GUI::Window* window);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
ErrorOr<NonnullRefPtr<PropertiesWindow>> PropertiesWindow::try_create(DeprecatedString const& path, bool disable_rename, Window* parent)
|
||||
ErrorOr<NonnullRefPtr<PropertiesWindow>> PropertiesWindow::try_create(ByteString const& path, bool disable_rename, Window* parent)
|
||||
{
|
||||
auto window = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) PropertiesWindow(path, parent)));
|
||||
window->set_icon(TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"sv)));
|
||||
|
@ -55,7 +55,7 @@ ErrorOr<NonnullRefPtr<PropertiesWindow>> PropertiesWindow::try_create(Deprecated
|
|||
return window;
|
||||
}
|
||||
|
||||
PropertiesWindow::PropertiesWindow(DeprecatedString const& path, Window* parent_window)
|
||||
PropertiesWindow::PropertiesWindow(ByteString const& path, Window* parent_window)
|
||||
: Window(parent_window)
|
||||
{
|
||||
auto lexical_path = LexicalPath(path);
|
||||
|
@ -134,15 +134,15 @@ ErrorOr<void> PropertiesWindow::create_general_tab(GUI::TabWidget& tab_widget, b
|
|||
};
|
||||
|
||||
auto* location = general_tab.find_descendant_of_type_named<GUI::LinkLabel>("location");
|
||||
location->set_text(TRY(String::from_deprecated_string(m_path)));
|
||||
location->set_text(TRY(String::from_byte_string(m_path)));
|
||||
location->on_click = [this] {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme(m_parent_path, m_name));
|
||||
};
|
||||
|
||||
auto st = TRY(Core::System::lstat(m_path));
|
||||
|
||||
DeprecatedString owner_name;
|
||||
DeprecatedString group_name;
|
||||
ByteString owner_name;
|
||||
ByteString group_name;
|
||||
|
||||
if (auto* pw = getpwuid(st.st_uid)) {
|
||||
owner_name = pw->pw_name;
|
||||
|
@ -171,7 +171,7 @@ ErrorOr<void> PropertiesWindow::create_general_tab(GUI::TabWidget& tab_widget, b
|
|||
auto* link_location = general_tab.find_descendant_of_type_named<GUI::LinkLabel>("link_location");
|
||||
link_location->set_text(link_destination);
|
||||
link_location->on_click = [link_destination] {
|
||||
auto link_directory = LexicalPath(link_destination.to_deprecated_string());
|
||||
auto link_directory = LexicalPath(link_destination.to_byte_string());
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme(link_directory.dirname(), link_directory.basename()));
|
||||
};
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ ErrorOr<void> PropertiesWindow::create_general_tab(GUI::TabWidget& tab_widget, b
|
|||
m_size_label = general_tab.find_descendant_of_type_named<GUI::Label>("size");
|
||||
m_size_label->set_text(S_ISDIR(st.st_mode)
|
||||
? "Calculating..."_string
|
||||
: TRY(String::from_deprecated_string(human_readable_size_long(st.st_size, UseThousandsSeparator::Yes))));
|
||||
: TRY(String::from_byte_string(human_readable_size_long(st.st_size, UseThousandsSeparator::Yes))));
|
||||
|
||||
auto* owner = general_tab.find_descendant_of_type_named<GUI::Label>("owner");
|
||||
owner->set_text(String::formatted("{} ({})", owner_name, st.st_uid).release_value_but_fixme_should_propagate_errors());
|
||||
|
@ -192,10 +192,10 @@ ErrorOr<void> PropertiesWindow::create_general_tab(GUI::TabWidget& tab_widget, b
|
|||
group->set_text(String::formatted("{} ({})", group_name, st.st_gid).release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
auto* created_at = general_tab.find_descendant_of_type_named<GUI::Label>("created_at");
|
||||
created_at->set_text(String::from_deprecated_string(GUI::FileSystemModel::timestamp_string(st.st_ctime)).release_value_but_fixme_should_propagate_errors());
|
||||
created_at->set_text(String::from_byte_string(GUI::FileSystemModel::timestamp_string(st.st_ctime)).release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
auto* last_modified = general_tab.find_descendant_of_type_named<GUI::Label>("last_modified");
|
||||
last_modified->set_text(String::from_deprecated_string(GUI::FileSystemModel::timestamp_string(st.st_mtime)).release_value_but_fixme_should_propagate_errors());
|
||||
last_modified->set_text(String::from_byte_string(GUI::FileSystemModel::timestamp_string(st.st_mtime)).release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
auto* owner_read = general_tab.find_descendant_of_type_named<GUI::CheckBox>("owner_read");
|
||||
auto* owner_write = general_tab.find_descendant_of_type_named<GUI::CheckBox>("owner_write");
|
||||
|
@ -263,7 +263,7 @@ ErrorOr<void> PropertiesWindow::create_archive_tab(GUI::TabWidget& tab_widget, N
|
|||
tab.find_descendant_of_type_named<GUI::Label>("archive_file_count")->set_text(TRY(String::number(statistics.file_count())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("archive_format")->set_text("ZIP"_string);
|
||||
tab.find_descendant_of_type_named<GUI::Label>("archive_directory_count")->set_text(TRY(String::number(statistics.directory_count())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("archive_uncompressed_size")->set_text(TRY(String::from_deprecated_string(AK::human_readable_size(statistics.total_uncompressed_bytes()))));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("archive_uncompressed_size")->set_text(TRY(String::from_byte_string(AK::human_readable_size(statistics.total_uncompressed_bytes()))));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -280,9 +280,9 @@ ErrorOr<void> PropertiesWindow::create_audio_tab(GUI::TabWidget& tab_widget, Non
|
|||
auto& tab = tab_widget.add_tab<GUI::Widget>("Audio"_string);
|
||||
TRY(tab.load_from_gml(properties_window_audio_tab_gml));
|
||||
|
||||
tab.find_descendant_of_type_named<GUI::Label>("audio_type")->set_text(TRY(String::from_deprecated_string(loader->format_name())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("audio_type")->set_text(TRY(String::from_byte_string(loader->format_name())));
|
||||
auto duration_seconds = loader->total_samples() / loader->sample_rate();
|
||||
tab.find_descendant_of_type_named<GUI::Label>("audio_duration")->set_text(TRY(String::from_deprecated_string(human_readable_digital_time(duration_seconds))));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("audio_duration")->set_text(TRY(String::from_byte_string(human_readable_digital_time(duration_seconds))));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("audio_sample_rate")->set_text(TRY(String::formatted("{} Hz", loader->sample_rate())));
|
||||
tab.find_descendant_of_type_named<GUI::Label>("audio_format")->set_text(TRY(String::formatted("{}-bit", loader->bits_per_sample())));
|
||||
|
||||
|
@ -487,12 +487,12 @@ ErrorOr<void> PropertiesWindow::create_pdf_tab(GUI::TabWidget& tab_widget, Nonnu
|
|||
if (maybe_info_dict.is_error()) {
|
||||
warnln("Failed to read InfoDict from '{}': {}", m_path, maybe_info_dict.error().message());
|
||||
} else if (maybe_info_dict.value().has_value()) {
|
||||
auto get_info_string = [](PDF::PDFErrorOr<Optional<DeprecatedString>> input) -> ErrorOr<String> {
|
||||
auto get_info_string = [](PDF::PDFErrorOr<Optional<ByteString>> input) -> ErrorOr<String> {
|
||||
if (input.is_error())
|
||||
return String {};
|
||||
if (!input.value().has_value())
|
||||
return String {};
|
||||
return String::from_deprecated_string(input.value().value());
|
||||
return String::from_byte_string(input.value().value());
|
||||
};
|
||||
|
||||
auto info_dict = maybe_info_dict.release_value().release_value();
|
||||
|
@ -512,7 +512,7 @@ ErrorOr<void> PropertiesWindow::create_pdf_tab(GUI::TabWidget& tab_widget, Nonnu
|
|||
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(DeprecatedString::formatted("{} - Properties", m_name));
|
||||
set_title(ByteString::formatted("{} - Properties", m_name));
|
||||
}
|
||||
|
||||
void PropertiesWindow::permission_changed(mode_t mask, bool set)
|
||||
|
@ -527,24 +527,24 @@ void PropertiesWindow::permission_changed(mode_t mask, bool set)
|
|||
m_apply_button->set_enabled(m_name_dirty || m_permissions_dirty);
|
||||
}
|
||||
|
||||
DeprecatedString PropertiesWindow::make_full_path(DeprecatedString const& name)
|
||||
ByteString PropertiesWindow::make_full_path(ByteString const& name)
|
||||
{
|
||||
return DeprecatedString::formatted("{}/{}", m_parent_path, name);
|
||||
return ByteString::formatted("{}/{}", m_parent_path, name);
|
||||
}
|
||||
|
||||
bool PropertiesWindow::apply_changes()
|
||||
{
|
||||
if (m_name_dirty) {
|
||||
DeprecatedString new_name = m_name_box->text();
|
||||
DeprecatedString new_file = make_full_path(new_name).characters();
|
||||
ByteString new_name = m_name_box->text();
|
||||
ByteString new_file = make_full_path(new_name).characters();
|
||||
|
||||
if (FileSystem::exists(new_file)) {
|
||||
GUI::MessageBox::show(this, DeprecatedString::formatted("A file \"{}\" already exists!", new_name), "Error"sv, GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(this, ByteString::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, DeprecatedString::formatted("Could not rename file: {}!", strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(this, ByteString::formatted("Could not rename file: {}!", strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -555,7 +555,7 @@ bool PropertiesWindow::apply_changes()
|
|||
|
||||
if (m_permissions_dirty) {
|
||||
if (chmod(make_full_path(m_name).characters(), m_mode)) {
|
||||
GUI::MessageBox::show(this, DeprecatedString::formatted("Could not update permissions: {}!", strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(this, ByteString::formatted("Could not update permissions: {}!", strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -606,7 +606,7 @@ void PropertiesWindow::close()
|
|||
m_directory_statistics_calculator->stop();
|
||||
}
|
||||
|
||||
PropertiesWindow::DirectoryStatisticsCalculator::DirectoryStatisticsCalculator(DeprecatedString path)
|
||||
PropertiesWindow::DirectoryStatisticsCalculator::DirectoryStatisticsCalculator(ByteString path)
|
||||
{
|
||||
m_work_queue.enqueue(path);
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@ class PropertiesWindow final : public GUI::Window {
|
|||
C_OBJECT(PropertiesWindow);
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<PropertiesWindow>> try_create(DeprecatedString const& path, bool disable_rename, Window* parent = nullptr);
|
||||
static ErrorOr<NonnullRefPtr<PropertiesWindow>> try_create(ByteString const& path, bool disable_rename, Window* parent = nullptr);
|
||||
virtual ~PropertiesWindow() override = default;
|
||||
|
||||
virtual void close() final;
|
||||
|
||||
private:
|
||||
PropertiesWindow(DeprecatedString const& path, Window* parent = nullptr);
|
||||
PropertiesWindow(ByteString const& path, Window* parent = nullptr);
|
||||
ErrorOr<void> create_widgets(bool disable_rename);
|
||||
ErrorOr<void> create_general_tab(GUI::TabWidget&, bool disable_rename);
|
||||
ErrorOr<void> create_file_type_specific_tabs(GUI::TabWidget&);
|
||||
|
@ -44,7 +44,7 @@ private:
|
|||
|
||||
class DirectoryStatisticsCalculator final : public RefCounted<DirectoryStatisticsCalculator> {
|
||||
public:
|
||||
DirectoryStatisticsCalculator(DeprecatedString path);
|
||||
DirectoryStatisticsCalculator(ByteString path);
|
||||
void start();
|
||||
void stop();
|
||||
Function<void(off_t total_size_in_bytes, size_t file_count, size_t directory_count)> on_update;
|
||||
|
@ -54,7 +54,7 @@ private:
|
|||
size_t m_file_count { 0 };
|
||||
size_t m_directory_count { 0 };
|
||||
RefPtr<Threading::BackgroundAction<int>> m_background_action;
|
||||
Queue<DeprecatedString> m_work_queue;
|
||||
Queue<ByteString> m_work_queue;
|
||||
};
|
||||
|
||||
static StringView const get_description(mode_t const mode)
|
||||
|
@ -84,7 +84,7 @@ private:
|
|||
void permission_changed(mode_t mask, bool set);
|
||||
bool apply_changes();
|
||||
void update();
|
||||
DeprecatedString make_full_path(DeprecatedString const& name);
|
||||
ByteString make_full_path(ByteString const& name);
|
||||
|
||||
RefPtr<GUI::Button> m_apply_button;
|
||||
RefPtr<GUI::TextBox> m_name_box;
|
||||
|
@ -92,9 +92,9 @@ private:
|
|||
RefPtr<GUI::Label> m_size_label;
|
||||
RefPtr<DirectoryStatisticsCalculator> m_directory_statistics_calculator;
|
||||
RefPtr<GUI::Action> m_on_escape;
|
||||
DeprecatedString m_name;
|
||||
DeprecatedString m_parent_path;
|
||||
DeprecatedString m_path;
|
||||
ByteString m_name;
|
||||
ByteString m_parent_path;
|
||||
ByteString m_path;
|
||||
mode_t m_mode { 0 };
|
||||
mode_t m_old_mode { 0 };
|
||||
bool m_permissions_dirty { false };
|
||||
|
|
|
@ -59,15 +59,15 @@
|
|||
using namespace FileManager;
|
||||
|
||||
static ErrorOr<int> run_in_desktop_mode();
|
||||
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, Vector<NonnullRefPtr<LauncherHandler>>& current_file_launch_handlers);
|
||||
static ErrorOr<int> run_in_windowed_mode(ByteString const& initial_location, ByteString const& entry_focused_on_init);
|
||||
static void do_copy(Vector<ByteString> const& selected_file_paths, FileOperation file_operation);
|
||||
static void do_paste(ByteString const& target_directory, GUI::Window* window);
|
||||
static void do_create_link(Vector<ByteString> const& selected_file_paths, GUI::Window* window);
|
||||
static void do_create_archive(Vector<ByteString> const& selected_file_paths, GUI::Window* window);
|
||||
static void do_set_wallpaper(ByteString const& file_path, GUI::Window* window);
|
||||
static void do_unzip_archive(Vector<ByteString> const& selected_file_paths, GUI::Window* window);
|
||||
static void show_properties(ByteString const& container_dir_path, ByteString const& path, Vector<ByteString> const& selected, GUI::Window* window);
|
||||
static bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, ByteString const& full_path, RefPtr<GUI::Action>& default_action, Vector<NonnullRefPtr<LauncherHandler>>& current_file_launch_handlers);
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
bool is_desktop_mode { false };
|
||||
bool is_selection_mode { false };
|
||||
bool ignore_path_resolution { false };
|
||||
DeprecatedString initial_location;
|
||||
ByteString 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');
|
||||
|
@ -109,7 +109,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
LexicalPath path(initial_location);
|
||||
if (!initial_location.is_empty()) {
|
||||
if (auto error_or_path = FileSystem::real_path(initial_location); !ignore_path_resolution && !error_or_path.is_error())
|
||||
initial_location = error_or_path.release_value().to_deprecated_string();
|
||||
initial_location = error_or_path.release_value().to_byte_string();
|
||||
|
||||
if (!FileSystem::is_directory(initial_location)) {
|
||||
// We want to extract zips to a temporary directory when FileManager is launched with a .zip file as its first argument
|
||||
|
@ -134,7 +134,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return -1;
|
||||
}
|
||||
|
||||
return run_in_windowed_mode(temp_directory_path.to_deprecated_string(), path.basename());
|
||||
return run_in_windowed_mode(temp_directory_path.to_byte_string(), path.basename());
|
||||
}
|
||||
|
||||
is_selection_mode = true;
|
||||
|
@ -142,7 +142,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
}
|
||||
|
||||
if (auto error_or_cwd = FileSystem::current_working_directory(); initial_location.is_empty() && !error_or_cwd.is_error())
|
||||
initial_location = error_or_cwd.release_value().to_deprecated_string();
|
||||
initial_location = error_or_cwd.release_value().to_byte_string();
|
||||
|
||||
if (initial_location.is_empty())
|
||||
initial_location = Core::StandardPaths::home_directory();
|
||||
|
@ -150,7 +150,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (initial_location.is_empty())
|
||||
initial_location = "/";
|
||||
|
||||
DeprecatedString focused_entry;
|
||||
ByteString focused_entry;
|
||||
if (is_selection_mode) {
|
||||
initial_location = path.dirname();
|
||||
focused_entry = path.basename();
|
||||
|
@ -159,7 +159,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return run_in_windowed_mode(initial_location, focused_entry);
|
||||
}
|
||||
|
||||
void do_copy(Vector<DeprecatedString> const& selected_file_paths, FileOperation file_operation)
|
||||
void do_copy(Vector<ByteString> const& selected_file_paths, FileOperation file_operation)
|
||||
{
|
||||
VERIFY(!selected_file_paths.is_empty());
|
||||
|
||||
|
@ -171,17 +171,17 @@ void do_copy(Vector<DeprecatedString> const& selected_file_paths, FileOperation
|
|||
auto url = URL::create_with_file_scheme(path);
|
||||
copy_text.appendff("{}\n", url);
|
||||
}
|
||||
GUI::Clipboard::the().set_data(copy_text.to_deprecated_string().bytes(), "text/uri-list");
|
||||
GUI::Clipboard::the().set_data(copy_text.to_byte_string().bytes(), "text/uri-list");
|
||||
}
|
||||
|
||||
void do_paste(DeprecatedString const& target_directory, GUI::Window* window)
|
||||
void do_paste(ByteString 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 = DeprecatedString::copy(data_and_type.data).split('\n');
|
||||
auto copied_lines = ByteString::copy(data_and_type.data).split('\n');
|
||||
if (copied_lines.is_empty()) {
|
||||
dbgln("No files to paste");
|
||||
return;
|
||||
|
@ -193,7 +193,7 @@ void do_paste(DeprecatedString const& target_directory, GUI::Window* window)
|
|||
copied_lines.remove(0);
|
||||
}
|
||||
|
||||
Vector<DeprecatedString> source_paths;
|
||||
Vector<ByteString> source_paths;
|
||||
for (auto& uri_as_string : copied_lines) {
|
||||
if (uri_as_string.is_empty())
|
||||
continue;
|
||||
|
@ -211,17 +211,17 @@ void do_paste(DeprecatedString const& target_directory, GUI::Window* window)
|
|||
}
|
||||
}
|
||||
|
||||
void do_create_link(Vector<DeprecatedString> const& selected_file_paths, GUI::Window* window)
|
||||
void do_create_link(Vector<ByteString> const& selected_file_paths, GUI::Window* window)
|
||||
{
|
||||
auto path = selected_file_paths.first();
|
||||
auto destination = DeprecatedString::formatted("{}/{}", Core::StandardPaths::desktop_directory(), LexicalPath::basename(path));
|
||||
auto destination = ByteString::formatted("{}/{}", Core::StandardPaths::desktop_directory(), LexicalPath::basename(path));
|
||||
if (auto result = FileSystem::link_file(destination, path); result.is_error()) {
|
||||
GUI::MessageBox::show(window, DeprecatedString::formatted("Could not create desktop shortcut:\n{}", result.error()), "File Manager"sv,
|
||||
GUI::MessageBox::show(window, ByteString::formatted("Could not create desktop shortcut:\n{}", result.error()), "File Manager"sv,
|
||||
GUI::MessageBox::Type::Error);
|
||||
}
|
||||
}
|
||||
|
||||
void do_create_archive(Vector<DeprecatedString> const& selected_file_paths, GUI::Window* window)
|
||||
void do_create_archive(Vector<ByteString> const& selected_file_paths, GUI::Window* window)
|
||||
{
|
||||
String archive_name;
|
||||
if (GUI::InputBox::show(window, archive_name, "Enter name:"sv, "Create Archive"sv) != GUI::InputBox::ExecResult::OK)
|
||||
|
@ -240,7 +240,7 @@ void do_create_archive(Vector<DeprecatedString> const& selected_file_paths, GUI:
|
|||
if (!AK::StringUtils::ends_with(archive_name, ".zip"sv, CaseSensitivity::CaseSensitive))
|
||||
path_builder.append(".zip"sv);
|
||||
}
|
||||
auto output_path = path_builder.to_deprecated_string();
|
||||
auto output_path = path_builder.to_byte_string();
|
||||
|
||||
pid_t zip_pid = fork();
|
||||
if (zip_pid < 0) {
|
||||
|
@ -249,7 +249,7 @@ void do_create_archive(Vector<DeprecatedString> const& selected_file_paths, GUI:
|
|||
}
|
||||
|
||||
if (!zip_pid) {
|
||||
Vector<DeprecatedString> relative_paths;
|
||||
Vector<ByteString> relative_paths;
|
||||
Vector<char const*> arg_list;
|
||||
arg_list.append("/bin/zip");
|
||||
arg_list.append("-r");
|
||||
|
@ -273,10 +273,10 @@ void do_create_archive(Vector<DeprecatedString> const& selected_file_paths, GUI:
|
|||
}
|
||||
}
|
||||
|
||||
void do_set_wallpaper(DeprecatedString const& file_path, GUI::Window* window)
|
||||
void do_set_wallpaper(ByteString const& file_path, GUI::Window* window)
|
||||
{
|
||||
auto show_error = [&] {
|
||||
GUI::MessageBox::show(window, DeprecatedString::formatted("Failed to set {} as wallpaper.", file_path), "Failed to set wallpaper"sv, GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(window, ByteString::formatted("Failed to set {} as wallpaper.", file_path), "Failed to set wallpaper"sv, GUI::MessageBox::Type::Error);
|
||||
};
|
||||
|
||||
auto bitmap_or_error = Gfx::Bitmap::load_from_file(file_path);
|
||||
|
@ -289,10 +289,10 @@ void do_set_wallpaper(DeprecatedString const& file_path, GUI::Window* window)
|
|||
show_error();
|
||||
}
|
||||
|
||||
void do_unzip_archive(Vector<DeprecatedString> const& selected_file_paths, GUI::Window* window)
|
||||
void do_unzip_archive(Vector<ByteString> const& selected_file_paths, GUI::Window* window)
|
||||
{
|
||||
DeprecatedString archive_file_path = selected_file_paths.first();
|
||||
DeprecatedString output_directory_path = archive_file_path.substring(0, archive_file_path.length() - 4);
|
||||
ByteString archive_file_path = selected_file_paths.first();
|
||||
ByteString output_directory_path = archive_file_path.substring(0, archive_file_path.length() - 4);
|
||||
|
||||
pid_t unzip_pid = fork();
|
||||
if (unzip_pid < 0) {
|
||||
|
@ -315,7 +315,7 @@ void do_unzip_archive(Vector<DeprecatedString> const& selected_file_paths, GUI::
|
|||
}
|
||||
}
|
||||
|
||||
void show_properties(DeprecatedString const& container_dir_path, DeprecatedString const& path, Vector<DeprecatedString> const& selected, GUI::Window* window)
|
||||
void show_properties(ByteString const& container_dir_path, ByteString const& path, Vector<ByteString> const& selected, GUI::Window* window)
|
||||
{
|
||||
ErrorOr<RefPtr<PropertiesWindow>> properties_or_error = nullptr;
|
||||
if (selected.is_empty()) {
|
||||
|
@ -337,7 +337,7 @@ void show_properties(DeprecatedString const& container_dir_path, DeprecatedStrin
|
|||
properties->show();
|
||||
}
|
||||
|
||||
bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr<GUI::Action>& default_action, Vector<NonnullRefPtr<LauncherHandler>>& current_file_launch_handlers)
|
||||
bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, ByteString const& full_path, RefPtr<GUI::Action>& default_action, Vector<NonnullRefPtr<LauncherHandler>>& current_file_launch_handlers)
|
||||
{
|
||||
current_file_launch_handlers = directory_view.get_launch_handlers(full_path);
|
||||
|
||||
|
@ -348,9 +348,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(DeprecatedString::formatted("Run {}", file_open_action->text()));
|
||||
file_open_action->set_text(ByteString::formatted("Run {}", file_open_action->text()));
|
||||
else
|
||||
file_open_action->set_text(DeprecatedString::formatted("Open in {}", file_open_action->text()));
|
||||
file_open_action->set_text(ByteString::formatted("Open in {}", file_open_action->text()));
|
||||
|
||||
default_action = file_open_action;
|
||||
|
||||
|
@ -458,8 +458,8 @@ ErrorOr<int> run_in_desktop_mode()
|
|||
|
||||
auto properties_action = GUI::CommonActions::make_properties_action(
|
||||
[&](auto&) {
|
||||
DeprecatedString path = directory_view->path();
|
||||
Vector<DeprecatedString> selected = directory_view->selected_file_paths();
|
||||
ByteString path = directory_view->path();
|
||||
Vector<ByteString> selected = directory_view->selected_file_paths();
|
||||
|
||||
show_properties(path, path, selected, directory_view->window());
|
||||
},
|
||||
|
@ -472,7 +472,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 = [&](DeprecatedString const& data_type) {
|
||||
GUI::Clipboard::the().on_change = [&](ByteString const& data_type) {
|
||||
paste_action->set_enabled(data_type == "text/uri-list" && access(directory_view->path().characters(), W_OK) == 0);
|
||||
};
|
||||
|
||||
|
@ -604,7 +604,7 @@ ErrorOr<int> run_in_desktop_mode()
|
|||
return GUI::Application::the()->exec();
|
||||
}
|
||||
|
||||
ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, DeprecatedString const& entry_focused_on_init)
|
||||
ErrorOr<int> run_in_windowed_mode(ByteString const& initial_location, ByteString const& entry_focused_on_init)
|
||||
{
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_title("File Manager");
|
||||
|
@ -762,7 +762,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
|||
view_type_action_group->add_action(directory_view->view_as_columns_action());
|
||||
|
||||
auto tree_view_selected_file_paths = [&] {
|
||||
Vector<DeprecatedString> paths;
|
||||
Vector<ByteString> paths;
|
||||
auto& view = tree_view;
|
||||
view.selection().for_each_index([&](GUI::ModelIndex const& index) {
|
||||
paths.append(directories_model->full_path(index));
|
||||
|
@ -802,7 +802,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
|||
|
||||
auto copy_path_action = GUI::Action::create(
|
||||
"Copy Path", [&](GUI::Action const&) {
|
||||
Vector<DeprecatedString> selected_paths;
|
||||
Vector<ByteString> selected_paths;
|
||||
if (directory_view->active_widget()->is_focused()) {
|
||||
selected_paths = directory_view->selected_file_paths();
|
||||
} else if (tree_view.is_focused()) {
|
||||
|
@ -822,7 +822,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
|||
{},
|
||||
TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-file-manager.png"sv)),
|
||||
[&](GUI::Action const& action) {
|
||||
Vector<DeprecatedString> paths;
|
||||
Vector<ByteString> paths;
|
||||
if (action.activator() == tree_view_directory_context_menu)
|
||||
paths = tree_view_selected_file_paths();
|
||||
else
|
||||
|
@ -841,7 +841,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
|||
{},
|
||||
TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-terminal.png"sv)),
|
||||
[&](GUI::Action const& action) {
|
||||
Vector<DeprecatedString> paths;
|
||||
Vector<ByteString> paths;
|
||||
if (action.activator() == tree_view_directory_context_menu)
|
||||
paths = tree_view_selected_file_paths();
|
||||
else
|
||||
|
@ -911,9 +911,9 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
|||
|
||||
auto properties_action = GUI::CommonActions::make_properties_action(
|
||||
[&](auto& action) {
|
||||
DeprecatedString container_dir_path;
|
||||
DeprecatedString path;
|
||||
Vector<DeprecatedString> selected;
|
||||
ByteString container_dir_path;
|
||||
ByteString path;
|
||||
Vector<ByteString> selected;
|
||||
if (action.activator() == directory_context_menu || directory_view->active_widget()->is_focused()) {
|
||||
path = directory_view->path();
|
||||
container_dir_path = path;
|
||||
|
@ -930,7 +930,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
|||
|
||||
auto paste_action = GUI::CommonActions::make_paste_action(
|
||||
[&](GUI::Action const& action) {
|
||||
DeprecatedString target_directory;
|
||||
ByteString target_directory;
|
||||
if (action.activator() == directory_context_menu)
|
||||
target_directory = directory_view->selected_file_paths()[0];
|
||||
else
|
||||
|
@ -942,7 +942,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
|||
|
||||
auto folder_specific_paste_action = GUI::CommonActions::make_paste_action(
|
||||
[&](GUI::Action const& action) {
|
||||
DeprecatedString target_directory;
|
||||
ByteString target_directory;
|
||||
if (action.activator() == directory_context_menu)
|
||||
target_directory = directory_view->selected_file_paths()[0];
|
||||
else
|
||||
|
@ -970,7 +970,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
|||
},
|
||||
window);
|
||||
|
||||
GUI::Clipboard::the().on_change = [&](DeprecatedString const& data_type) {
|
||||
GUI::Clipboard::the().on_change = [&](ByteString 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);
|
||||
};
|
||||
|
@ -1108,12 +1108,12 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
|||
}
|
||||
};
|
||||
|
||||
directory_view->on_path_change = [&](DeprecatedString const& new_path, bool can_read_in_path, bool can_write_in_path) {
|
||||
directory_view->on_path_change = [&](ByteString 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);
|
||||
|
||||
window->set_title(DeprecatedString::formatted("{} - File Manager", new_path));
|
||||
window->set_title(ByteString::formatted("{} - File Manager", new_path));
|
||||
|
||||
breadcrumbbar.set_current_path(new_path);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue