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

Everywhere: Use LibFileSystem where trivial

This commit is contained in:
Cameron Youell 2023-03-22 02:35:30 +11:00 committed by Linus Groh
parent edab0cbf41
commit 1d24f394c6
115 changed files with 275 additions and 228 deletions

View file

@ -25,4 +25,4 @@ set(GENERATED_SOURCES
)
serenity_app(FileManager ICON app-file-manager)
target_link_libraries(FileManager PRIVATE LibCore LibGfx LibGUI LibDesktop LibConfig LibMain LibThreading)
target_link_libraries(FileManager PRIVATE LibCore LibFileSystem LibGfx LibGUI LibDesktop LibConfig LibMain LibThreading)

View file

@ -14,6 +14,7 @@
#include <LibCore/DeprecatedFile.h>
#include <LibCore/MimeData.h>
#include <LibCore/StandardPaths.h>
#include <LibFileSystem/FileSystem.h>
#include <LibGUI/FileIconProvider.h>
#include <LibGUI/InputBox.h>
#include <LibGUI/Label.h>
@ -204,7 +205,7 @@ void DirectoryView::setup_model()
while (model_root.string() != "/") {
model_root = model_root.parent();
if (Core::DeprecatedFile::is_directory(model_root.string()))
if (FileSystem::is_directory(model_root.string()))
break;
}
@ -406,7 +407,7 @@ void DirectoryView::add_path_to_history(DeprecatedString path)
bool DirectoryView::open(DeprecatedString const& path)
{
auto real_path = Core::DeprecatedFile::real_path_for(path);
if (real_path.is_null() || !Core::DeprecatedFile::is_directory(path))
if (real_path.is_null() || !FileSystem::is_directory(path))
return false;
if (chdir(real_path.characters()) < 0) {
@ -555,7 +556,7 @@ bool DirectoryView::can_modify_current_selection()
// FIXME: remove once Clang formats this properly.
// clang-format off
return selections.first_matching([&](auto& index) {
return Core::DeprecatedFile::can_delete_or_move(node(index).full_path());
return FileSystem::can_delete_or_move(node(index).full_path());
}).has_value();
// clang-format on
}

View file

@ -8,9 +8,9 @@
#include "FileUtils.h"
#include "FileOperationProgressWidget.h"
#include <AK/LexicalPath.h>
#include <LibCore/DeprecatedFile.h>
#include <LibCore/MimeData.h>
#include <LibCore/System.h>
#include <LibFileSystem/FileSystem.h>
#include <LibGUI/Event.h>
#include <LibGUI/MessageBox.h>
#include <unistd.h>
@ -124,7 +124,7 @@ ErrorOr<bool> handle_drop(GUI::DropEvent const& event, DeprecatedString const& d
auto const target = LexicalPath::canonicalized_path(destination);
if (!Core::DeprecatedFile::is_directory(target))
if (!FileSystem::is_directory(target))
return has_accepted_drop;
Vector<DeprecatedString> paths_to_copy;

View file

@ -14,6 +14,7 @@
#include <LibCore/Directory.h>
#include <LibCore/System.h>
#include <LibDesktop/Launcher.h>
#include <LibFileSystem/FileSystem.h>
#include <LibGUI/BoxLayout.h>
#include <LibGUI/CheckBox.h>
#include <LibGUI/FileIconProvider.h>
@ -212,7 +213,7 @@ bool PropertiesWindow::apply_changes()
DeprecatedString new_name = m_name_box->text();
DeprecatedString new_file = make_full_path(new_name).characters();
if (Core::DeprecatedFile::exists(new_file)) {
if (FileSystem::exists(new_file)) {
GUI::MessageBox::show(this, DeprecatedString::formatted("A file \"{}\" already exists!", new_name), "Error"sv, GUI::MessageBox::Type::Error);
return false;
}

View file

@ -25,6 +25,7 @@
#include <LibCore/System.h>
#include <LibCore/TempFile.h>
#include <LibDesktop/Launcher.h>
#include <LibFileSystem/FileSystem.h>
#include <LibGUI/Action.h>
#include <LibGUI/ActionGroup.h>
#include <LibGUI/Application.h>
@ -111,7 +112,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (!ignore_path_resolution)
initial_location = Core::DeprecatedFile::real_path_for(initial_location);
if (!Core::DeprecatedFile::is_directory(initial_location)) {
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
if (path.has_extension(".zip"sv)) {
auto temp_directory = Core::TempFile::create_temp_directory();
@ -215,7 +216,7 @@ void do_create_link(Vector<DeprecatedString> const& selected_file_paths, GUI::Wi
{
auto path = selected_file_paths.first();
auto destination = DeprecatedString::formatted("{}/{}", Core::StandardPaths::desktop_directory(), LexicalPath::basename(path));
if (auto result = Core::DeprecatedFile::link_file(destination, path); result.is_error()) {
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::Type::Error);
}
@ -483,7 +484,7 @@ ErrorOr<int> run_in_desktop_mode()
}
for (auto& path : paths) {
if (Core::DeprecatedFile::is_directory(path))
if (FileSystem::is_directory(path))
Desktop::Launcher::open(URL::create_with_file_scheme(path));
}
});
@ -496,7 +497,7 @@ ErrorOr<int> run_in_desktop_mode()
}
for (auto& path : paths) {
if (Core::DeprecatedFile::is_directory(path)) {
if (FileSystem::is_directory(path)) {
spawn_terminal(path);
}
}
@ -821,7 +822,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
paths = directory_view->selected_file_paths();
for (auto& path : paths) {
if (Core::DeprecatedFile::is_directory(path))
if (FileSystem::is_directory(path))
Desktop::Launcher::open(URL::create_with_file_scheme(path));
}
},
@ -840,7 +841,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
paths = directory_view->selected_file_paths();
for (auto& path : paths) {
if (Core::DeprecatedFile::is_directory(path)) {
if (FileSystem::is_directory(path)) {
spawn_terminal(path);
}
}
@ -1092,7 +1093,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
(void)TRY(main_toolbar.try_add_action(directory_view->view_as_columns_action()));
breadcrumbbar.on_path_change = [&](auto selected_path) {
if (Core::DeprecatedFile::is_directory(selected_path)) {
if (FileSystem::is_directory(selected_path)) {
directory_view->open(selected_path);
} else {
dbgln("Breadcrumb path '{}' doesn't exist", selected_path);