diff --git a/Ladybird/CMakeLists.txt b/Ladybird/CMakeLists.txt index 14fcccf22dd..939f9f237b2 100644 --- a/Ladybird/CMakeLists.txt +++ b/Ladybird/CMakeLists.txt @@ -97,7 +97,7 @@ set(SOURCES qt_add_executable(ladybird ${SOURCES} MANUAL_FINALIZATION ) -target_link_libraries(ladybird PRIVATE Qt::Core Qt::Gui Qt::Network Qt::Widgets LibCore LibGfx LibGUI LibIPC LibJS LibMain LibWeb LibWebView LibSQL) +target_link_libraries(ladybird PRIVATE Qt::Core Qt::Gui Qt::Network Qt::Widgets LibCore LibFileSystem LibGfx LibGUI LibIPC LibJS LibMain LibWeb LibWebView LibSQL) target_include_directories(ladybird PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Applications/) @@ -110,7 +110,7 @@ qt_add_executable(headless-browser Utilities.cpp) target_include_directories(headless-browser PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -target_link_libraries(headless-browser PRIVATE Qt::Core LibWeb LibWebView LibWebSocket LibCrypto LibGemini LibHTTP LibJS LibGfx LibMain LibTLS LibIPC LibJS) +target_link_libraries(headless-browser PRIVATE Qt::Core LibWeb LibWebView LibWebSocket LibCrypto LibFileSystem LibGemini LibHTTP LibJS LibGfx LibMain LibTLS LibIPC LibJS) set_target_properties(ladybird PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER org.serenityos.ladybird diff --git a/Ladybird/SQLServer/CMakeLists.txt b/Ladybird/SQLServer/CMakeLists.txt index 9859398b6d2..b960ff79b34 100644 --- a/Ladybird/SQLServer/CMakeLists.txt +++ b/Ladybird/SQLServer/CMakeLists.txt @@ -11,4 +11,4 @@ qt_add_executable(SQLServer ${SQL_SERVER_SOURCES}) target_include_directories(SQLServer PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Services/) target_include_directories(SQLServer PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/..) -target_link_libraries(SQLServer PRIVATE Qt::Core Qt::Gui Qt::Network LibCore LibIPC LibSQL LibMain) +target_link_libraries(SQLServer PRIVATE Qt::Core Qt::Gui Qt::Network LibCore LibFileSystem LibIPC LibSQL LibMain) diff --git a/Ladybird/Utilities.cpp b/Ladybird/Utilities.cpp index 4f0fa2de5aa..1c052611a63 100644 --- a/Ladybird/Utilities.cpp +++ b/Ladybird/Utilities.cpp @@ -9,7 +9,7 @@ #include "Utilities.h" #include #include -#include +#include #include DeprecatedString s_serenity_resource_root; @@ -49,7 +49,7 @@ void platform_init() auto* home = getenv("XDG_CONFIG_HOME") ?: getenv("HOME"); VERIFY(home); auto home_lagom = DeprecatedString::formatted("{}/.lagom", home); - if (Core::DeprecatedFile::is_directory(home_lagom)) + if (FileSystem::is_directory(home_lagom)) return home_lagom; auto app_dir = ak_deprecated_string_from_qstring(QCoreApplication::applicationDirPath()); return LexicalPath(app_dir).parent().append("share"sv).string(); diff --git a/Ladybird/WebContent/CMakeLists.txt b/Ladybird/WebContent/CMakeLists.txt index 298a45ead82..b2b5864702f 100644 --- a/Ladybird/WebContent/CMakeLists.txt +++ b/Ladybird/WebContent/CMakeLists.txt @@ -22,4 +22,4 @@ qt_add_executable(WebContent ${WEBCONTENT_SOURCES}) target_include_directories(WebContent PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Services/) target_include_directories(WebContent PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/..) -target_link_libraries(WebContent PRIVATE Qt::Core Qt::Gui Qt::Network LibCore LibGfx LibIPC LibJS LibMain LibWeb LibWebSocket) +target_link_libraries(WebContent PRIVATE Qt::Core Qt::Gui Qt::Network LibCore LibFileSystem LibGfx LibIPC LibJS LibMain LibWeb LibWebSocket) diff --git a/Ladybird/WebDriver/CMakeLists.txt b/Ladybird/WebDriver/CMakeLists.txt index f10b05ada02..72dcd2e5474 100644 --- a/Ladybird/WebDriver/CMakeLists.txt +++ b/Ladybird/WebDriver/CMakeLists.txt @@ -15,5 +15,5 @@ target_include_directories(WebDriver PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) target_include_directories(WebDriver PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/..) target_include_directories(WebDriver PRIVATE ${SERENITY_SOURCE_DIR}/Userland) target_include_directories(WebDriver PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Services) -target_link_libraries(WebDriver PRIVATE Qt::Core Qt::Network LibCore LibGfx LibIPC LibJS LibMain LibWeb LibWebSocket) +target_link_libraries(WebDriver PRIVATE Qt::Core Qt::Network LibCore LibFileSystem LibGfx LibIPC LibJS LibMain LibWeb LibWebSocket) add_dependencies(WebDriver headless-browser) diff --git a/Ladybird/main.cpp b/Ladybird/main.cpp index 4f04b9e7d90..f6176ba14d4 100644 --- a/Ladybird/main.cpp +++ b/Ladybird/main.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -76,7 +77,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto get_formatted_url = [&](StringView const& raw_url) -> URL { URL url = raw_url; - if (Core::DeprecatedFile::exists(raw_url)) + if (FileSystem::exists(raw_url)) url = URL::create_with_file_scheme(Core::DeprecatedFile::real_path_for(raw_url)); else if (!url.is_valid()) url = DeprecatedString::formatted("http://{}", raw_url); diff --git a/Meta/CMake/utils.cmake b/Meta/CMake/utils.cmake index 9970e87f72b..76f4ef5ad53 100644 --- a/Meta/CMake/utils.cmake +++ b/Meta/CMake/utils.cmake @@ -122,7 +122,7 @@ if (NOT COMMAND serenity_test) add_dependencies(ComponentTests ${test_name}) set_target_properties(${test_name} PROPERTIES EXCLUDE_FROM_ALL TRUE) serenity_set_implicit_links(${test_name}) - target_link_libraries(${test_name} PRIVATE LibTest LibCore) + target_link_libraries(${test_name} PRIVATE LibTest LibCore LibFileSystem) foreach(lib ${SERENITY_TEST_LIBS}) target_link_libraries(${test_name} PRIVATE ${lib}) endforeach() @@ -135,7 +135,7 @@ function(serenity_testjs_test test_src sub_dir) if ("${SERENITY_TEST_CUSTOM_MAIN}" STREQUAL "") set(SERENITY_TEST_CUSTOM_MAIN "$") endif() - list(APPEND SERENITY_TEST_LIBS LibJS LibCore) + list(APPEND SERENITY_TEST_LIBS LibJS LibCore LibFileSystem) serenity_test(${test_src} ${sub_dir} CUSTOM_MAIN "${SERENITY_TEST_CUSTOM_MAIN}" LIBS ${SERENITY_TEST_LIBS}) diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt index fcea6058f12..d7d93499959 100644 --- a/Meta/Lagom/CMakeLists.txt +++ b/Meta/Lagom/CMakeLists.txt @@ -251,7 +251,7 @@ function(lagom_test source) cmake_parse_arguments(LAGOM_TEST "" "WORKING_DIRECTORY" "LIBS" ${ARGN}) get_filename_component(name ${source} NAME_WE) add_executable(${name} ${source}) - target_link_libraries(${name} PRIVATE LibCore LibTest LibTestMain ${LAGOM_TEST_LIBS}) + target_link_libraries(${name} PRIVATE LibCore LibFileSystem LibTest LibTestMain ${LAGOM_TEST_LIBS}) add_test( NAME ${name} COMMAND ${name} @@ -346,6 +346,10 @@ target_sources(LibCore PRIVATE ${AK_SOURCES}) # LibMain add_serenity_subdirectory(Userland/Libraries/LibMain) +# LibFileSystem +# This is needed even if Lagom is not enabled because it is depended upon by code generators. +add_serenity_subdirectory(Userland/Libraries/LibFileSystem) + # LibTimeZone # This is needed even if Lagom is not enabled because it is depended upon by code generators. add_serenity_subdirectory(Userland/Libraries/LibTimeZone) @@ -524,7 +528,7 @@ if (BUILD_LAGOM) endif() add_executable(markdown-check ../../Userland/Utilities/markdown-check.cpp) - target_link_libraries(markdown-check LibMarkdown LibMain) + target_link_libraries(markdown-check LibFileSystem LibMarkdown LibMain) if (NOT EMSCRIPTEN) add_executable(ntpquery ../../Userland/Utilities/ntpquery.cpp) @@ -532,10 +536,10 @@ if (BUILD_LAGOM) endif() add_executable(sql ../../Userland/Utilities/sql.cpp) - target_link_libraries(sql LibCore LibIPC LibLine LibMain LibSQL) + target_link_libraries(sql LibCore LibFileSystem LibIPC LibLine LibMain LibSQL) add_executable(test262-runner ../../Tests/LibJS/test262-runner.cpp) - target_link_libraries(test262-runner LibJS LibCore) + target_link_libraries(test262-runner LibJS LibCore LibFileSystem) if (CMAKE_SYSTEM_NAME STREQUAL "Linux") include(CheckCSourceCompiles) @@ -554,7 +558,7 @@ if (BUILD_LAGOM) endif() add_executable(wasm ../../Userland/Utilities/wasm.cpp) - target_link_libraries(wasm LibCore LibWasm LibLine LibMain LibJS) + target_link_libraries(wasm LibCore LibFileSystem LibWasm LibLine LibMain LibJS) add_executable(xml ../../Userland/Utilities/xml.cpp) target_link_libraries(xml LibCore LibXML LibMain) @@ -567,7 +571,7 @@ if (BUILD_LAGOM) LibTest ${LIBTEST_SOURCES} ) - target_link_libraries(LibTest PRIVATE LibCore) + target_link_libraries(LibTest PRIVATE LibCore LibFileSystem) set_target_properties(LibTest PROPERTIES OUTPUT_NAME lagom-test) add_library( LibTestMain @@ -622,7 +626,7 @@ if (BUILD_LAGOM) add_executable(test-js ../../Tests/LibJS/test-js.cpp ../../Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp) - target_link_libraries(test-js LibCore LibTest LibJS) + target_link_libraries(test-js LibCore LibFileSystem LibTest LibJS) add_test( NAME JS COMMAND test-js --show-progress=false @@ -638,7 +642,7 @@ if (BUILD_LAGOM) add_executable(test-spreadsheet ../../Tests/Spreadsheet/test-spreadsheet.cpp ../../Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp) - target_link_libraries(test-spreadsheet LibCore LibTest LibJS) + target_link_libraries(test-spreadsheet LibCore LibFileSystem LibTest LibJS) add_test( NAME Spreadsheet COMMAND test-spreadsheet --show-progress=false @@ -649,7 +653,7 @@ if (BUILD_LAGOM) add_executable(test-wasm ../../Tests/LibWasm/test-wasm.cpp ../../Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp) - target_link_libraries(test-wasm LibCore LibTest LibWasm LibJS) + target_link_libraries(test-wasm LibCore LibFileSystem LibTest LibWasm LibJS) add_test( NAME WasmParser COMMAND test-wasm --show-progress=false ${CMAKE_CURRENT_BINARY_DIR}/Userland/Libraries/LibWasm/Tests diff --git a/Meta/Lagom/Tools/CMakeLists.txt b/Meta/Lagom/Tools/CMakeLists.txt index e81eff13dea..3ef0940925b 100644 --- a/Meta/Lagom/Tools/CMakeLists.txt +++ b/Meta/Lagom/Tools/CMakeLists.txt @@ -3,7 +3,7 @@ function(lagom_tool tool) add_executable(${tool} ${SOURCES} ${LAGOM_TOOL_SOURCES}) # alias for parity with exports add_executable(Lagom::${tool} ALIAS ${tool}) - target_link_libraries(${tool} LibCore ${LAGOM_TOOL_LIBS}) + target_link_libraries(${tool} LibCore LibFileSystem ${LAGOM_TOOL_LIBS}) install( TARGETS ${tool} EXPORT LagomTargets diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp index 8e55575b86b..9fb8e78f032 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp @@ -19,8 +19,8 @@ #include #include #include -#include #include +#include static DeprecatedString format_identifier(StringView owner, DeprecatedString identifier) { @@ -913,7 +913,7 @@ static ErrorOr parse_all_locales(DeprecatedString bcp47_path, DeprecatedSt { LexicalPath core_supplemental_path(core_path); core_supplemental_path = core_supplemental_path.append("supplemental"sv); - VERIFY(Core::DeprecatedFile::is_directory(core_supplemental_path.string())); + VERIFY(FileSystem::is_directory(core_supplemental_path.string())); TRY(parse_core_aliases(core_supplemental_path.string(), cldr)); TRY(parse_likely_subtags(core_supplemental_path.string(), cldr)); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp index 5e7046ce481..b8a1d17501a 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp @@ -23,8 +23,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -700,7 +700,7 @@ static ErrorOr parse_all_locales(DeprecatedString core_path, DeprecatedStr { LexicalPath core_supplemental_path(move(core_path)); core_supplemental_path = core_supplemental_path.append("supplemental"sv); - VERIFY(Core::DeprecatedFile::is_directory(core_supplemental_path.string())); + VERIFY(FileSystem::is_directory(core_supplemental_path.string())); TRY(parse_number_system_digits(core_supplemental_path.string(), cldr)); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp index 2b24c31710c..c0908738daa 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp @@ -14,8 +14,8 @@ #include #include #include -#include #include +#include #include static DeprecatedString format_identifier(StringView owner, DeprecatedString identifier) @@ -396,7 +396,7 @@ static ErrorOr parse_all_locales(DeprecatedString core_path, DeprecatedStr { LexicalPath core_supplemental_path(move(core_path)); core_supplemental_path = core_supplemental_path.append("supplemental"sv); - VERIFY(Core::DeprecatedFile::is_directory(core_supplemental_path.string())); + VERIFY(FileSystem::is_directory(core_supplemental_path.string())); auto remove_variants_from_path = [&](DeprecatedString path) -> ErrorOr { auto parsed_locale = TRY(CanonicalLanguageID::parse(cldr.unique_strings, LexicalPath::basename(path))); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp index 09a3dab1c09..e9adbab855f 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp @@ -12,8 +12,8 @@ #include #include #include -#include #include +#include #include struct Emoji { @@ -47,7 +47,7 @@ static void set_image_path_for_emoji(StringView emoji_resource_path, EmojiData& auto file = DeprecatedString::formatted("{}.png", builder.to_deprecated_string()); auto path = DeprecatedString::formatted("{}/{}", emoji_resource_path, file); - if (!Core::DeprecatedFile::exists(path)) + if (!FileSystem::exists(path)) return; emoji.image_path = emoji_data.unique_strings.ensure(move(file)); @@ -396,7 +396,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_option(emoji_resource_path, "Path to the /res/emoji directory", "emoji-resource-path", 'r', "emoji-resource-path"); args_parser.parse(arguments); - VERIFY(!emoji_resource_path.is_empty() && Core::DeprecatedFile::exists(emoji_resource_path)); + VERIFY(!emoji_resource_path.is_empty() && FileSystem::exists(emoji_resource_path)); auto emoji_test_file = TRY(open_file(emoji_test_path, Core::File::OpenMode::Read)); diff --git a/Meta/Lagom/Tools/ConfigureComponents/main.cpp b/Meta/Lagom/Tools/ConfigureComponents/main.cpp index e356589b0cf..4741b1da35a 100644 --- a/Meta/Lagom/Tools/ConfigureComponents/main.cpp +++ b/Meta/Lagom/Tools/ConfigureComponents/main.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -241,7 +242,7 @@ int main() return 1; } - if (!Core::DeprecatedFile::exists("components.ini"sv)) { + if (!FileSystem::exists("components.ini"sv)) { warnln("\e[31mError:\e[0m There is no 'components.ini' in the current working directory."); warnln(" It can be generated by running CMake with 'cmake ../.. -G Ninja'"); return 1; diff --git a/Tests/LibJS/CMakeLists.txt b/Tests/LibJS/CMakeLists.txt index 20d42a2a1cd..08b8bf97b77 100644 --- a/Tests/LibJS/CMakeLists.txt +++ b/Tests/LibJS/CMakeLists.txt @@ -27,6 +27,6 @@ serenity_component( TARGETS test-test262 ) add_executable(test-test262 test-test262.cpp) -target_link_libraries(test-test262 PRIVATE LibMain LibCore) +target_link_libraries(test-test262 PRIVATE LibMain LibCore LibFileSystem) serenity_set_implicit_links(test-test262) install(TARGETS test-test262 RUNTIME DESTINATION bin OPTIONAL) diff --git a/Tests/LibJS/test-test262.cpp b/Tests/LibJS/test-test262.cpp index a1ec4dce441..c6419def1c0 100644 --- a/Tests/LibJS/test-test262.cpp +++ b/Tests/LibJS/test-test262.cpp @@ -13,10 +13,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include @@ -322,7 +322,7 @@ ErrorOr serenity_main(Main::Arguments arguments) // Normalize the path to ensure filenames are consistent Vector paths; - if (!Core::DeprecatedFile::is_directory(test_directory)) { + if (!FileSystem::is_directory(test_directory)) { paths.append(test_directory); } else { Test::iterate_directory_recursively(LexicalPath::canonicalized_path(test_directory), [&](DeprecatedString const& file_path) { diff --git a/Tests/LibTLS/TestTLSHandshake.cpp b/Tests/LibTLS/TestTLSHandshake.cpp index 8453445f4ef..f3ff6c6fa9a 100644 --- a/Tests/LibTLS/TestTLSHandshake.cpp +++ b/Tests/LibTLS/TestTLSHandshake.cpp @@ -6,10 +6,10 @@ #include #include -#include #include #include #include +#include #include #include @@ -28,11 +28,11 @@ DeprecatedString locate_ca_certs_file(); DeprecatedString locate_ca_certs_file() { - if (Core::DeprecatedFile::exists(ca_certs_file)) { + if (FileSystem::exists(ca_certs_file)) { return ca_certs_file; } auto on_target_path = DeprecatedString("/etc/cacert.pem"); - if (Core::DeprecatedFile::exists(on_target_path)) { + if (FileSystem::exists(on_target_path)) { return on_target_path; } return ""; diff --git a/Userland/Applications/Browser/CMakeLists.txt b/Userland/Applications/Browser/CMakeLists.txt index 908c036417d..e51c8ebe91e 100644 --- a/Userland/Applications/Browser/CMakeLists.txt +++ b/Userland/Applications/Browser/CMakeLists.txt @@ -41,5 +41,5 @@ set(GENERATED_SOURCES ) serenity_app(Browser ICON app-browser) -target_link_libraries(Browser PRIVATE LibCore LibWebView LibWeb LibProtocol LibGUI LibDesktop LibConfig LibGfx LibIPC LibJS LibLocale LibMain LibSyntax LibSQL) +target_link_libraries(Browser PRIVATE LibCore LibFileSystem LibWebView LibWeb LibProtocol LibGUI LibDesktop LibConfig LibGfx LibIPC LibJS LibLocale LibMain LibSyntax LibSQL) link_with_locale_data(Browser) diff --git a/Userland/Applications/Browser/main.cpp b/Userland/Applications/Browser/main.cpp index 1d9738ab2ba..d485e9bd1ab 100644 --- a/Userland/Applications/Browser/main.cpp +++ b/Userland/Applications/Browser/main.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -131,7 +132,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } auto url_from_argument_string = [](DeprecatedString const& string) -> URL { - if (Core::DeprecatedFile::exists(string)) { + if (FileSystem::exists(string)) { return URL::create_with_file_scheme(Core::DeprecatedFile::real_path_for(string)); } return Browser::url_from_user_input(string); diff --git a/Userland/Applications/CrashReporter/CMakeLists.txt b/Userland/Applications/CrashReporter/CMakeLists.txt index 12bab1e8f57..e6da9f0168e 100644 --- a/Userland/Applications/CrashReporter/CMakeLists.txt +++ b/Userland/Applications/CrashReporter/CMakeLists.txt @@ -16,4 +16,4 @@ set(GENERATED_SOURCES ) serenity_app(CrashReporter ICON app-crash-reporter) -target_link_libraries(CrashReporter PRIVATE LibCore LibCoredump LibDebug LibDesktop LibFileSystemAccessClient LibGfx LibGUI LibMain LibThreading) +target_link_libraries(CrashReporter PRIVATE LibCore LibCoredump LibDebug LibDesktop LibFileSystem LibFileSystemAccessClient LibGfx LibGUI LibMain LibThreading) diff --git a/Userland/Applications/CrashReporter/main.cpp b/Userland/Applications/CrashReporter/main.cpp index 03d7c8adea2..978a0606440 100644 --- a/Userland/Applications/CrashReporter/main.cpp +++ b/Userland/Applications/CrashReporter/main.cpp @@ -12,13 +12,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include @@ -131,7 +131,7 @@ static TitleAndText build_cpu_registers(const ELF::Core::ThreadInfo& thread_info static void unlink_coredump(StringView coredump_path) { - if (Core::DeprecatedFile::remove(coredump_path, Core::DeprecatedFile::RecursionMode::Disallowed).is_error()) + if (FileSystem::remove(coredump_path, FileSystem::RecursionMode::Disallowed).is_error()) dbgln("Failed deleting coredump file"); } diff --git a/Userland/Applications/FileManager/CMakeLists.txt b/Userland/Applications/FileManager/CMakeLists.txt index be9447af5bd..548c0ed585a 100644 --- a/Userland/Applications/FileManager/CMakeLists.txt +++ b/Userland/Applications/FileManager/CMakeLists.txt @@ -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) diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp index 8c1713ba55b..4d9b182cfbf 100644 --- a/Userland/Applications/FileManager/DirectoryView.cpp +++ b/Userland/Applications/FileManager/DirectoryView.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -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 } diff --git a/Userland/Applications/FileManager/FileUtils.cpp b/Userland/Applications/FileManager/FileUtils.cpp index 0388701ed34..4e8d4c79aa6 100644 --- a/Userland/Applications/FileManager/FileUtils.cpp +++ b/Userland/Applications/FileManager/FileUtils.cpp @@ -8,9 +8,9 @@ #include "FileUtils.h" #include "FileOperationProgressWidget.h" #include -#include #include #include +#include #include #include #include @@ -124,7 +124,7 @@ ErrorOr 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 paths_to_copy; diff --git a/Userland/Applications/FileManager/PropertiesWindow.cpp b/Userland/Applications/FileManager/PropertiesWindow.cpp index 8c661899602..2ce754edfb6 100644 --- a/Userland/Applications/FileManager/PropertiesWindow.cpp +++ b/Userland/Applications/FileManager/PropertiesWindow.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -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; } diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index 6e67a5d90ab..fcd46dbd67f 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -111,7 +112,7 @@ ErrorOr 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 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 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 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 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 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 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); diff --git a/Userland/Applications/PartitionEditor/CMakeLists.txt b/Userland/Applications/PartitionEditor/CMakeLists.txt index cbf99f0f560..79294f42f03 100644 --- a/Userland/Applications/PartitionEditor/CMakeLists.txt +++ b/Userland/Applications/PartitionEditor/CMakeLists.txt @@ -15,4 +15,4 @@ set(GENERATED_SOURCES ) serenity_app(PartitionEditor ICON app-partition-editor) -target_link_libraries(PartitionEditor PRIVATE LibCore LibGfx LibMain LibGUI LibPartition) +target_link_libraries(PartitionEditor PRIVATE LibCore LibFileSystem LibGfx LibMain LibGUI LibPartition) diff --git a/Userland/Applications/PartitionEditor/PartitionModel.cpp b/Userland/Applications/PartitionEditor/PartitionModel.cpp index 73f7da320eb..90859254e4c 100644 --- a/Userland/Applications/PartitionEditor/PartitionModel.cpp +++ b/Userland/Applications/PartitionEditor/PartitionModel.cpp @@ -13,6 +13,11 @@ namespace PartitionEditor { +NonnullRefPtr PartitionModel::create() +{ + return adopt_ref(*new PartitionModel); +} + DeprecatedString PartitionModel::column_name(int column) const { switch (column) { diff --git a/Userland/Applications/PartitionEditor/PartitionModel.h b/Userland/Applications/PartitionEditor/PartitionModel.h index a54165062fb..e7ce742a2b7 100644 --- a/Userland/Applications/PartitionEditor/PartitionModel.h +++ b/Userland/Applications/PartitionEditor/PartitionModel.h @@ -22,7 +22,7 @@ public: __Count, }; - static NonnullRefPtr create() { return adopt_ref(*new PartitionModel()); } + static NonnullRefPtr create(); virtual ~PartitionModel() override = default; virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override { return m_partition_table->partitions_count(); } diff --git a/Userland/Applications/PartitionEditor/main.cpp b/Userland/Applications/PartitionEditor/main.cpp index ad1cb4c15b2..202726fe591 100644 --- a/Userland/Applications/PartitionEditor/main.cpp +++ b/Userland/Applications/PartitionEditor/main.cpp @@ -6,9 +6,9 @@ #include #include -#include #include #include +#include #include #include #include @@ -23,7 +23,7 @@ static Vector get_device_paths() // FIXME: Propagate errors. (void)Core::Directory::for_each_entry("/dev"sv, Core::DirIterator::Flags::SkipParentAndBaseDir, [&](auto const& entry, auto const& directory) -> ErrorOr { auto full_path = LexicalPath::join(directory.path().string(), entry.name).string(); - if (Core::DeprecatedFile::is_block_device(full_path)) + if (FileSystem::is_block_device(full_path)) device_paths.append(full_path); return IterationDecision::Continue; }); diff --git a/Userland/Applications/SoundPlayer/AlbumCoverVisualizationWidget.cpp b/Userland/Applications/SoundPlayer/AlbumCoverVisualizationWidget.cpp index 3eeda05ed70..5c56a5bdaa3 100644 --- a/Userland/Applications/SoundPlayer/AlbumCoverVisualizationWidget.cpp +++ b/Userland/Applications/SoundPlayer/AlbumCoverVisualizationWidget.cpp @@ -8,7 +8,7 @@ #include "AlbumCoverVisualizationWidget.h" #include -#include +#include #include #include @@ -48,7 +48,7 @@ ErrorOr> AlbumCoverVisualizationWidget::get_album_cov static constexpr auto possible_cover_filenames = Array { "cover.png"sv, "cover.jpg"sv }; for (auto& it : possible_cover_filenames) { LexicalPath cover_path = LexicalPath::join(directory, it); - if (Core::DeprecatedFile::exists(cover_path.string())) + if (FileSystem::exists(cover_path.string())) return Gfx::Bitmap::load_from_file(cover_path.string()); } diff --git a/Userland/Applications/SoundPlayer/CMakeLists.txt b/Userland/Applications/SoundPlayer/CMakeLists.txt index c827fc42b35..66926eb5e48 100644 --- a/Userland/Applications/SoundPlayer/CMakeLists.txt +++ b/Userland/Applications/SoundPlayer/CMakeLists.txt @@ -19,4 +19,4 @@ set(SOURCES ) serenity_app(SoundPlayer ICON app-sound-player) -target_link_libraries(SoundPlayer PRIVATE LibAudio LibConfig LibCore LibDSP LibGfx LibGUI LibIPC LibMain LibThreading LibImageDecoderClient) +target_link_libraries(SoundPlayer PRIVATE LibAudio LibConfig LibCore LibFileSystem LibDSP LibGfx LibGUI LibIPC LibMain LibThreading LibImageDecoderClient) diff --git a/Userland/Applications/SoundPlayer/Player.cpp b/Userland/Applications/SoundPlayer/Player.cpp index af254a04809..41c874cdd0e 100644 --- a/Userland/Applications/SoundPlayer/Player.cpp +++ b/Userland/Applications/SoundPlayer/Player.cpp @@ -7,7 +7,7 @@ #include "Player.h" #include -#include +#include Player::Player(Audio::ConnectionToServer& audio_client_connection) : m_audio_client_connection(audio_client_connection) @@ -44,7 +44,7 @@ void Player::play_file_path(DeprecatedString const& path) if (path.is_null()) return; - if (!Core::DeprecatedFile::exists(path)) { + if (!FileSystem::exists(path)) { audio_load_error(path, "File does not exist"sv); return; } diff --git a/Userland/Applications/SoundPlayer/Playlist.cpp b/Userland/Applications/SoundPlayer/Playlist.cpp index 63bd4e97742..6e841291eda 100644 --- a/Userland/Applications/SoundPlayer/Playlist.cpp +++ b/Userland/Applications/SoundPlayer/Playlist.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include bool Playlist::load(StringView path) @@ -39,11 +39,11 @@ void Playlist::try_fill_missing_info(Vector& entries, StringView path) entry.path = DeprecatedString::formatted("{}/{}", playlist_path.dirname(), entry.path); if (!entry.extended_info->file_size_in_bytes.has_value()) { - auto size = Core::DeprecatedFile::size(entry.path); + auto size = FileSystem::size(entry.path); if (size.is_error()) continue; entry.extended_info->file_size_in_bytes = size.value(); - } else if (!Core::DeprecatedFile::exists(entry.path)) { + } else if (!FileSystem::exists(entry.path)) { to_delete.append(&entry); continue; } diff --git a/Userland/Applications/SpaceAnalyzer/CMakeLists.txt b/Userland/Applications/SpaceAnalyzer/CMakeLists.txt index 6783b80b204..a6f1e4c3c48 100644 --- a/Userland/Applications/SpaceAnalyzer/CMakeLists.txt +++ b/Userland/Applications/SpaceAnalyzer/CMakeLists.txt @@ -17,4 +17,4 @@ set(GENERATED_SOURCES ) serenity_app(SpaceAnalyzer ICON app-space-analyzer) -target_link_libraries(SpaceAnalyzer PRIVATE LibCore LibDesktop LibGfx LibGUI LibIPC LibMain) +target_link_libraries(SpaceAnalyzer PRIVATE LibCore LibDesktop LibFileSystem LibGfx LibGUI LibIPC LibMain) diff --git a/Userland/Applications/SpaceAnalyzer/main.cpp b/Userland/Applications/SpaceAnalyzer/main.cpp index 4a83bbef40d..7fb7eef6267 100644 --- a/Userland/Applications/SpaceAnalyzer/main.cpp +++ b/Userland/Applications/SpaceAnalyzer/main.cpp @@ -11,8 +11,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -84,7 +84,7 @@ ErrorOr serenity_main(Main::Arguments arguments) if (path_string.is_empty()) return; - if (Core::DeprecatedFile::is_directory(path_string)) { + if (FileSystem::is_directory(path_string)) { Desktop::Launcher::open(URL::create_with_file_scheme(path_string)); return; } @@ -102,7 +102,7 @@ ErrorOr serenity_main(Main::Arguments arguments) while (try_again) { try_again = false; - auto deletion_result = Core::DeprecatedFile::remove(selected_node_path, Core::DeprecatedFile::RecursionMode::Allowed); + auto deletion_result = FileSystem::remove(selected_node_path, FileSystem::RecursionMode::Allowed); if (deletion_result.is_error()) { auto retry_message_result = GUI::MessageBox::show(window, DeprecatedString::formatted("Failed to delete \"{}\": {}. Retry?", @@ -168,8 +168,8 @@ ErrorOr serenity_main(Main::Arguments arguments) DeprecatedString selected_node_path = get_absolute_path_to_selected_node(tree_map_widget); if (selected_node_path.is_empty()) return; - delete_action->set_enabled(Core::DeprecatedFile::can_delete_or_move(selected_node_path)); - if (Core::DeprecatedFile::is_directory(selected_node_path)) + delete_action->set_enabled(FileSystem::can_delete_or_move(selected_node_path)); + if (FileSystem::is_directory(selected_node_path)) open_action->set_text("Open in File Manager"); else open_action->set_text("Reveal in File Manager"); diff --git a/Userland/Applications/Spreadsheet/CMakeLists.txt b/Userland/Applications/Spreadsheet/CMakeLists.txt index 1e6753198c7..e4affa4cb41 100644 --- a/Userland/Applications/Spreadsheet/CMakeLists.txt +++ b/Userland/Applications/Spreadsheet/CMakeLists.txt @@ -42,7 +42,7 @@ set(GENERATED_SOURCES ) serenity_app(Spreadsheet ICON app-spreadsheet) -target_link_libraries(Spreadsheet PRIVATE LibCore LibFileSystemAccessClient LibGfx LibGUI LibJS LibMain LibMarkdown LibSyntax LibWebView LibWeb) +target_link_libraries(Spreadsheet PRIVATE LibCore LibFileSystem LibFileSystemAccessClient LibGfx LibGUI LibJS LibMain LibMarkdown LibSyntax LibWebView LibWeb) serenity_test(Writers/Test/TestXSVWriter.cpp Spreadsheet) diff --git a/Userland/Applications/Spreadsheet/main.cpp b/Userland/Applications/Spreadsheet/main.cpp index d7599cc235f..bd1cc8a8a04 100644 --- a/Userland/Applications/Spreadsheet/main.cpp +++ b/Userland/Applications/Spreadsheet/main.cpp @@ -10,8 +10,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -34,7 +34,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.parse(arguments); if (!filename.is_empty()) { - if (!Core::DeprecatedFile::exists(filename) || Core::DeprecatedFile::is_directory(filename)) { + if (!FileSystem::exists(filename) || FileSystem::is_directory(filename)) { warnln("File does not exist or is a directory: {}", filename); return 1; } diff --git a/Userland/Applications/ThemeEditor/CMakeLists.txt b/Userland/Applications/ThemeEditor/CMakeLists.txt index fcb9b9fbc3c..95ee3c629c4 100644 --- a/Userland/Applications/ThemeEditor/CMakeLists.txt +++ b/Userland/Applications/ThemeEditor/CMakeLists.txt @@ -28,4 +28,4 @@ set(GENERATED_SOURCES ) serenity_app(ThemeEditor ICON app-theme-editor) -target_link_libraries(ThemeEditor PRIVATE LibCore LibGfx LibGUI LibFileSystemAccessClient LibIPC LibMain) +target_link_libraries(ThemeEditor PRIVATE LibCore LibGfx LibGUI LibFileSystem LibFileSystemAccessClient LibIPC LibMain) diff --git a/Userland/Applications/ThemeEditor/MainWidget.cpp b/Userland/Applications/ThemeEditor/MainWidget.cpp index 74c217a6fca..f2a812c9c84 100644 --- a/Userland/Applications/ThemeEditor/MainWidget.cpp +++ b/Userland/Applications/ThemeEditor/MainWidget.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include @@ -591,8 +591,8 @@ void MainWidget::show_path_picker_dialog(StringView property_display_name, GUI:: bool open_folder = path_picker_target == PathPickerTarget::Folder; auto window_title = DeprecatedString::formatted(open_folder ? "Select {} folder"sv : "Select {} file"sv, property_display_name); auto target_path = path_input.text(); - if (Core::DeprecatedFile::exists(target_path)) { - if (!Core::DeprecatedFile::is_directory(target_path)) + if (FileSystem::exists(target_path)) { + if (!FileSystem::is_directory(target_path)) target_path = LexicalPath::dirname(target_path); } else { target_path = "/res/icons"; diff --git a/Userland/BuggieBox/CMakeLists.txt b/Userland/BuggieBox/CMakeLists.txt index fcd294ed8bb..2f2464e05b3 100644 --- a/Userland/BuggieBox/CMakeLists.txt +++ b/Userland/BuggieBox/CMakeLists.txt @@ -41,7 +41,7 @@ set(utility_srcs serenity_bin(BuggieBox) target_sources(BuggieBox PRIVATE main.cpp) -target_link_libraries(BuggieBox PRIVATE LibMain LibShell LibCompress LibCore LibCrypto LibGfx LibLine LibRegex LibAudio) +target_link_libraries(BuggieBox PRIVATE LibMain LibShell LibCompress LibCore LibCrypto LibFileSystem LibGfx LibLine LibRegex LibAudio) foreach(file IN LISTS utility_srcs) buggiebox_utility(${file}) diff --git a/Userland/DevTools/HackStudio/CMakeLists.txt b/Userland/DevTools/HackStudio/CMakeLists.txt index ecd3c084a27..92373ace9e8 100644 --- a/Userland/DevTools/HackStudio/CMakeLists.txt +++ b/Userland/DevTools/HackStudio/CMakeLists.txt @@ -54,5 +54,5 @@ set(GENERATED_SOURCES ) serenity_app(HackStudio ICON app-hack-studio) -target_link_libraries(HackStudio PRIVATE LibWebView LibWeb LibMarkdown LibGUI LibCpp LibCMake LibGfx LibCore LibVT LibDebug LibX86 LibDiff LibShell LibSymbolication LibSyntax LibRegex LibSQL LibConfig LibCore LibCoredump LibDesktop LibIPC LibJS LibMain LibThreading) +target_link_libraries(HackStudio PRIVATE LibWebView LibWeb LibMarkdown LibGUI LibCpp LibCMake LibGfx LibCore LibVT LibDebug LibX86 LibDiff LibShell LibSymbolication LibSyntax LibRegex LibSQL LibConfig LibCore LibCoredump LibDesktop LibFileSystem LibIPC LibJS LibMain LibThreading) add_dependencies(HackStudio CppLanguageServer) diff --git a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp index 597b50860c3..21fae01e087 100644 --- a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp +++ b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp @@ -12,8 +12,8 @@ #include #include -#include #include +#include #include #include #include @@ -150,7 +150,7 @@ Optional NewProjectDialog::get_available_project_name() ? chosen_name : DeprecatedString::formatted("{}-{}", chosen_name, i); - if (!Core::DeprecatedFile::exists(DeprecatedString::formatted("{}/{}", create_in, candidate))) + if (!FileSystem::exists(DeprecatedString::formatted("{}/{}", create_in, candidate))) return candidate; } @@ -188,7 +188,7 @@ void NewProjectDialog::do_create_project() } auto create_in = m_create_in_input->text(); - if (!Core::DeprecatedFile::exists(create_in) || !Core::DeprecatedFile::is_directory(create_in)) { + if (!FileSystem::exists(create_in) || !FileSystem::is_directory(create_in)) { auto result = GUI::MessageBox::show(this, DeprecatedString::formatted("The directory {} does not exist yet, would you like to create it?", create_in), "New project"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); if (result != GUI::MessageBox::ExecResult::Yes) return; diff --git a/Userland/DevTools/HackStudio/Editor.cpp b/Userland/DevTools/HackStudio/Editor.cpp index 0fe712fd441..ad0f9f81ac8 100644 --- a/Userland/DevTools/HackStudio/Editor.cpp +++ b/Userland/DevTools/HackStudio/Editor.cpp @@ -16,11 +16,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include @@ -424,7 +424,7 @@ static HashMap& include_paths() Core::DirIterator it(recursive.value_or(base), Core::DirIterator::Flags::SkipDots); while (it.has_next()) { auto path = it.next_full_path(); - if (!Core::DeprecatedFile::is_directory(path)) { + if (!FileSystem::is_directory(path)) { auto key = path.substring(base.length() + 1, path.length() - base.length() - 1); dbgln_if(EDITOR_DEBUG, "Adding header \"{}\" in path \"{}\"", key, path); paths.set(key, path); diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index e631627a8d8..ae2b2a2a5d8 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -311,7 +312,7 @@ bool HackStudioWidget::open_file(DeprecatedString const& full_filename, size_t l if (full_filename.starts_with(project().root_path())) { filename = LexicalPath::relative_path(full_filename, project().root_path()); } - if (Core::DeprecatedFile::is_directory(filename) || !Core::DeprecatedFile::exists(filename)) + if (FileSystem::is_directory(filename) || !FileSystem::exists(filename)) return false; auto editor_wrapper_or_none = m_all_editor_wrappers.first_matching([&](auto& wrapper) { @@ -533,13 +534,13 @@ ErrorOr> HackStudioWidget::create_new_file_action(Dep DeprecatedString filepath; if (!path_to_selected.is_empty()) { - VERIFY(Core::DeprecatedFile::exists(path_to_selected.first())); + VERIFY(FileSystem::exists(path_to_selected.first())); LexicalPath selected(path_to_selected.first()); DeprecatedString dir_path; - if (Core::DeprecatedFile::is_directory(selected.string())) + if (FileSystem::is_directory(selected.string())) dir_path = selected.string(); else dir_path = selected.dirname(); @@ -573,7 +574,7 @@ ErrorOr> HackStudioWidget::create_new_directory_actio DeprecatedString dir_path; - if (Core::DeprecatedFile::is_directory(selected.string())) + if (FileSystem::is_directory(selected.string())) dir_path = selected.string(); else dir_path = selected.dirname(); @@ -681,7 +682,7 @@ NonnullRefPtr HackStudioWidget::create_delete_action() } bool is_directory = S_ISDIR(st.st_mode); - if (auto result = Core::DeprecatedFile::remove(file, Core::DeprecatedFile::RecursionMode::Allowed); result.is_error()) { + if (auto result = FileSystem::remove(file, FileSystem::RecursionMode::Allowed); result.is_error()) { auto& error = result.error(); if (is_directory) { GUI::MessageBox::show(window(), @@ -1001,7 +1002,7 @@ ErrorOr> HackStudioWidget::create_debug_action() { auto icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-run.png"sv)); return GUI::Action::create("&Debug", icon, [this](auto&) { - if (!Core::DeprecatedFile::exists(get_project_executable_path())) { + if (!FileSystem::exists(get_project_executable_path())) { GUI::MessageBox::show(window(), DeprecatedString::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error"sv, GUI::MessageBox::Type::Error); return; } @@ -1249,7 +1250,7 @@ void HackStudioWidget::configure_project_tree_view() auto selections = m_project_tree_view->selection().indices(); auto it = selections.find_if([&](auto selected_file) { - return Core::DeprecatedFile::can_delete_or_move(m_project->model().full_path(selected_file)); + return FileSystem::can_delete_or_move(m_project->model().full_path(selected_file)); }); bool has_permissions = it != selections.end(); m_tree_view_rename_action->set_enabled(has_permissions); @@ -1794,10 +1795,10 @@ ErrorOr> HackStudioWidget::create_open_project_config DeprecatedString formatted_error_string_holder; auto save_configuration_or_error = [&]() -> ErrorOr { - if (Core::DeprecatedFile::exists(absolute_config_file_path)) + if (FileSystem::exists(absolute_config_file_path)) return {}; - if (Core::DeprecatedFile::exists(parent_directory) && !Core::DeprecatedFile::is_directory(parent_directory)) { + if (FileSystem::exists(parent_directory) && !FileSystem::is_directory(parent_directory)) { formatted_error_string_holder = DeprecatedString::formatted("Cannot create the '{}' directory because there is already a file with that name", parent_directory); return Error::from_string_view(formatted_error_string_holder); } diff --git a/Userland/DevTools/HackStudio/Project.cpp b/Userland/DevTools/HackStudio/Project.cpp index f15a33fc6c9..1358958cc2a 100644 --- a/Userland/DevTools/HackStudio/Project.cpp +++ b/Userland/DevTools/HackStudio/Project.cpp @@ -6,7 +6,7 @@ #include "Project.h" #include "HackStudio.h" -#include +#include namespace HackStudio { @@ -18,7 +18,7 @@ Project::Project(DeprecatedString const& root_path) OwnPtr Project::open_with_root_path(DeprecatedString const& root_path) { - if (!Core::DeprecatedFile::is_directory(root_path)) + if (!FileSystem::is_directory(root_path)) return {}; return adopt_own(*new Project(root_path)); } diff --git a/Userland/DevTools/HackStudio/ProjectBuilder.cpp b/Userland/DevTools/HackStudio/ProjectBuilder.cpp index b18ee7a99e9..91f3141721f 100644 --- a/Userland/DevTools/HackStudio/ProjectBuilder.cpp +++ b/Userland/DevTools/HackStudio/ProjectBuilder.cpp @@ -7,7 +7,7 @@ #include "ProjectBuilder.h" #include #include -#include +#include #include #include #include @@ -124,15 +124,15 @@ ErrorOr ProjectBuilder::component_name(StringView cmake_file_p ErrorOr ProjectBuilder::initialize_build_directory() { - if (!Core::DeprecatedFile::exists(build_directory())) { + if (!FileSystem::exists(build_directory())) { if (mkdir(LexicalPath::join(build_directory()).string().characters(), 0700)) { return Error::from_errno(errno); } } auto cmake_file_path = LexicalPath::join(build_directory(), "CMakeLists.txt"sv).string(); - if (Core::DeprecatedFile::exists(cmake_file_path)) - MUST(Core::DeprecatedFile::remove(cmake_file_path, Core::DeprecatedFile::RecursionMode::Disallowed)); + if (FileSystem::exists(cmake_file_path)) + MUST(FileSystem::remove(cmake_file_path, FileSystem::RecursionMode::Disallowed)); auto cmake_file = TRY(Core::File::open(cmake_file_path, Core::File::OpenMode::Write)); TRY(cmake_file->write_until_depleted(generate_cmake_file_content().bytes())); @@ -150,7 +150,7 @@ Optional ProjectBuilder::find_cmake_file_for(StringView file_p auto directory = LexicalPath::dirname(file_path); while (!directory.is_empty()) { auto cmake_path = LexicalPath::join(m_project_root, directory, "CMakeLists.txt"sv); - if (Core::DeprecatedFile::exists(cmake_path.string())) + if (FileSystem::exists(cmake_path.string())) return cmake_path.string(); directory = LexicalPath::dirname(directory); } diff --git a/Userland/DevTools/HackStudio/ProjectTemplate.cpp b/Userland/DevTools/HackStudio/ProjectTemplate.cpp index 3f4983ab2ee..9f9b0892bdf 100644 --- a/Userland/DevTools/HackStudio/ProjectTemplate.cpp +++ b/Userland/DevTools/HackStudio/ProjectTemplate.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -52,7 +53,7 @@ RefPtr ProjectTemplate::load_from_manifest(DeprecatedString con auto bitmap_path_32 = DeprecatedString::formatted("/res/icons/hackstudio/templates-32x32/{}.png", config->read_entry("HackStudioTemplate", "IconName32x")); - if (Core::DeprecatedFile::exists(bitmap_path_32)) { + if (FileSystem::exists(bitmap_path_32)) { auto bitmap_or_error = Gfx::Bitmap::load_from_file(bitmap_path_32); if (!bitmap_or_error.is_error()) icon = GUI::Icon(bitmap_or_error.release_value()); @@ -64,14 +65,14 @@ RefPtr ProjectTemplate::load_from_manifest(DeprecatedString con Result ProjectTemplate::create_project(DeprecatedString const& name, DeprecatedString const& path) { // Check if a file or directory already exists at the project path - if (Core::DeprecatedFile::exists(path)) + if (FileSystem::exists(path)) return DeprecatedString("File or directory already exists at specified location."); dbgln("Creating project at path '{}' with name '{}'", path, name); // Verify that the template content directory exists. If it does, copy it's contents. // Otherwise, create an empty directory at the project path. - if (Core::DeprecatedFile::is_directory(content_path())) { + if (FileSystem::is_directory(content_path())) { auto result = Core::DeprecatedFile::copy_file_or_directory(path, content_path()); dbgln("Copying {} -> {}", content_path(), path); if (result.is_error()) diff --git a/Userland/DevTools/HackStudio/main.cpp b/Userland/DevTools/HackStudio/main.cpp index aaed97dadec..abf1777a21c 100644 --- a/Userland/DevTools/HackStudio/main.cpp +++ b/Userland/DevTools/HackStudio/main.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -140,7 +141,7 @@ static Optional last_opened_project_path() if (projects.size() == 0) return {}; - if (!Core::DeprecatedFile::exists(projects[0])) + if (!FileSystem::exists(projects[0])) return {}; return { projects[0] }; diff --git a/Userland/DevTools/Profiler/CMakeLists.txt b/Userland/DevTools/Profiler/CMakeLists.txt index 94bd3ea0e5a..bf3aa6b4cf8 100644 --- a/Userland/DevTools/Profiler/CMakeLists.txt +++ b/Userland/DevTools/Profiler/CMakeLists.txt @@ -24,4 +24,4 @@ set(SOURCES ) serenity_app(Profiler ICON app-profiler) -target_link_libraries(Profiler PRIVATE LibCore LibDebug LibGfx LibGUI LibDesktop LibX86 LibSymbolication LibMain) +target_link_libraries(Profiler PRIVATE LibCore LibDebug LibFileSystem LibGfx LibGUI LibDesktop LibX86 LibSymbolication LibMain) diff --git a/Userland/DevTools/Profiler/Process.cpp b/Userland/DevTools/Profiler/Process.cpp index 2fdcb376ea8..b21b2f45de1 100644 --- a/Userland/DevTools/Profiler/Process.cpp +++ b/Userland/DevTools/Profiler/Process.cpp @@ -5,7 +5,7 @@ */ #include "Process.h" -#include +#include namespace Profiler { @@ -93,7 +93,7 @@ void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, DeprecatedString co DeprecatedString full_path; if (path_string.starts_with('/')) full_path = path_string; - else if (Core::DeprecatedFile::looks_like_shared_library(path_string)) + else if (FileSystem::looks_like_shared_library(path_string)) full_path = DeprecatedString::formatted("/usr/lib/{}", path); else full_path = path_string; diff --git a/Userland/DevTools/SQLStudio/CMakeLists.txt b/Userland/DevTools/SQLStudio/CMakeLists.txt index 143734e7df2..3b181de45f3 100644 --- a/Userland/DevTools/SQLStudio/CMakeLists.txt +++ b/Userland/DevTools/SQLStudio/CMakeLists.txt @@ -17,4 +17,4 @@ set(GENERATED_SOURCES ) serenity_app(SQLStudio ICON app-sql-studio) -target_link_libraries(SQLStudio PRIVATE LibCore LibDesktop LibGfx LibGUI LibIPC LibMain LibSQL LibSyntax) +target_link_libraries(SQLStudio PRIVATE LibCore LibDesktop LibFileSystem LibGfx LibGUI LibIPC LibMain LibSQL LibSyntax) diff --git a/Userland/DevTools/SQLStudio/MainWidget.cpp b/Userland/DevTools/SQLStudio/MainWidget.cpp index c87992e3a60..78a2c3250f3 100644 --- a/Userland/DevTools/SQLStudio/MainWidget.cpp +++ b/Userland/DevTools/SQLStudio/MainWidget.cpp @@ -6,10 +6,10 @@ */ #include -#include #include #include #include +#include #include #include #include @@ -45,7 +45,7 @@ static Vector lookup_database_names() static constexpr auto database_extension = ".db"sv; auto database_path = DeprecatedString::formatted("{}/sql", Core::StandardPaths::data_directory()); - if (!Core::DeprecatedFile::exists(database_path)) + if (!FileSystem::exists(database_path)) return {}; Core::DirIterator iterator(move(database_path), Core::DirIterator::SkipParentAndBaseDir); diff --git a/Userland/DevTools/UserspaceEmulator/CMakeLists.txt b/Userland/DevTools/UserspaceEmulator/CMakeLists.txt index 73b4daa3bd4..7135ba09aff 100644 --- a/Userland/DevTools/UserspaceEmulator/CMakeLists.txt +++ b/Userland/DevTools/UserspaceEmulator/CMakeLists.txt @@ -23,4 +23,4 @@ set(SOURCES add_compile_options(-mmmx -Wno-psabi -frounding-math) serenity_bin(UserspaceEmulator) -target_link_libraries(UserspaceEmulator PRIVATE LibX86 LibDebug LibCore LibLine LibSystem) +target_link_libraries(UserspaceEmulator PRIVATE LibX86 LibDebug LibCore LibFileSystem LibLine LibSystem) diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.cpp b/Userland/DevTools/UserspaceEmulator/Emulator.cpp index a0207c4acfd..b73082053e3 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -423,7 +424,7 @@ MmapRegion const* Emulator::load_library_from_address(FlatPtr address) return {}; DeprecatedString lib_path = lib_name; - if (Core::DeprecatedFile::looks_like_shared_library(lib_name)) + if (FileSystem::looks_like_shared_library(lib_name)) lib_path = DeprecatedString::formatted("/usr/lib/{}", lib_path); if (!m_dynamic_library_cache.contains(lib_path)) { @@ -461,7 +462,7 @@ Optional Emulator::symbol_at(FlatPtr address) auto const* first_region = (lib_name.is_null() || lib_name.is_empty()) ? address_region : first_region_for_object(lib_name); VERIFY(first_region); auto lib_path = lib_name; - if (Core::DeprecatedFile::looks_like_shared_library(lib_name)) { + if (FileSystem::looks_like_shared_library(lib_name)) { lib_path = DeprecatedString::formatted("/usr/lib/{}", lib_name); } diff --git a/Userland/Games/Snake/CMakeLists.txt b/Userland/Games/Snake/CMakeLists.txt index 687f0d419f4..b92db998fd0 100644 --- a/Userland/Games/Snake/CMakeLists.txt +++ b/Userland/Games/Snake/CMakeLists.txt @@ -19,4 +19,4 @@ set(GENERATED_SOURCES ) serenity_app(Snake ICON app-snake) -target_link_libraries(Snake PRIVATE LibCore LibGfx LibGUI LibConfig LibMain LibDesktop) +target_link_libraries(Snake PRIVATE LibCore LibFileSystem LibGfx LibGUI LibConfig LibMain LibDesktop) diff --git a/Userland/Games/Snake/Skins/SnakeSkin.cpp b/Userland/Games/Snake/Skins/SnakeSkin.cpp index da1d77729f1..e797725b853 100644 --- a/Userland/Games/Snake/Skins/SnakeSkin.cpp +++ b/Userland/Games/Snake/Skins/SnakeSkin.cpp @@ -8,7 +8,7 @@ #include "ClassicSkin.h" #include "ImageSkin.h" #include -#include +#include namespace Snake { @@ -18,7 +18,7 @@ ErrorOr> SnakeSkin::create(StringView skin_name, Color return try_make(color); // Try to find an image-based skin matching the name. - if (Core::DeprecatedFile::exists(TRY(String::formatted("/res/graphics/snake/skins/{}", skin_name)))) + if (FileSystem::exists(TRY(String::formatted("/res/graphics/snake/skins/{}", skin_name)))) return ImageSkin::create(skin_name); // Fall-back on classic diff --git a/Userland/Libraries/LibCodeComprehension/Cpp/CMakeLists.txt b/Userland/Libraries/LibCodeComprehension/Cpp/CMakeLists.txt index 63c75e98c15..d8e18961320 100644 --- a/Userland/Libraries/LibCodeComprehension/Cpp/CMakeLists.txt +++ b/Userland/Libraries/LibCodeComprehension/Cpp/CMakeLists.txt @@ -17,4 +17,4 @@ set(SOURCES serenity_bin(CppComprehensionTests) -target_link_libraries(CppComprehensionTests PRIVATE LibCodeComprehension LibCore LibCpp LibRegex LibMain) +target_link_libraries(CppComprehensionTests PRIVATE LibCodeComprehension LibCore LibCpp LibFileSystem LibRegex LibMain) diff --git a/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp b/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp index 7d7c44d9648..ceb5203894d 100644 --- a/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp +++ b/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp @@ -9,12 +9,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include @@ -736,7 +736,7 @@ Optional> CppComprehensionEng if (!path.starts_with(partial_basename)) continue; - if (Core::DeprecatedFile::is_directory(LexicalPath::join(full_dir, path).string())) { + if (FileSystem::is_directory(LexicalPath::join(full_dir, path).string())) { // FIXME: Don't dismiss the autocomplete when filling these suggestions. auto completion = DeprecatedString::formatted("{}{}{}/", prefix, include_dir, path); options.empend(completion, include_dir.length() + partial_basename.length() + 1, CodeComprehension::Language::Cpp, path, CodeComprehension::AutocompleteResultEntry::HideAutocompleteAfterApplying::No); diff --git a/Userland/Libraries/LibCoredump/Backtrace.cpp b/Userland/Libraries/LibCoredump/Backtrace.cpp index 94ae94859b6..a4bcf9d51c9 100644 --- a/Userland/Libraries/LibCoredump/Backtrace.cpp +++ b/Userland/Libraries/LibCoredump/Backtrace.cpp @@ -9,12 +9,12 @@ #include #include #include -#include #include #include #include #include #include +#include namespace Coredump { @@ -26,7 +26,7 @@ ELFObjectInfo const* Backtrace::object_info_for_region(Reader const& coredump, M if (maybe_ptr.has_value()) return *maybe_ptr; - if (!Core::DeprecatedFile::exists(path)) + if (!FileSystem::exists(path)) return nullptr; auto file_or_error = Core::MappedFile::map(path); diff --git a/Userland/Libraries/LibCoredump/CMakeLists.txt b/Userland/Libraries/LibCoredump/CMakeLists.txt index a627b00e976..62aba7bac8d 100644 --- a/Userland/Libraries/LibCoredump/CMakeLists.txt +++ b/Userland/Libraries/LibCoredump/CMakeLists.txt @@ -5,4 +5,4 @@ set(SOURCES ) serenity_lib(LibCoredump coredump) -target_link_libraries(LibCoredump PRIVATE LibCompress LibCore LibDebug) +target_link_libraries(LibCoredump PRIVATE LibCompress LibCore LibDebug LibFileSystem) diff --git a/Userland/Libraries/LibCoredump/Reader.cpp b/Userland/Libraries/LibCoredump/Reader.cpp index dbbdc2285d9..e071f472ad7 100644 --- a/Userland/Libraries/LibCoredump/Reader.cpp +++ b/Userland/Libraries/LibCoredump/Reader.cpp @@ -6,13 +6,14 @@ */ #include +#include #include #include #include #include #include -#include #include +#include #include #include #include @@ -297,7 +298,7 @@ DeprecatedString Reader::resolve_object_path(StringView name) const // (e.g. UserspaceEmulator, LibSymbolication, Profiler, and DynamicLinker itself) // We should consider creating unified implementation in the future. - if (name.starts_with('/') || !Core::DeprecatedFile::looks_like_shared_library(name)) { + if (name.starts_with('/') || !FileSystem::looks_like_shared_library(name)) { return name; } diff --git a/Userland/Libraries/LibDebug/CMakeLists.txt b/Userland/Libraries/LibDebug/CMakeLists.txt index 878c9704182..fbfc5781717 100644 --- a/Userland/Libraries/LibDebug/CMakeLists.txt +++ b/Userland/Libraries/LibDebug/CMakeLists.txt @@ -14,4 +14,4 @@ set(SOURCES ) serenity_lib(LibDebug debug) -target_link_libraries(LibDebug PRIVATE LibCore LibRegex) +target_link_libraries(LibDebug PRIVATE LibCore LibFileSystem LibRegex) diff --git a/Userland/Libraries/LibDebug/DebugSession.cpp b/Userland/Libraries/LibDebug/DebugSession.cpp index 451d4a17a23..cddfe4aed58 100644 --- a/Userland/Libraries/LibDebug/DebugSession.cpp +++ b/Userland/Libraries/LibDebug/DebugSession.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -487,7 +488,7 @@ void DebugSession::update_loaded_libs() return IterationDecision::Continue; DeprecatedString lib_name = object_path.value(); - if (Core::DeprecatedFile::looks_like_shared_library(lib_name)) + if (FileSystem::looks_like_shared_library(lib_name)) lib_name = LexicalPath::basename(object_path.value()); FlatPtr base_address = entry.as_object().get_addr("address"sv).value_or(0); diff --git a/Userland/Libraries/LibFileSystemAccessClient/CMakeLists.txt b/Userland/Libraries/LibFileSystemAccessClient/CMakeLists.txt index 87c8ccea06d..7d0b4537b5b 100644 --- a/Userland/Libraries/LibFileSystemAccessClient/CMakeLists.txt +++ b/Userland/Libraries/LibFileSystemAccessClient/CMakeLists.txt @@ -8,5 +8,5 @@ set(GENERATED_SOURCES ) serenity_lib(LibFileSystemAccessClient filesystemaccessclient) -target_link_libraries(LibFileSystemAccessClient PRIVATE LibCore LibIPC) +target_link_libraries(LibFileSystemAccessClient PRIVATE LibCore LibFileSystem LibIPC) add_dependencies(LibFileSystemAccessClient WindowServer) diff --git a/Userland/Libraries/LibFileSystemAccessClient/Client.cpp b/Userland/Libraries/LibFileSystemAccessClient/Client.cpp index e4c7f185670..ea4af7a4571 100644 --- a/Userland/Libraries/LibFileSystemAccessClient/Client.cpp +++ b/Userland/Libraries/LibFileSystemAccessClient/Client.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -128,13 +129,13 @@ void Client::handle_prompt_end(i32 request_id, i32 error, Optional co return; } - if (Core::DeprecatedFile::is_device(ipc_file->fd())) { + if (FileSystem::is_device(*chosen_file)) { GUI::MessageBox::show_error(request_data.parent_window, DeprecatedString::formatted("Opening \"{}\" failed: Cannot open device files", *chosen_file)); request_data.promise->resolve(Error::from_string_literal("Cannot open device files")).release_value_but_fixme_should_propagate_errors(); return; } - if (Core::DeprecatedFile::is_directory(ipc_file->fd())) { + if (FileSystem::is_directory(*chosen_file)) { GUI::MessageBox::show_error(request_data.parent_window, DeprecatedString::formatted("Opening \"{}\" failed: Cannot open directory", *chosen_file)); request_data.promise->resolve(Error::from_errno(EISDIR)).release_value_but_fixme_should_propagate_errors(); return; diff --git a/Userland/Libraries/LibGUI/CMakeLists.txt b/Userland/Libraries/LibGUI/CMakeLists.txt index 7cc61bd0a4a..c6e740f20d4 100644 --- a/Userland/Libraries/LibGUI/CMakeLists.txt +++ b/Userland/Libraries/LibGUI/CMakeLists.txt @@ -143,4 +143,4 @@ set(GENERATED_SOURCES ) serenity_lib(LibGUI gui) -target_link_libraries(LibGUI PRIVATE LibCore LibGfx LibIPC LibThreading LibRegex LibSyntax LibConfig LibUnicode) +target_link_libraries(LibGUI PRIVATE LibCore LibFileSystem LibGfx LibIPC LibThreading LibRegex LibSyntax LibConfig LibUnicode) diff --git a/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp b/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp index ba81d3aa195..5928651cbd0 100644 --- a/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp +++ b/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp @@ -8,9 +8,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -25,7 +25,7 @@ static void initialize_if_needed() return; auto user_config = DeprecatedString::formatted("{}/CommonLocations.json", Core::StandardPaths::config_directory()); - if (Core::DeprecatedFile::exists(user_config)) { + if (FileSystem::exists(user_config)) { auto maybe_error = CommonLocationsProvider::load_from_json(user_config); if (!maybe_error.is_error()) return; diff --git a/Userland/Libraries/LibGUI/FilePicker.cpp b/Userland/Libraries/LibGUI/FilePicker.cpp index c984dfc6ddf..dced842f09b 100644 --- a/Userland/Libraries/LibGUI/FilePicker.cpp +++ b/Userland/Libraries/LibGUI/FilePicker.cpp @@ -7,8 +7,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -320,7 +320,7 @@ void FilePicker::on_file_return() path = LexicalPath::join(m_model->root_path(), path).string(); } - bool file_exists = Core::DeprecatedFile::exists(path); + bool file_exists = FileSystem::exists(path); if (!file_exists && (m_mode == Mode::Open || m_mode == Mode::OpenFolder)) { MessageBox::show(this, DeprecatedString::formatted("No such file or directory: {}", m_filename_textbox->text()), "File not found"sv, MessageBox::Type::Error, MessageBox::InputType::OK); diff --git a/Userland/Libraries/LibGUI/PathBreadcrumbbar.cpp b/Userland/Libraries/LibGUI/PathBreadcrumbbar.cpp index 78988a3df34..062cb423ff6 100644 --- a/Userland/Libraries/LibGUI/PathBreadcrumbbar.cpp +++ b/Userland/Libraries/LibGUI/PathBreadcrumbbar.cpp @@ -9,8 +9,8 @@ #include "PathBreadcrumbbar.h" #include -#include #include +#include #include #include #include @@ -49,7 +49,7 @@ PathBreadcrumbbar::PathBreadcrumbbar(NonnullRefPtr location_text_b }; m_location_text_box->on_return_pressed = [&] { - if (Core::DeprecatedFile::is_directory(m_location_text_box->text())) { + if (FileSystem::is_directory(m_location_text_box->text())) { set_current_path(m_location_text_box->text()); hide_location_text_box(); } @@ -104,7 +104,7 @@ void PathBreadcrumbbar::set_current_path(DeprecatedString const& new_path) // If the path change was because the directory we were in was deleted, // remove the breadcrumbs for it. if ((new_segment_index + 1 < m_breadcrumbbar->segment_count()) - && !Core::DeprecatedFile::is_directory(m_breadcrumbbar->segment_data(new_segment_index + 1))) { + && !FileSystem::is_directory(m_breadcrumbbar->segment_data(new_segment_index + 1))) { m_breadcrumbbar->remove_end_segments(new_segment_index + 1); } } else { diff --git a/Userland/Libraries/LibGfx/CMakeLists.txt b/Userland/Libraries/LibGfx/CMakeLists.txt index 259dd78fc97..38923c5e72b 100644 --- a/Userland/Libraries/LibGfx/CMakeLists.txt +++ b/Userland/Libraries/LibGfx/CMakeLists.txt @@ -63,4 +63,4 @@ set(SOURCES ) serenity_lib(LibGfx gfx) -target_link_libraries(LibGfx PRIVATE LibCompress LibCore LibCrypto LibTextCodec LibIPC LibUnicode) +target_link_libraries(LibGfx PRIVATE LibCompress LibCore LibCrypto LibFileSystem LibTextCodec LibIPC LibUnicode) diff --git a/Userland/Libraries/LibGfx/Font/FontDatabase.cpp b/Userland/Libraries/LibGfx/Font/FontDatabase.cpp index 36ca33e75eb..59bd281f6c7 100644 --- a/Userland/Libraries/LibGfx/Font/FontDatabase.cpp +++ b/Userland/Libraries/LibGfx/Font/FontDatabase.cpp @@ -7,8 +7,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -135,7 +135,7 @@ void FontDatabase::load_all_fonts_from_path(DeprecatedString const& root) while (dir_iterator.has_next()) { auto path = dir_iterator.next_full_path(); - if (Core::DeprecatedFile::is_directory(path)) { + if (FileSystem::is_directory(path)) { path_queue.enqueue(path); continue; } diff --git a/Userland/Libraries/LibIDL/CMakeLists.txt b/Userland/Libraries/LibIDL/CMakeLists.txt index cc8ad431fd5..93c73e86440 100644 --- a/Userland/Libraries/LibIDL/CMakeLists.txt +++ b/Userland/Libraries/LibIDL/CMakeLists.txt @@ -4,4 +4,4 @@ set(SOURCES ) serenity_lib(LibIDL idl) -target_link_libraries(LibIDL PRIVATE LibCore) +target_link_libraries(LibIDL PRIVATE LibCore LibFileSystem) diff --git a/Userland/Libraries/LibIDL/IDLParser.cpp b/Userland/Libraries/LibIDL/IDLParser.cpp index 0470c87fdb3..240da5ff3c0 100644 --- a/Userland/Libraries/LibIDL/IDLParser.cpp +++ b/Userland/Libraries/LibIDL/IDLParser.cpp @@ -13,6 +13,7 @@ #include #include #include +#include [[noreturn]] static void report_parsing_error(StringView message, StringView filename, StringView input, size_t offset) { @@ -138,7 +139,7 @@ static HashTable import_stack; Optional Parser::resolve_import(auto path) { auto include_path = LexicalPath::join(import_base_path, path).string(); - if (!Core::DeprecatedFile::exists(include_path)) + if (!FileSystem::exists(include_path)) report_parsing_error(DeprecatedString::formatted("{}: No such file or directory", include_path), filename, input, lexer.tell()); auto real_path = Core::DeprecatedFile::real_path_for(include_path); diff --git a/Userland/Libraries/LibJS/CMakeLists.txt b/Userland/Libraries/LibJS/CMakeLists.txt index c08007f93c1..d4ae494f215 100644 --- a/Userland/Libraries/LibJS/CMakeLists.txt +++ b/Userland/Libraries/LibJS/CMakeLists.txt @@ -265,4 +265,4 @@ set(SOURCES ) serenity_lib(LibJS js) -target_link_libraries(LibJS PRIVATE LibCore LibCrypto LibRegex LibSyntax LibLocale LibUnicode) +target_link_libraries(LibJS PRIVATE LibCore LibCrypto LibFileSystem LibRegex LibSyntax LibLocale LibUnicode) diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp index b6e9857ee24..3ce4588b65a 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.cpp +++ b/Userland/Libraries/LibJS/Runtime/VM.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -854,18 +855,18 @@ static DeprecatedString resolve_module_filename(StringView filename, StringView auto extensions = Vector { "js"sv, "mjs"sv }; if (module_type == "json"sv) extensions = { "json"sv }; - if (!Core::DeprecatedFile::exists(filename)) { + if (!FileSystem::exists(filename)) { for (auto extension : extensions) { // import "./foo" -> import "./foo.ext" auto resolved_filepath = DeprecatedString::formatted("{}.{}", filename, extension); - if (Core::DeprecatedFile::exists(resolved_filepath)) + if (FileSystem::exists(resolved_filepath)) return resolved_filepath; } - } else if (Core::DeprecatedFile::is_directory(filename)) { + } else if (FileSystem::is_directory(filename)) { for (auto extension : extensions) { // import "./foo" -> import "./foo/index.ext" auto resolved_filepath = LexicalPath::join(filename, DeprecatedString::formatted("index.{}", extension)).string(); - if (Core::DeprecatedFile::exists(resolved_filepath)) + if (FileSystem::exists(resolved_filepath)) return resolved_filepath; } } diff --git a/Userland/Libraries/LibManual/CMakeLists.txt b/Userland/Libraries/LibManual/CMakeLists.txt index 15b4c3d62ba..20359709a51 100644 --- a/Userland/Libraries/LibManual/CMakeLists.txt +++ b/Userland/Libraries/LibManual/CMakeLists.txt @@ -7,4 +7,4 @@ set(SOURCES ) serenity_lib(LibManual manual) -target_link_libraries(LibManual PRIVATE LibCore) +target_link_libraries(LibManual PRIVATE LibCore LibFileSystem) diff --git a/Userland/Libraries/LibManual/Node.cpp b/Userland/Libraries/LibManual/Node.cpp index bfc11d55b49..3b48ae90c00 100644 --- a/Userland/Libraries/LibManual/Node.cpp +++ b/Userland/Libraries/LibManual/Node.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include namespace Manual { @@ -48,7 +48,7 @@ ErrorOr> Node::try_create_from_query(Vector> maybe_page; for (auto const& section : sections) { auto const page = TRY(try_make_ref_counted(section, TRY(String::from_utf8(first_query_parameter)))); - if (Core::DeprecatedFile::exists(TRY(page->path()))) { + if (FileSystem::exists(TRY(page->path()))) { maybe_page = page; break; } @@ -61,7 +61,7 @@ ErrorOr> Node::try_create_from_query(Vector(section, TRY(String::from_utf8(second_query_parameter)))); - if (Core::DeprecatedFile::exists(TRY(page->path()))) + if (FileSystem::exists(TRY(page->path()))) return page; return Error::from_string_literal("Page doesn't exist in section"); } diff --git a/Userland/Libraries/LibManual/SectionNode.cpp b/Userland/Libraries/LibManual/SectionNode.cpp index 75db61043b7..150f960f32c 100644 --- a/Userland/Libraries/LibManual/SectionNode.cpp +++ b/Userland/Libraries/LibManual/SectionNode.cpp @@ -10,8 +10,8 @@ #include "SubsectionNode.h" #include #include -#include #include +#include namespace Manual { @@ -54,7 +54,7 @@ ErrorOr SectionNode::reify_if_needed() const while (dir_iter.has_next()) { LexicalPath lexical_path(dir_iter.next_path()); if (lexical_path.extension() != "md") { - if (Core::DeprecatedFile::is_directory(LexicalPath::absolute_path(own_path.to_deprecated_string(), lexical_path.string()))) { + if (FileSystem::is_directory(LexicalPath::absolute_path(own_path.to_deprecated_string(), lexical_path.string()))) { dbgln("Found subsection {}", lexical_path); children.append({ .node = TRY(try_make_ref_counted(*this, lexical_path.title())), .name_for_sorting = TRY(String::from_utf8(lexical_path.title())) }); diff --git a/Userland/Libraries/LibSQL/CMakeLists.txt b/Userland/Libraries/LibSQL/CMakeLists.txt index febcb1c28d1..b782d824b47 100644 --- a/Userland/Libraries/LibSQL/CMakeLists.txt +++ b/Userland/Libraries/LibSQL/CMakeLists.txt @@ -41,4 +41,4 @@ set(GENERATED_SOURCES ) serenity_lib(LibSQL sql) -target_link_libraries(LibSQL PRIVATE LibCore LibIPC LibSyntax LibRegex) +target_link_libraries(LibSQL PRIVATE LibCore LibFileSystem LibIPC LibSyntax LibRegex) diff --git a/Userland/Libraries/LibSQL/SQLClient.cpp b/Userland/Libraries/LibSQL/SQLClient.cpp index db9455b83e0..9fdd842f0fc 100644 --- a/Userland/Libraries/LibSQL/SQLClient.cpp +++ b/Userland/Libraries/LibSQL/SQLClient.cpp @@ -10,11 +10,11 @@ #include #if !defined(AK_OS_SERENITY) -# include # include # include # include # include +# include #endif namespace SQL { @@ -24,7 +24,7 @@ namespace SQL { // This is heavily based on how SystemServer's Service creates its socket. static ErrorOr create_database_socket(DeprecatedString const& socket_path) { - if (Core::DeprecatedFile::exists(socket_path)) + if (FileSystem::exists(socket_path)) TRY(Core::System::unlink(socket_path)); # ifdef SOCK_NONBLOCK @@ -102,7 +102,7 @@ static ErrorOr launch_server(DeprecatedString const& socket_path, Deprecat static ErrorOr should_launch_server(DeprecatedString const& pid_path) { - if (!Core::DeprecatedFile::exists(pid_path)) + if (!FileSystem::exists(pid_path)) return true; Optional pid; diff --git a/Userland/Libraries/LibSymbolication/CMakeLists.txt b/Userland/Libraries/LibSymbolication/CMakeLists.txt index 7d43eed41d3..a5cdb4e4dbd 100644 --- a/Userland/Libraries/LibSymbolication/CMakeLists.txt +++ b/Userland/Libraries/LibSymbolication/CMakeLists.txt @@ -3,4 +3,4 @@ set(SOURCES ) serenity_lib(LibSymbolication symbolication) -target_link_libraries(LibSymbolication PRIVATE LibCore LibDebug) +target_link_libraries(LibSymbolication PRIVATE LibCore LibDebug LibFileSystem) diff --git a/Userland/Libraries/LibSymbolication/Symbolication.cpp b/Userland/Libraries/LibSymbolication/Symbolication.cpp index 485a99782e7..274c75aca6d 100644 --- a/Userland/Libraries/LibSymbolication/Symbolication.cpp +++ b/Userland/Libraries/LibSymbolication/Symbolication.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include namespace Symbolication { @@ -65,7 +66,7 @@ Optional symbolicate(DeprecatedString const& path, FlatPtr address, Incl bool found = false; for (auto& search_path : search_paths) { full_path = LexicalPath::join(search_path, path).string(); - if (Core::DeprecatedFile::exists(full_path)) { + if (FileSystem::exists(full_path)) { found = true; break; } diff --git a/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp b/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp index e0f7edf3f61..9fc4fa8ad88 100644 --- a/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp +++ b/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -158,7 +159,7 @@ int main(int argc, char** argv) common_path = DeprecatedString::formatted("{}/Userland/Libraries/LibJS/Tests/test-common.js", serenity_source_dir); #endif } - if (!Core::DeprecatedFile::is_directory(test_root)) { + if (!FileSystem::is_directory(test_root)) { warnln("Test root is not a directory: {}", test_root); return 1; } diff --git a/Userland/Services/SystemServer/CMakeLists.txt b/Userland/Services/SystemServer/CMakeLists.txt index ac24b0bd431..583046f5705 100644 --- a/Userland/Services/SystemServer/CMakeLists.txt +++ b/Userland/Services/SystemServer/CMakeLists.txt @@ -10,4 +10,4 @@ set(SOURCES ) serenity_bin(SystemServer) -target_link_libraries(SystemServer PRIVATE LibCore LibMain) +target_link_libraries(SystemServer PRIVATE LibCore LibFileSystem LibMain) diff --git a/Userland/Services/SystemServer/Service.cpp b/Userland/Services/SystemServer/Service.cpp index 56590f0d9e8..c2fb68a0a4c 100644 --- a/Userland/Services/SystemServer/Service.cpp +++ b/Userland/Services/SystemServer/Service.cpp @@ -12,11 +12,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include @@ -123,7 +123,7 @@ ErrorOr Service::activate() ErrorOr Service::spawn(int socket_fd) { - if (!Core::DeprecatedFile::exists(m_executable_path)) { + if (!FileSystem::exists(m_executable_path)) { dbgln("{}: binary \"{}\" does not exist, skipping service.", name(), m_executable_path); return Error::from_errno(ENOENT); } diff --git a/Userland/Services/WebContent/CMakeLists.txt b/Userland/Services/WebContent/CMakeLists.txt index c5c0e302475..ef0cf40da77 100644 --- a/Userland/Services/WebContent/CMakeLists.txt +++ b/Userland/Services/WebContent/CMakeLists.txt @@ -28,5 +28,5 @@ set(GENERATED_SOURCES ) serenity_bin(WebContent) -target_link_libraries(WebContent PRIVATE LibCore LibIPC LibGfx LibImageDecoderClient LibJS LibWebView LibWeb LibLocale LibMain) +target_link_libraries(WebContent PRIVATE LibCore LibFileSystem LibIPC LibGfx LibImageDecoderClient LibJS LibWebView LibWeb LibLocale LibMain) link_with_locale_data(WebContent) diff --git a/Userland/Services/WebContent/main.cpp b/Userland/Services/WebContent/main.cpp index caa0a2e48d4..081f24bbb4e 100644 --- a/Userland/Services/WebContent/main.cpp +++ b/Userland/Services/WebContent/main.cpp @@ -5,11 +5,11 @@ */ #include "ImageCodecPluginSerenity.h" -#include #include #include #include #include +#include #include #include #include @@ -29,7 +29,7 @@ ErrorOr serenity_main(Main::Arguments) // This must be first; we can't check if /tmp/webdriver exists once we've unveiled other paths. auto webdriver_socket_path = DeprecatedString::formatted("{}/webdriver", TRY(Core::StandardPaths::runtime_directory())); - if (Core::DeprecatedFile::exists(webdriver_socket_path)) + if (FileSystem::exists(webdriver_socket_path)) TRY(Core::System::unveil(webdriver_socket_path, "rw"sv)); TRY(Core::System::unveil("/res", "r")); diff --git a/Userland/Services/WebServer/CMakeLists.txt b/Userland/Services/WebServer/CMakeLists.txt index d682847f441..d788dec1e4d 100644 --- a/Userland/Services/WebServer/CMakeLists.txt +++ b/Userland/Services/WebServer/CMakeLists.txt @@ -10,4 +10,4 @@ set(SOURCES ) serenity_bin(WebServer) -target_link_libraries(WebServer PRIVATE LibCore LibHTTP LibMain) +target_link_libraries(WebServer PRIVATE LibCore LibFileSystem LibHTTP LibMain) diff --git a/Userland/Services/WebServer/Client.cpp b/Userland/Services/WebServer/Client.cpp index 43b40da3e0a..c91d8a0b409 100644 --- a/Userland/Services/WebServer/Client.cpp +++ b/Userland/Services/WebServer/Client.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -133,7 +134,7 @@ ErrorOr Client::handle_request(ReadonlyBytes raw_request) path_builder.append(requested_path); auto real_path = TRY(path_builder.to_string()); - if (Core::DeprecatedFile::is_directory(real_path.bytes_as_string_view())) { + if (FileSystem::is_directory(real_path.bytes_as_string_view())) { if (!resource_decoded.ends_with('/')) { StringBuilder red; @@ -148,7 +149,7 @@ ErrorOr Client::handle_request(ReadonlyBytes raw_request) index_html_path_builder.append(real_path); index_html_path_builder.append("/index.html"sv); auto index_html_path = TRY(index_html_path_builder.to_string()); - if (!Core::DeprecatedFile::exists(index_html_path)) { + if (!FileSystem::exists(index_html_path)) { TRY(handle_directory_listing(requested_path, real_path, request)); return true; } @@ -170,7 +171,7 @@ ErrorOr Client::handle_request(ReadonlyBytes raw_request) auto const info = ContentInfo { .type = TRY(String::from_utf8(Core::guess_mime_type_based_on_filename(real_path.bytes_as_string_view()))), - .length = TRY(Core::DeprecatedFile::size(real_path.bytes_as_string_view())) + .length = TRY(FileSystem::size(real_path.bytes_as_string_view())) }; TRY(send_response(*stream, request, move(info))); return true; diff --git a/Userland/Services/WebServer/main.cpp b/Userland/Services/WebServer/main.cpp index ecbf66928f6..7f4dbadb622 100644 --- a/Userland/Services/WebServer/main.cpp +++ b/Userland/Services/WebServer/main.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -57,7 +58,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } auto real_document_root_path = Core::DeprecatedFile::real_path_for(document_root_path); - if (!Core::DeprecatedFile::exists(real_document_root_path)) { + if (!FileSystem::exists(real_document_root_path)) { warnln("Root path does not exist: '{}'", document_root_path); return 1; } diff --git a/Userland/Services/WindowServer/CMakeLists.txt b/Userland/Services/WindowServer/CMakeLists.txt index b9a297592a0..ed975c387ea 100644 --- a/Userland/Services/WindowServer/CMakeLists.txt +++ b/Userland/Services/WindowServer/CMakeLists.txt @@ -45,5 +45,5 @@ set(GENERATED_SOURCES ) serenity_bin(WindowServer) -target_link_libraries(WindowServer PRIVATE LibCore LibGfx LibThreading LibIPC LibMain) +target_link_libraries(WindowServer PRIVATE LibCore LibFileSystem LibGfx LibThreading LibIPC LibMain) serenity_install_headers(Services/WindowServer) diff --git a/Userland/Services/WindowServer/main.cpp b/Userland/Services/WindowServer/main.cpp index da17e92616d..6b0176e1fb4 100644 --- a/Userland/Services/WindowServer/main.cpp +++ b/Userland/Services/WindowServer/main.cpp @@ -11,9 +11,9 @@ #include "WindowManager.h" #include #include -#include #include #include +#include #include #include #include @@ -89,7 +89,7 @@ ErrorOr serenity_main(Main::Arguments) if (!path.starts_with("connector"sv)) continue; auto full_path = DeprecatedString::formatted("/dev/gpu/{}", path); - if (!Core::DeprecatedFile::is_device(full_path)) + if (!FileSystem::is_device(full_path)) continue; auto display_connector_fd = TRY(Core::System::open(full_path, O_RDWR | O_CLOEXEC)); if (int rc = graphics_connector_set_responsible(display_connector_fd); rc != 0) diff --git a/Userland/Shell/AST.cpp b/Userland/Shell/AST.cpp index 09ddfd69565..4ba3f987005 100644 --- a/Userland/Shell/AST.cpp +++ b/Userland/Shell/AST.cpp @@ -12,8 +12,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -676,7 +676,7 @@ ErrorOr BarewordLiteral::highlight_in_editor(Line::Editor& editor, Shell& editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Foreground(Line::Style::XtermColor::Cyan) }); } } - if (Core::DeprecatedFile::exists(m_text)) { + if (FileSystem::exists(m_text)) { auto realpath = shell.resolve_path(m_text.bytes_as_string_view()); auto url = URL::create_with_file_scheme(realpath); url.set_host(shell.hostname); @@ -3209,7 +3209,7 @@ ErrorOr Juxtaposition::highlight_in_editor(Line::Editor& editor, Shell& sh path_builder.append(bareword_value); auto path = path_builder.to_deprecated_string(); - if (Core::DeprecatedFile::exists(path)) { + if (FileSystem::exists(path)) { auto realpath = shell.resolve_path(path); auto url = URL::create_with_file_scheme(realpath); url.set_host(shell.hostname); diff --git a/Userland/Shell/CMakeLists.txt b/Userland/Shell/CMakeLists.txt index 961e2052108..54099af2869 100644 --- a/Userland/Shell/CMakeLists.txt +++ b/Userland/Shell/CMakeLists.txt @@ -18,7 +18,7 @@ set(SOURCES ) serenity_lib(LibShell shell) -target_link_libraries(LibShell PRIVATE LibCore LibLine LibSyntax LibRegex) +target_link_libraries(LibShell PRIVATE LibCore LibFileSystem LibLine LibSyntax LibRegex) if (SERENITYOS) target_sources(LibShell PRIVATE SyntaxHighlighter.cpp) @@ -31,7 +31,7 @@ else() set(SOURCES main.cpp) serenity_bin(Shell) - target_link_libraries(Shell PRIVATE LibCore LibLine LibShell LibMain) + target_link_libraries(Shell PRIVATE LibCore LibFileSystem LibLine LibShell LibMain) install(DIRECTORY Tests/ DESTINATION usr/Tests/Shell PATTERN "Tests/*" diff --git a/Userland/Shell/main.cpp b/Userland/Shell/main.cpp index 90d5e406221..9ef41363527 100644 --- a/Userland/Shell/main.cpp +++ b/Userland/Shell/main.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -227,7 +228,7 @@ ErrorOr serenity_main(Main::Arguments arguments) DeprecatedString file_path = name; if (file_path.starts_with('~')) file_path = shell->expand_tilde(file_path); - if (Core::DeprecatedFile::exists(file_path)) { + if (FileSystem::exists(file_path)) { shell->run_file(file_path, false); } }; diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index 001dcfc31c4..906863dfa0d 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -80,6 +80,8 @@ target_link_libraries(chres PRIVATE LibGUI LibIPC) target_link_libraries(cksum PRIVATE LibCrypto) target_link_libraries(config PRIVATE LibConfig LibIPC) target_link_libraries(copy PRIVATE LibGUI) +target_link_libraries(comm PRIVATE LibFileSystem) +target_link_libraries(cp PRIVATE LibFileSystem) target_link_libraries(cpp-lexer PRIVATE LibCpp) target_link_libraries(cpp-parser PRIVATE LibCpp) target_link_libraries(cpp-preprocessor PRIVATE LibCpp) @@ -90,26 +92,29 @@ target_link_libraries(fdtdump PRIVATE LibDeviceTree) target_link_libraries(file PRIVATE LibGfx LibIPC LibCompress LibAudio) target_link_libraries(functrace PRIVATE LibDebug LibX86) target_link_libraries(gml-format PRIVATE LibGUI) -target_link_libraries(grep PRIVATE LibRegex) +target_link_libraries(grep PRIVATE LibFileSystem LibRegex) target_link_libraries(gunzip PRIVATE LibCompress) target_link_libraries(gzip PRIVATE LibCompress) -target_link_libraries(headless-browser PRIVATE LibCrypto LibGemini LibGfx LibHTTP LibTLS LibWeb LibWebView LibWebSocket LibIPC LibJS) +target_link_libraries(headless-browser PRIVATE LibCrypto LibFileSystem LibGemini LibGfx LibHTTP LibTLS LibWeb LibWebView LibWebSocket LibIPC LibJS) target_link_libraries(icc PRIVATE LibGfx LibVideo) target_link_libraries(image PRIVATE LibGfx) target_link_libraries(image2bin PRIVATE LibGfx) +target_link_libraries(ini PRIVATE LibFileSystem) target_link_libraries(jail-attach PRIVATE LibCore LibMain) target_link_libraries(jail-create PRIVATE LibCore LibMain) target_link_libraries(js PRIVATE LibCrypto LibJS LibLine LibLocale LibTextCodec) link_with_locale_data(js) target_link_libraries(keymap PRIVATE LibKeyboard) target_link_libraries(less PRIVATE LibLine) +target_link_libraries(ls PRIVATE LibFileSystem) target_link_libraries(lspci PRIVATE LibPCIDB) target_link_libraries(lsusb PRIVATE LibUSBDB) target_link_libraries(lzcat PRIVATE LibCompress) target_link_libraries(man PRIVATE LibMarkdown LibManual) -target_link_libraries(markdown-check PRIVATE LibMarkdown) +target_link_libraries(markdown-check PRIVATE LibFileSystem LibMarkdown) target_link_libraries(matroska PRIVATE LibVideo) target_link_libraries(md PRIVATE LibMarkdown) +target_link_libraries(mv PRIVATE LibFileSystem) target_link_libraries(notify PRIVATE LibGfx LibGUI) target_link_libraries(open PRIVATE LibDesktop) target_link_libraries(passwd PRIVATE LibCrypt) @@ -117,29 +122,33 @@ target_link_libraries(paste PRIVATE LibGUI) target_link_libraries(pgrep PRIVATE LibRegex) target_link_libraries(pkill PRIVATE LibRegex) target_link_libraries(pls PRIVATE LibCrypt) -target_link_libraries(pro PRIVATE LibProtocol LibHTTP) -target_link_libraries(run-tests PRIVATE LibRegex LibCoredump LibDebug) +target_link_libraries(pro PRIVATE LibFileSystem LibProtocol LibHTTP) +target_link_libraries(run-tests PRIVATE LibCoredump LibDebug LibFileSystem LibRegex) +target_link_libraries(rm PRIVATE LibFileSystem) target_link_libraries(sed PRIVATE LibRegex) target_link_libraries(shot PRIVATE LibGfx LibGUI LibIPC) -target_link_libraries(sql PRIVATE LibLine LibSQL LibIPC) +target_link_libraries(sql PRIVATE LibFileSystem LibIPC LibLine LibSQL) target_link_libraries(su PRIVATE LibCrypt) target_link_libraries(syscall PRIVATE LibSystem) target_link_libraries(ttfdisasm PRIVATE LibGfx) -target_link_libraries(tar PRIVATE LibArchive LibCompress) +target_link_libraries(tar PRIVATE LibArchive LibCompress LibFileSystem) target_link_libraries(telws PRIVATE LibProtocol LibLine) target_link_libraries(test-fuzz PRIVATE LibGemini LibGfx LibHTTP LibIPC LibJS LibMarkdown LibRegex LibShell) target_link_libraries(test-imap PRIVATE LibIMAP) target_link_libraries(test-pthread PRIVATE LibThreading) +target_link_libraries(touch PRIVATE LibFileSystem) target_link_libraries(unveil PRIVATE LibMain) -target_link_libraries(unzip PRIVATE LibArchive LibCompress LibCrypto) +target_link_libraries(unzip PRIVATE LibArchive LibCompress LibCrypto LibFileSystem) target_link_libraries(update-cpp-test-results PRIVATE LibCpp) target_link_libraries(useradd PRIVATE LibCrypt) +target_link_libraries(userdel PRIVATE LibFileSystem) target_link_libraries(wallpaper PRIVATE LibGfx LibGUI) target_link_libraries(wasm PRIVATE LibWasm LibLine LibJS) +target_link_libraries(watch PRIVATE LibFileSystem) target_link_libraries(wsctl PRIVATE LibGUI LibIPC) target_link_libraries(xml PRIVATE LibXML) target_link_libraries(xzcat PRIVATE LibCompress) -target_link_libraries(zip PRIVATE LibArchive LibCompress LibCrypto) +target_link_libraries(zip PRIVATE LibArchive LibCompress LibCrypto LibFileSystem) # FIXME: Link this file into headless-browser without compiling it again. target_sources(headless-browser PRIVATE "${SerenityOS_SOURCE_DIR}/Userland/Services/WebContent/WebDriverConnection.cpp") diff --git a/Userland/Utilities/comm.cpp b/Userland/Utilities/comm.cpp index 5a49cfded91..31c23f23a80 100644 --- a/Userland/Utilities/comm.cpp +++ b/Userland/Utilities/comm.cpp @@ -6,9 +6,9 @@ */ #include -#include #include #include +#include #include #include #include @@ -68,7 +68,7 @@ ErrorOr serenity_main(Main::Arguments arguments) return false; } - if (path != "-" && Core::DeprecatedFile::is_directory(path)) { + if (path != "-" && FileSystem::is_directory(path)) { warnln("Failed to open file{} '{}': is a directory", file_number, path); return false; } diff --git a/Userland/Utilities/cp.cpp b/Userland/Utilities/cp.cpp index 38d160cd709..e83a0b07483 100644 --- a/Userland/Utilities/cp.cpp +++ b/Userland/Utilities/cp.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -69,7 +70,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio rpath wpath cpath fattr")); } - bool destination_is_existing_dir = Core::DeprecatedFile::is_directory(destination); + bool destination_is_existing_dir = FileSystem::is_directory(destination); for (auto& source : sources) { auto destination_path = destination_is_existing_dir diff --git a/Userland/Utilities/grep.cpp b/Userland/Utilities/grep.cpp index 57309294dd9..4a50c7707cd 100644 --- a/Userland/Utilities/grep.cpp +++ b/Userland/Utilities/grep.cpp @@ -11,10 +11,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include @@ -245,7 +245,7 @@ ErrorOr serenity_main(Main::Arguments args) Core::DirIterator it(recursive.value_or(base), Core::DirIterator::Flags::SkipDots); while (it.has_next()) { auto path = it.next_full_path(); - if (!Core::DeprecatedFile::is_directory(path)) { + if (!FileSystem::is_directory(path)) { auto key = user_has_specified_files ? path.view() : path.substring_view(base.length() + 1, path.length() - base.length() - 1); if (auto result = handle_file(key, true); result.is_error() && !suppress_errors) warnln("Failed with file {}: {}", key, result.release_error()); diff --git a/Userland/Utilities/headless-browser.cpp b/Userland/Utilities/headless-browser.cpp index 2f081e24156..975c257726e 100644 --- a/Userland/Utilities/headless-browser.cpp +++ b/Userland/Utilities/headless-browser.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -164,8 +165,8 @@ static ErrorOr> load_page_for_screenshot_and_exit(Cor // FIXME: Allow passing the output path as an argument. static constexpr auto output_file_path = "output.png"sv; - if (Core::DeprecatedFile::exists(output_file_path)) - TRY(Core::DeprecatedFile::remove(output_file_path, Core::DeprecatedFile::RecursionMode::Disallowed)); + if (FileSystem::exists(output_file_path)) + TRY(FileSystem::remove(output_file_path, FileSystem::RecursionMode::Disallowed)); outln("Taking screenshot after {} seconds", screenshot_timeout); @@ -191,7 +192,7 @@ static ErrorOr> load_page_for_screenshot_and_exit(Cor static ErrorOr format_url(StringView url) { - if (Core::DeprecatedFile::exists(url)) + if (FileSystem::exists(url)) return URL::create_with_file_scheme(Core::DeprecatedFile::real_path_for(url)); URL formatted_url { url }; diff --git a/Userland/Utilities/ini.cpp b/Userland/Utilities/ini.cpp index 19e92bb76b3..0053a98d609 100644 --- a/Userland/Utilities/ini.cpp +++ b/Userland/Utilities/ini.cpp @@ -6,8 +6,8 @@ #include #include -#include #include +#include #include ErrorOr serenity_main(Main::Arguments arguments) @@ -26,7 +26,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(value_to_write, "Value to write", "value", Core::ArgsParser::Required::No); args_parser.parse(arguments); - if (!Core::DeprecatedFile::exists(path)) { + if (!FileSystem::exists(path)) { warnln("File does not exist: '{}'", path); return 1; } diff --git a/Userland/Utilities/ls.cpp b/Userland/Utilities/ls.cpp index df4759f3f8e..cc656e84474 100644 --- a/Userland/Utilities/ls.cpp +++ b/Userland/Utilities/ls.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -164,7 +165,7 @@ ErrorOr serenity_main(Main::Arguments arguments) for (size_t i = 0; i < files.size(); i++) { auto path = files[i].name; - if (flag_recursive && Core::DeprecatedFile::is_directory(path)) { + if (flag_recursive && FileSystem::is_directory(path)) { size_t subdirs = 0; Core::DirIterator di(path, Core::DirIterator::SkipParentAndBaseDir); @@ -175,7 +176,7 @@ ErrorOr serenity_main(Main::Arguments arguments) while (di.has_next()) { DeprecatedString directory = di.next_full_path(); - if (Core::DeprecatedFile::is_directory(directory) && !Core::DeprecatedFile::is_link(directory)) { + if (FileSystem::is_directory(directory) && !FileSystem::is_link(directory)) { ++subdirs; FileMetadata new_file; new_file.name = move(directory); @@ -184,7 +185,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } } - bool show_dir_separator = files.size() > 1 && Core::DeprecatedFile::is_directory(path) && !flag_list_directories_only; + bool show_dir_separator = files.size() > 1 && FileSystem::is_directory(path) && !flag_list_directories_only; if (show_dir_separator) { printf("%s:\n", path.characters()); } diff --git a/Userland/Utilities/markdown-check.cpp b/Userland/Utilities/markdown-check.cpp index ab6ce84eb81..47db678beb2 100644 --- a/Userland/Utilities/markdown-check.cpp +++ b/Userland/Utilities/markdown-check.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -293,7 +294,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } else { pointee_file = LexicalPath::absolute_path(file_dir, file_link.file_path); } - if (!Core::DeprecatedFile::exists(pointee_file) && !is_missing_file_acceptable(pointee_file)) { + if (!FileSystem::exists(pointee_file) && !is_missing_file_acceptable(pointee_file)) { outln("File '{}' points to '{}' (label '{}'), but '{}' does not exist!", file_item.key, file_link.file_path, file_link.label, pointee_file); any_problems = true; diff --git a/Userland/Utilities/mv.cpp b/Userland/Utilities/mv.cpp index 9b1af01a8e0..306ae82c4ab 100644 --- a/Userland/Utilities/mv.cpp +++ b/Userland/Utilities/mv.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -69,7 +70,7 @@ ErrorOr serenity_main(Main::Arguments arguments) new_path = combined_new_path.characters(); } - if (no_clobber && Core::DeprecatedFile::exists(new_path)) + if (no_clobber && FileSystem::exists(new_path)) continue; rc = rename(old_path.characters(), new_path.characters()); diff --git a/Userland/Utilities/pro.cpp b/Userland/Utilities/pro.cpp index 5202296dad6..41d20e97898 100644 --- a/Userland/Utilities/pro.cpp +++ b/Userland/Utilities/pro.cpp @@ -13,9 +13,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -337,7 +337,7 @@ ErrorOr serenity_main(Main::Arguments arguments) if (i > -1) output_name = DeprecatedString::formatted("{}.{}", output_name, i); ++i; - } while (Core::DeprecatedFile::exists(output_name)); + } while (FileSystem::exists(output_name)); } int target_file_fd = open(output_name.characters(), O_WRONLY | O_CREAT | O_TRUNC, 0644); diff --git a/Userland/Utilities/rm.cpp b/Userland/Utilities/rm.cpp index 4a34af01faf..107b9374c57 100644 --- a/Userland/Utilities/rm.cpp +++ b/Userland/Utilities/rm.cpp @@ -7,8 +7,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -43,7 +43,7 @@ ErrorOr serenity_main(Main::Arguments arguments) continue; } - auto result = Core::DeprecatedFile::remove(path, recursive ? Core::DeprecatedFile::RecursionMode::Allowed : Core::DeprecatedFile::RecursionMode::Disallowed); + auto result = FileSystem::remove(path, recursive ? FileSystem::RecursionMode::Allowed : FileSystem::RecursionMode::Disallowed); if (result.is_error()) { auto error = result.release_error(); diff --git a/Userland/Utilities/run-tests.cpp b/Userland/Utilities/run-tests.cpp index 2d75897efe9..0eba0b71900 100644 --- a/Userland/Utilities/run-tests.cpp +++ b/Userland/Utilities/run-tests.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -365,7 +366,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } else { test_root = "/usr/Tests"; } - if (!Core::DeprecatedFile::is_directory(test_root)) { + if (!FileSystem::is_directory(test_root)) { warnln("Test root is not a directory: {}", test_root); return 1; } diff --git a/Userland/Utilities/sql.cpp b/Userland/Utilities/sql.cpp index 9d68d4646db..2b6516b9714 100644 --- a/Userland/Utilities/sql.cpp +++ b/Userland/Utilities/sql.cpp @@ -10,8 +10,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -365,7 +365,7 @@ ErrorOr serenity_main(Main::Arguments arguments) SQLRepl repl(loop, database_name, move(sql_client)); - if (!suppress_sqlrc && Core::DeprecatedFile::exists(sqlrc_path)) + if (!suppress_sqlrc && FileSystem::exists(sqlrc_path)) repl.source_file(sqlrc_path); if (!file_to_source.is_empty()) repl.source_file(file_to_source); diff --git a/Userland/Utilities/tar.cpp b/Userland/Utilities/tar.cpp index 44069aa9251..58124933e83 100644 --- a/Userland/Utilities/tar.cpp +++ b/Userland/Utilities/tar.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -278,9 +279,9 @@ ErrorOr serenity_main(Main::Arguments arguments) Core::DirIterator it(path, Core::DirIterator::Flags::SkipParentAndBaseDir); while (it.has_next()) { auto child_path = it.next_full_path(); - if (!dereference && Core::DeprecatedFile::is_link(child_path)) { + if (!dereference && FileSystem::is_link(child_path)) { TRY(add_link(child_path)); - } else if (!Core::DeprecatedFile::is_directory(child_path)) { + } else if (!FileSystem::is_directory(child_path)) { TRY(add_file(child_path)); } else { TRY(handle_directory(child_path, handle_directory)); @@ -291,7 +292,7 @@ ErrorOr serenity_main(Main::Arguments arguments) }; for (auto const& path : paths) { - if (Core::DeprecatedFile::is_directory(path)) { + if (FileSystem::is_directory(path)) { TRY(add_directory(path, add_directory)); } else { TRY(add_file(path)); diff --git a/Userland/Utilities/touch.cpp b/Userland/Utilities/touch.cpp index 41ff23113ac..8652b4b6116 100644 --- a/Userland/Utilities/touch.cpp +++ b/Userland/Utilities/touch.cpp @@ -9,8 +9,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -239,7 +239,7 @@ ErrorOr serenity_main(Main::Arguments arguments) atime.tv_nsec = UTIME_OMIT; for (auto path : paths) { - if (Core::DeprecatedFile::exists(path)) { + if (FileSystem::exists(path)) { if (utimensat(AT_FDCWD, path.characters(), times, 0) == -1) err("failed to touch '{}': {}", path, strerror(errno)); } else if (!no_create_file) { diff --git a/Userland/Utilities/unzip.cpp b/Userland/Utilities/unzip.cpp index 3014ce503ae..8d7a36565a4 100644 --- a/Userland/Utilities/unzip.cpp +++ b/Userland/Utilities/unzip.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include static ErrorOr adjust_modification_time(Archive::ZipMember const& zip_member) @@ -94,7 +95,7 @@ static bool unpack_zip_member(Archive::ZipMember zip_member, bool quiet) if (checksum.digest() != zip_member.crc32) { warnln("Failed decompressing file {}: CRC32 mismatch", zip_member.name); - MUST(Core::DeprecatedFile::remove(zip_member.name, Core::DeprecatedFile::RecursionMode::Disallowed)); + MUST(FileSystem::remove(zip_member.name, FileSystem::RecursionMode::Disallowed)); return false; } diff --git a/Userland/Utilities/userdel.cpp b/Userland/Utilities/userdel.cpp index a2aa9ae5b23..6e9c07f8276 100644 --- a/Userland/Utilities/userdel.cpp +++ b/Userland/Utilities/userdel.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -54,7 +55,7 @@ ErrorOr serenity_main(Main::Arguments arguments) return 12; } - if (auto result = Core::DeprecatedFile::remove(real_path, Core::DeprecatedFile::RecursionMode::Allowed); result.is_error()) { + if (auto result = FileSystem::remove(real_path, FileSystem::RecursionMode::Allowed); result.is_error()) { warnln("{}", result.release_error()); return 12; } diff --git a/Userland/Utilities/watch.cpp b/Userland/Utilities/watch.cpp index 3fe9f3a6c66..db43551a37d 100644 --- a/Userland/Utilities/watch.cpp +++ b/Userland/Utilities/watch.cpp @@ -10,9 +10,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -165,7 +165,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto file_watcher = Core::BlockingFileWatcher(); for (auto const& file : files_to_watch) { - if (!Core::DeprecatedFile::exists(file)) { + if (!FileSystem::exists(file)) { warnln("Cannot watch '{}', it does not exist.", file); return 1; } diff --git a/Userland/Utilities/zip.cpp b/Userland/Utilities/zip.cpp index b0a7e8c84a3..3fe91460a22 100644 --- a/Userland/Utilities/zip.cpp +++ b/Userland/Utilities/zip.cpp @@ -10,11 +10,11 @@ #include #include #include -#include #include #include #include #include +#include ErrorOr serenity_main(Main::Arguments arguments) { @@ -40,7 +40,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil(nullptr, nullptr)); DeprecatedString zip_file_path { zip_path }; - if (Core::DeprecatedFile::exists(zip_file_path)) { + if (FileSystem::exists(zip_file_path)) { if (force) { outln("{} already exists, overwriting...", zip_file_path); } else { @@ -107,9 +107,9 @@ ErrorOr serenity_main(Main::Arguments arguments) Core::DirIterator it(path, Core::DirIterator::Flags::SkipParentAndBaseDir); while (it.has_next()) { auto child_path = it.next_full_path(); - if (Core::DeprecatedFile::is_link(child_path)) + if (FileSystem::is_link(child_path)) return {}; - if (!Core::DeprecatedFile::is_directory(child_path)) { + if (!FileSystem::is_directory(child_path)) { auto result = add_file(child_path); if (result.is_error()) warnln("Couldn't add file '{}': {}", child_path, result.error()); @@ -123,7 +123,7 @@ ErrorOr serenity_main(Main::Arguments arguments) }; for (auto const& source_path : source_paths) { - if (Core::DeprecatedFile::is_directory(source_path)) { + if (FileSystem::is_directory(source_path)) { auto result = add_directory(source_path, add_directory); if (result.is_error()) warnln("Couldn't add directory '{}': {}", source_path, result.error());