diff --git a/Base/usr/share/man/man2/readlink.md b/Base/usr/share/man/man2/readlink.md index 9a2fedb622d..e4c7c24e626 100644 --- a/Base/usr/share/man/man2/readlink.md +++ b/Base/usr/share/man/man2/readlink.md @@ -26,12 +26,12 @@ and sets `errno` to describe the error. ## Notes The underlying system call always returns the full size of the target path on -success, not the number of bytes written. `Core::File::read_link()` makes use +success, not the number of bytes written. `Core::DeprecatedFile::read_link()` makes use of this to provide an alternative way to read links that doesn't require the caller to pick a buffer size and allocate a buffer straight up. Since it's essentially impossible to guess the right buffer size for reading -links, it's strongly recommended that everything uses `Core::File::read_link()` +links, it's strongly recommended that everything uses `Core::DeprecatedFile::read_link()` instead. ## Examples @@ -40,7 +40,7 @@ The following example demonstrates how one could implement an alternative version of `getpid(2)` which reads the calling process ID from ProcFS: ```c++ -#include +#include #include pid_t read_pid_using_readlink() @@ -55,7 +55,7 @@ pid_t read_pid_using_readlink() pid_t read_pid_using_core_file() { - auto target = Core::File::read_link("/proc/self"); + auto target = Core::DeprecatedFile::read_link("/proc/self"); if (target.is_null()) return -1; auto pid = target.to_uint(); diff --git a/Ladybird/AndroidPlatform.cpp b/Ladybird/AndroidPlatform.cpp index c88a4dce3d9..b1f81043146 100644 --- a/Ladybird/AndroidPlatform.cpp +++ b/Ladybird/AndroidPlatform.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -68,7 +67,7 @@ ErrorOr extract_tar_archive(DeprecatedString archive_file, DeprecatedStrin { constexpr size_t buffer_size = 4096; - auto file = TRY(Core::File::open(archive_file, Core::OpenMode::ReadOnly)); + auto file = TRY(Core::DeprecatedFile::open(archive_file, Core::OpenMode::ReadOnly)); DeprecatedString old_pwd = TRY(Core::System::getcwd()); @@ -155,7 +154,7 @@ ErrorOr extract_tar_archive(DeprecatedString archive_file, DeprecatedStrin path = path.prepend(header.prefix()); DeprecatedString filename = get_override("path"sv).value_or(path.string()); - DeprecatedString absolute_path = Core::File::absolute_path(filename); + DeprecatedString absolute_path = Core::DeprecatedFile::absolute_path(filename); auto parent_path = LexicalPath(absolute_path).parent(); switch (header.type_flag()) { diff --git a/Ladybird/Utilities.cpp b/Ladybird/Utilities.cpp index 7c823644c76..12a534a1a6d 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; @@ -43,7 +43,7 @@ void platform_init() auto* home = getenv("XDG_CONFIG_HOME") ?: getenv("HOME"); VERIFY(home); auto home_lagom = DeprecatedString::formatted("{}/.lagom", home); - if (Core::File::is_directory(home_lagom)) + if (Core::DeprecatedFile::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/main.cpp b/Ladybird/WebContent/main.cpp index 31aef09d75c..0a68d2ed287 100644 --- a/Ladybird/WebContent/main.cpp +++ b/Ladybird/WebContent/main.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/Ladybird/WebContentView.cpp b/Ladybird/WebContentView.cpp index d6d9c7ef46d..690b1c0d727 100644 --- a/Ladybird/WebContentView.cpp +++ b/Ladybird/WebContentView.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/Ladybird/main.cpp b/Ladybird/main.cpp index b6fa18b6141..f29490a0501 100644 --- a/Ladybird/main.cpp +++ b/Ladybird/main.cpp @@ -13,8 +13,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -79,8 +79,8 @@ ErrorOr serenity_main(Main::Arguments arguments) auto get_formatted_url = [&](StringView const& raw_url) -> URL { URL url = raw_url; - if (Core::File::exists(raw_url)) - url = URL::create_with_file_scheme(Core::File::real_path_for(raw_url)); + if (Core::DeprecatedFile::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); return url; diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp index e7b2880cb4f..f2e0249bcfb 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 #include static DeprecatedString format_identifier(StringView owner, DeprecatedString identifier) @@ -921,7 +921,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::File::is_directory(core_supplemental_path.string())); + VERIFY(Core::DeprecatedFile::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 879f85fd926..f9c35fae1b4 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 @@ -704,7 +704,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::File::is_directory(core_supplemental_path.string())); + VERIFY(Core::DeprecatedFile::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 ebbf19492d1..d13b5f37533 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include @@ -398,7 +398,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::File::is_directory(core_supplemental_path.string())); + VERIFY(Core::DeprecatedFile::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 a3f3e6692b5..984f44396c0 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp @@ -11,8 +11,8 @@ #include #include #include +#include #include -#include #include #include @@ -46,7 +46,7 @@ static void set_image_path_for_emoji(StringView emoji_resource_path, Emoji& emoj } auto path = DeprecatedString::formatted("{}/{}.png", emoji_resource_path, builder.to_deprecated_string()); - if (Core::File::exists(path)) + if (Core::DeprecatedFile::exists(path)) emoji.image_path = move(path); } @@ -340,7 +340,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.parse(arguments); auto emoji_test_file = TRY(open_file(emoji_test_path, Core::Stream::OpenMode::Read)); - VERIFY(!emoji_resource_path.is_empty() && Core::File::exists(emoji_resource_path)); + VERIFY(!emoji_resource_path.is_empty() && Core::DeprecatedFile::exists(emoji_resource_path)); EmojiData emoji_data {}; TRY(parse_emoji_test_data(*emoji_test_file, emoji_data)); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h index 12f8e741f81..c83378f6f94 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h @@ -20,7 +20,6 @@ #include #include #include -#include #include #include diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/main.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/main.cpp index 5dda94b574c..ec07396c5f0 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/main.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/main.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/Meta/Lagom/Tools/ConfigureComponents/main.cpp b/Meta/Lagom/Tools/ConfigureComponents/main.cpp index 192717cddcc..a184dd5405e 100644 --- a/Meta/Lagom/Tools/ConfigureComponents/main.cpp +++ b/Meta/Lagom/Tools/ConfigureComponents/main.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -231,7 +231,7 @@ int main() return 1; } - auto current_working_directory = Core::File::current_working_directory(); + auto current_working_directory = Core::DeprecatedFile::current_working_directory(); if (current_working_directory.is_null()) return 1; auto lexical_cwd = LexicalPath(current_working_directory); @@ -241,7 +241,7 @@ int main() return 1; } - if (!Core::File::exists("components.ini"sv)) { + if (!Core::DeprecatedFile::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/Meta/Lagom/Tools/IPCMagicLinter/main.cpp b/Meta/Lagom/Tools/IPCMagicLinter/main.cpp index 5c482fc1fd6..f48e01bc178 100644 --- a/Meta/Lagom/Tools/IPCMagicLinter/main.cpp +++ b/Meta/Lagom/Tools/IPCMagicLinter/main.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include // Exit code is bitwise-or of these values: static constexpr auto EXIT_COLLISION = 0x1; @@ -25,7 +25,7 @@ int main(int argc, char** argv) bool had_errors = false; for (int file_index = 1; file_index < argc; ++file_index) { DeprecatedString filename(argv[file_index]); - auto file_or_error = Core::File::open(filename, Core::OpenMode::ReadOnly); + auto file_or_error = Core::DeprecatedFile::open(filename, Core::OpenMode::ReadOnly); if (file_or_error.is_error()) { warnln("Error: Cannot open '{}': {}", filename, file_or_error.error()); had_errors = true; diff --git a/Ports/OpenJDK/patches/0008-java.base-Enable-java.lang.Process-on-serenity.patch b/Ports/OpenJDK/patches/0008-java.base-Enable-java.lang.Process-on-serenity.patch index fd77cb1cda0..50763e01cee 100644 --- a/Ports/OpenJDK/patches/0008-java.base-Enable-java.lang.Process-on-serenity.patch +++ b/Ports/OpenJDK/patches/0008-java.base-Enable-java.lang.Process-on-serenity.patch @@ -88,9 +88,9 @@ index 0000000000000000000000000000000000000000..cc0c08cb85a682d66a00f6b48ad2871f +} + +#include ++#include +#include +#include -+#include +#include +#include + @@ -108,11 +108,11 @@ index 0000000000000000000000000000000000000000..cc0c08cb85a682d66a00f6b48ad2871f + }) + + -+static RefPtr proc_all; ++static RefPtr proc_all; + +extern "C" { +void os_initNative(JNIEnv *env, jclass clazz) { -+ proc_all = MUST(Core::File::open("/sys/kernel/processes", Core::OpenMode::ReadOnly)); ++ proc_all = MUST(Core::DeprecatedFile::open("/sys/kernel/processes", Core::OpenMode::ReadOnly)); +} + +jint os_getChildren(JNIEnv *env, jlong jpid, jlongArray jarray, diff --git a/Tests/Kernel/TestKernelFilePermissions.cpp b/Tests/Kernel/TestKernelFilePermissions.cpp index 00dbbabc5be..ec58a1f10a0 100644 --- a/Tests/Kernel/TestKernelFilePermissions.cpp +++ b/Tests/Kernel/TestKernelFilePermissions.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include @@ -81,7 +81,7 @@ TEST_CASE(test_change_file_location) ftruncate(fd, 0); EXPECT(fchmod(fd, 06755) != -1); - auto suid_path_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); + auto suid_path_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); EXPECT(!suid_path_or_error.is_error()); auto suid_path = suid_path_or_error.release_value(); diff --git a/Tests/LibC/TestIo.cpp b/Tests/LibC/TestIo.cpp index e121876d736..b7bcd583597 100644 --- a/Tests/LibC/TestIo.cpp +++ b/Tests/LibC/TestIo.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include #include @@ -217,7 +217,7 @@ TEST_CASE(unlink_symlink) perror("symlink"); } - auto target_or_error = Core::File::read_link("/tmp/linky"); + auto target_or_error = Core::DeprecatedFile::read_link("/tmp/linky"); EXPECT(!target_or_error.is_error()); auto target = target_or_error.release_value(); diff --git a/Tests/LibC/TestLibCMkTemp.cpp b/Tests/LibC/TestLibCMkTemp.cpp index 34df15b1451..9f7eedac6ff 100644 --- a/Tests/LibC/TestLibCMkTemp.cpp +++ b/Tests/LibC/TestLibCMkTemp.cpp @@ -6,7 +6,7 @@ */ #include -#include +#include #include #include #include @@ -86,7 +86,7 @@ TEST_CASE(test_mkstemp_unique_filename) auto fd = mkstemp(path); EXPECT_NE(fd, -1); - auto temp_path_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); + auto temp_path_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); EXPECT(!temp_path_or_error.is_error()); auto temp_path = temp_path_or_error.release_value(); @@ -107,7 +107,7 @@ TEST_CASE(test_mkstemp_unique_filename) auto fd = mkstemp(path); EXPECT(fd != -1); - auto path2_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); + auto path2_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); EXPECT(!path2_or_error.is_error()); auto path2 = path2_or_error.release_value(); @@ -132,7 +132,7 @@ TEST_CASE(test_mkstemps_unique_filename) auto fd = mkstemps(path, 6); EXPECT_NE(fd, -1); - auto temp_path_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); + auto temp_path_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); EXPECT(!temp_path_or_error.is_error()); auto temp_path = temp_path_or_error.release_value(); @@ -157,7 +157,7 @@ TEST_CASE(test_mkstemps_unique_filename) auto fd = mkstemps(path, 6); EXPECT(fd != -1); - auto path2_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); + auto path2_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); EXPECT(!path2_or_error.is_error()); auto path2 = path2_or_error.release_value(); diff --git a/Tests/LibCore/TestLibCoreIODevice.cpp b/Tests/LibCore/TestLibCoreIODevice.cpp index 4c4352fbeab..025d5042db2 100644 --- a/Tests/LibCore/TestLibCoreIODevice.cpp +++ b/Tests/LibCore/TestLibCoreIODevice.cpp @@ -4,14 +4,14 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include static bool files_have_same_contents(DeprecatedString filename1, DeprecatedString filename2) { - auto file1 = Core::File::open(filename1, Core::OpenMode::ReadOnly).value(); - auto file2 = Core::File::open(filename2, Core::OpenMode::ReadOnly).value(); + auto file1 = Core::DeprecatedFile::open(filename1, Core::OpenMode::ReadOnly).value(); + auto file2 = Core::DeprecatedFile::open(filename2, Core::OpenMode::ReadOnly).value(); auto contents1 = file1->read_all(), contents2 = file2->read_all(); return contents1 == contents2; } @@ -19,14 +19,14 @@ static bool files_have_same_contents(DeprecatedString filename1, DeprecatedStrin TEST_CASE(file_readline) { auto path = "long_lines.txt"; - auto file_or_error = Core::File::open(path, Core::OpenMode::ReadOnly); + auto file_or_error = Core::DeprecatedFile::open(path, Core::OpenMode::ReadOnly); if (file_or_error.is_error()) { warnln("Failed to open {}: {}", path, file_or_error.error()); VERIFY_NOT_REACHED(); } auto file = file_or_error.release_value(); auto output_path = "/tmp/output.txt"; - auto outfile_or_error = Core::File::open(output_path, Core::OpenMode::WriteOnly); + auto outfile_or_error = Core::DeprecatedFile::open(output_path, Core::OpenMode::WriteOnly); auto outputfile = outfile_or_error.release_value(); while (file->can_read_line()) { outputfile->write(file->read_line()); @@ -41,7 +41,7 @@ TEST_CASE(file_readline) TEST_CASE(file_get_read_position) { const DeprecatedString path = "10kb.txt"; - auto file = Core::File::open(path, Core::OpenMode::ReadOnly).release_value(); + auto file = Core::DeprecatedFile::open(path, Core::OpenMode::ReadOnly).release_value(); const size_t step_size = 98; for (size_t i = 0; i < 10240 - step_size; i += step_size) { @@ -73,14 +73,14 @@ TEST_CASE(file_get_read_position) TEST_CASE(file_lines_range) { auto path = "long_lines.txt"; - auto file_or_error = Core::File::open(path, Core::OpenMode::ReadOnly); + auto file_or_error = Core::DeprecatedFile::open(path, Core::OpenMode::ReadOnly); if (file_or_error.is_error()) { warnln("Failed to open {}: {}", path, file_or_error.error()); VERIFY_NOT_REACHED(); } auto file = file_or_error.release_value(); auto output_path = "/tmp/output.txt"; - auto outfile_or_error = Core::File::open(output_path, Core::OpenMode::WriteOnly); + auto outfile_or_error = Core::DeprecatedFile::open(output_path, Core::OpenMode::WriteOnly); auto outputfile = outfile_or_error.release_value(); for (auto line : file->lines()) { outputfile->write(line); diff --git a/Tests/LibELF/test-elf.cpp b/Tests/LibELF/test-elf.cpp index 8b4331ad423..2cb187a6a31 100644 --- a/Tests/LibELF/test-elf.cpp +++ b/Tests/LibELF/test-elf.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -58,7 +58,7 @@ TEST_CASE(test_interp_header_tiny_p_filesz) int nwritten = write(fd, buffer, sizeof(buffer)); EXPECT(nwritten); - auto elf_path_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); + auto elf_path_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); EXPECT(!elf_path_or_error.is_error()); auto elf_path = elf_path_or_error.release_value(); @@ -115,7 +115,7 @@ TEST_CASE(test_interp_header_p_filesz_larger_than_p_memsz) int nwritten = write(fd, buffer, sizeof(buffer)); EXPECT(nwritten); - auto elf_path_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); + auto elf_path_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); EXPECT(!elf_path_or_error.is_error()); auto elf_path = elf_path_or_error.release_value(); @@ -176,7 +176,7 @@ TEST_CASE(test_interp_header_p_filesz_plus_p_offset_overflow_p_memsz) int nwritten = write(fd, buffer, sizeof(buffer)); EXPECT(nwritten); - auto elf_path_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); + auto elf_path_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); EXPECT(!elf_path_or_error.is_error()); auto elf_path = elf_path_or_error.release_value(); @@ -234,7 +234,7 @@ TEST_CASE(test_load_header_p_memsz_zero) int nwritten = write(fd, buffer, sizeof(buffer)); EXPECT(nwritten); - auto elf_path_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); + auto elf_path_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); EXPECT(!elf_path_or_error.is_error()); auto elf_path = elf_path_or_error.release_value(); @@ -292,7 +292,7 @@ TEST_CASE(test_load_header_p_memsz_not_equal_to_p_align) int nwritten = write(fd, buffer, sizeof(buffer)); EXPECT(nwritten); - auto elf_path_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); + auto elf_path_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)); EXPECT(!elf_path_or_error.is_error()); auto elf_path = elf_path_or_error.release_value(); diff --git a/Tests/LibJS/test-test262.cpp b/Tests/LibJS/test-test262.cpp index 0adcc607c01..075197bbb79 100644 --- a/Tests/LibJS/test-test262.cpp +++ b/Tests/LibJS/test-test262.cpp @@ -13,7 +13,7 @@ #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::File::is_directory(test_directory)) { + if (!Core::DeprecatedFile::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 8f0a96e7cb2..1878b6a425f 100644 --- a/Tests/LibTLS/TestTLSHandshake.cpp +++ b/Tests/LibTLS/TestTLSHandshake.cpp @@ -6,8 +6,8 @@ #include #include +#include #include -#include #include #include #include @@ -27,11 +27,11 @@ DeprecatedString locate_ca_certs_file(); DeprecatedString locate_ca_certs_file() { - if (Core::File::exists(ca_certs_file)) { + if (Core::DeprecatedFile::exists(ca_certs_file)) { return ca_certs_file; } auto on_target_path = DeprecatedString("/etc/ca_certs.ini"); - if (Core::File::exists(on_target_path)) { + if (Core::DeprecatedFile::exists(on_target_path)) { return on_target_path; } return ""; diff --git a/Userland/Applications/3DFileViewer/MeshLoader.h b/Userland/Applications/3DFileViewer/MeshLoader.h index 0c33507962c..3e1f1f0680f 100644 --- a/Userland/Applications/3DFileViewer/MeshLoader.h +++ b/Userland/Applications/3DFileViewer/MeshLoader.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include "Common.h" #include "Mesh.h" @@ -18,5 +18,5 @@ public: MeshLoader() = default; virtual ~MeshLoader() = default; - virtual ErrorOr> load(Core::File& file) = 0; + virtual ErrorOr> load(Core::DeprecatedFile& file) = 0; }; diff --git a/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp b/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp index e5b7f5b9d1f..d6231abc929 100644 --- a/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp +++ b/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp @@ -8,7 +8,7 @@ #include "WavefrontOBJLoader.h" #include -#include +#include #include static inline GLuint get_index_value(StringView& representation) @@ -16,7 +16,7 @@ static inline GLuint get_index_value(StringView& representation) return representation.to_uint().value_or(1) - 1; } -ErrorOr> WavefrontOBJLoader::load(Core::File& file) +ErrorOr> WavefrontOBJLoader::load(Core::DeprecatedFile& file) { Vector vertices; Vector normals; diff --git a/Userland/Applications/3DFileViewer/WavefrontOBJLoader.h b/Userland/Applications/3DFileViewer/WavefrontOBJLoader.h index 77e197e43d1..1429547e6c9 100644 --- a/Userland/Applications/3DFileViewer/WavefrontOBJLoader.h +++ b/Userland/Applications/3DFileViewer/WavefrontOBJLoader.h @@ -18,5 +18,5 @@ public: WavefrontOBJLoader() = default; ~WavefrontOBJLoader() override = default; - ErrorOr> load(Core::File& file) override; + ErrorOr> load(Core::DeprecatedFile& file) override; }; diff --git a/Userland/Applications/3DFileViewer/main.cpp b/Userland/Applications/3DFileViewer/main.cpp index 27442da7184..e74a2ea7604 100644 --- a/Userland/Applications/3DFileViewer/main.cpp +++ b/Userland/Applications/3DFileViewer/main.cpp @@ -6,7 +6,6 @@ */ #include -#include #include #include #include @@ -34,7 +33,7 @@ class GLContextWidget final : public GUI::Frame { public: bool load_path(DeprecatedString const& fname); - bool load_file(Core::File& file); + bool load_file(Core::DeprecatedFile& file); void toggle_rotate_x() { m_rotate_x = !m_rotate_x; } void toggle_rotate_y() { m_rotate_y = !m_rotate_y; } void toggle_rotate_z() { m_rotate_z = !m_rotate_z; } @@ -291,7 +290,7 @@ void GLContextWidget::timer_event(Core::TimerEvent&) bool GLContextWidget::load_path(DeprecatedString const& filename) { - auto file = Core::File::construct(filename); + auto file = Core::DeprecatedFile::construct(filename); if (!file->open(Core::OpenMode::ReadOnly) && file->error() != ENOENT) { GUI::MessageBox::show(window(), DeprecatedString::formatted("Opening \"{}\" failed: {}", filename, strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error); @@ -301,7 +300,7 @@ bool GLContextWidget::load_path(DeprecatedString const& filename) return load_file(file); } -bool GLContextWidget::load_file(Core::File& file) +bool GLContextWidget::load_file(Core::DeprecatedFile& file) { auto const& filename = file.filename(); if (!filename.ends_with(".obj"sv)) { @@ -330,11 +329,11 @@ bool GLContextWidget::load_file(Core::File& file) builder.append(filename.split('.').at(0)); builder.append(".bmp"sv); - DeprecatedString texture_path = Core::File::absolute_path(builder.string_view()); + DeprecatedString texture_path = Core::DeprecatedFile::absolute_path(builder.string_view()); // Attempt to open the texture file from disk RefPtr texture_image; - if (Core::File::exists(texture_path)) { + if (Core::DeprecatedFile::exists(texture_path)) { auto bitmap_or_error = Gfx::Bitmap::load_from_file(texture_path); if (!bitmap_or_error.is_error()) texture_image = bitmap_or_error.release_value_but_fixme_should_propagate_errors(); @@ -403,7 +402,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto file = response.value(); if (widget->load_file(*file)) { - auto canonical_path = Core::File::absolute_path(file->filename()); + auto canonical_path = Core::DeprecatedFile::absolute_path(file->filename()); window->set_title(DeprecatedString::formatted("{} - 3D File Viewer", canonical_path)); } })); @@ -592,7 +591,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto filename = arguments.argc > 1 ? arguments.argv[1] : "/home/anon/Documents/3D Models/teapot.obj"; if (widget->load_path(filename)) { - auto canonical_path = Core::File::absolute_path(filename); + auto canonical_path = Core::DeprecatedFile::absolute_path(filename); window->set_title(DeprecatedString::formatted("{} - 3D File Viewer", canonical_path)); } diff --git a/Userland/Applications/Assistant/Providers.cpp b/Userland/Applications/Assistant/Providers.cpp index bfdcb66d8af..97ca9b3c174 100644 --- a/Userland/Applications/Assistant/Providers.cpp +++ b/Userland/Applications/Assistant/Providers.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -23,6 +22,7 @@ #include #include #include +#include #include namespace Assistant { diff --git a/Userland/Applications/Browser/main.cpp b/Userland/Applications/Browser/main.cpp index 05477647d91..b094e44e0f5 100644 --- a/Userland/Applications/Browser/main.cpp +++ b/Userland/Applications/Browser/main.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -131,8 +131,8 @@ ErrorOr serenity_main(Main::Arguments arguments) } auto url_from_argument_string = [](DeprecatedString const& string) -> URL { - if (Core::File::exists(string)) { - return URL::create_with_file_scheme(Core::File::real_path_for(string)); + if (Core::DeprecatedFile::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/main.cpp b/Userland/Applications/CrashReporter/main.cpp index f3c6a46b2a7..06410e508f4 100644 --- a/Userland/Applications/CrashReporter/main.cpp +++ b/Userland/Applications/CrashReporter/main.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -131,7 +130,7 @@ static TitleAndText build_cpu_registers(const ELF::Core::ThreadInfo& thread_info static void unlink_coredump(StringView coredump_path) { - if (Core::File::remove(coredump_path, Core::File::RecursionMode::Disallowed).is_error()) + if (Core::DeprecatedFile::remove(coredump_path, Core::DeprecatedFile::RecursionMode::Disallowed).is_error()) dbgln("Failed deleting coredump file"); } diff --git a/Userland/Applications/DisplaySettings/ThemePreviewWidget.cpp b/Userland/Applications/DisplaySettings/ThemePreviewWidget.cpp index 1be525239e8..35abe94a035 100644 --- a/Userland/Applications/DisplaySettings/ThemePreviewWidget.cpp +++ b/Userland/Applications/DisplaySettings/ThemePreviewWidget.cpp @@ -6,7 +6,6 @@ #include "ThemePreviewWidget.h" #include -#include #include #include #include diff --git a/Userland/Applications/Escalator/main.cpp b/Userland/Applications/Escalator/main.cpp index c84b1eb9f7e..7bcce414298 100644 --- a/Userland/Applications/Escalator/main.cpp +++ b/Userland/Applications/Escalator/main.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -33,7 +33,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app = TRY(GUI::Application::try_create(arguments)); - auto executable_path = Core::File::resolve_executable_from_environment(command[0]); + auto executable_path = Core::DeprecatedFile::resolve_executable_from_environment(command[0]); if (!executable_path.has_value()) { GUI::MessageBox::show_error(nullptr, DeprecatedString::formatted("Could not execute command {}: Command not found.", command[0])); return 127; diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp index 0cd9e3a286e..3d7f684dc07 100644 --- a/Userland/Applications/FileManager/DirectoryView.cpp +++ b/Userland/Applications/FileManager/DirectoryView.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -204,7 +204,7 @@ void DirectoryView::setup_model() while (model_root.string() != "/") { model_root = model_root.parent(); - if (Core::File::is_directory(model_root.string())) + if (Core::DeprecatedFile::is_directory(model_root.string())) break; } @@ -405,8 +405,8 @@ void DirectoryView::add_path_to_history(DeprecatedString path) bool DirectoryView::open(DeprecatedString const& path) { - auto real_path = Core::File::real_path_for(path); - if (real_path.is_null() || !Core::File::is_directory(path)) + auto real_path = Core::DeprecatedFile::real_path_for(path); + if (real_path.is_null() || !Core::DeprecatedFile::is_directory(path)) return false; if (chdir(real_path.characters()) < 0) { @@ -555,7 +555,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::File::can_delete_or_move(node(index).full_path()); + return Core::DeprecatedFile::can_delete_or_move(node(index).full_path()); }).has_value(); // clang-format on } diff --git a/Userland/Applications/FileManager/FileOperationProgressWidget.cpp b/Userland/Applications/FileManager/FileOperationProgressWidget.cpp index ed4f1a764dd..a185c4e58e5 100644 --- a/Userland/Applications/FileManager/FileOperationProgressWidget.cpp +++ b/Userland/Applications/FileManager/FileOperationProgressWidget.cpp @@ -8,7 +8,6 @@ #include "FileOperationProgressWidget.h" #include "FileUtils.h" #include -#include #include #include #include diff --git a/Userland/Applications/FileManager/FileUtils.cpp b/Userland/Applications/FileManager/FileUtils.cpp index d9daae3f71d..c25b0457a84 100644 --- a/Userland/Applications/FileManager/FileUtils.cpp +++ b/Userland/Applications/FileManager/FileUtils.cpp @@ -8,7 +8,7 @@ #include "FileUtils.h" #include "FileOperationProgressWidget.h" #include -#include +#include #include #include #include @@ -125,7 +125,7 @@ ErrorOr handle_drop(GUI::DropEvent const& event, DeprecatedString const& d auto const target = LexicalPath::canonicalized_path(destination); - if (!Core::File::is_directory(target)) + if (!Core::DeprecatedFile::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 75632ab82d6..6e0a537cd6c 100644 --- a/Userland/Applications/FileManager/PropertiesWindow.cpp +++ b/Userland/Applications/FileManager/PropertiesWindow.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -102,7 +103,7 @@ ErrorOr PropertiesWindow::create_widgets(bool disable_rename) type->set_text(get_description(m_mode)); if (S_ISLNK(m_mode)) { - auto link_destination_or_error = Core::File::read_link(m_path); + auto link_destination_or_error = Core::DeprecatedFile::read_link(m_path); if (link_destination_or_error.is_error()) { perror("readlink"); } else { @@ -214,7 +215,7 @@ bool PropertiesWindow::apply_changes() DeprecatedString new_name = m_name_box->text(); DeprecatedString new_file = make_full_path(new_name).characters(); - if (Core::File::exists(new_file)) { + if (Core::DeprecatedFile::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/PropertiesWindow.h b/Userland/Applications/FileManager/PropertiesWindow.h index 030342d0743..579c5e42f76 100644 --- a/Userland/Applications/FileManager/PropertiesWindow.h +++ b/Userland/Applications/FileManager/PropertiesWindow.h @@ -8,7 +8,6 @@ #pragma once #include -#include #include #include #include diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index 307fd55fe8c..9cd52d26569 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -107,14 +107,14 @@ ErrorOr serenity_main(Main::Arguments arguments) if (!initial_location.is_empty()) { if (!ignore_path_resolution) - initial_location = Core::File::real_path_for(initial_location); + initial_location = Core::DeprecatedFile::real_path_for(initial_location); - if (!Core::File::is_directory(initial_location)) + if (!Core::DeprecatedFile::is_directory(initial_location)) is_selection_mode = true; } if (initial_location.is_empty()) - initial_location = Core::File::current_working_directory(); + initial_location = Core::DeprecatedFile::current_working_directory(); if (initial_location.is_empty()) initial_location = Core::StandardPaths::home_directory(); @@ -188,7 +188,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::File::link_file(destination, path); result.is_error()) { + if (auto result = Core::DeprecatedFile::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); } @@ -456,7 +456,7 @@ ErrorOr run_in_desktop_mode() } for (auto& path : paths) { - if (Core::File::is_directory(path)) + if (Core::DeprecatedFile::is_directory(path)) Desktop::Launcher::open(URL::create_with_file_scheme(path)); } }); @@ -469,7 +469,7 @@ ErrorOr run_in_desktop_mode() } for (auto& path : paths) { - if (Core::File::is_directory(path)) { + if (Core::DeprecatedFile::is_directory(path)) { spawn_terminal(path); } } @@ -814,7 +814,7 @@ ErrorOr run_in_windowed_mode(DeprecatedString const& initial_location, Depr paths = directory_view->selected_file_paths(); for (auto& path : paths) { - if (Core::File::is_directory(path)) + if (Core::DeprecatedFile::is_directory(path)) Desktop::Launcher::open(URL::create_with_file_scheme(path)); } }, @@ -833,7 +833,7 @@ ErrorOr run_in_windowed_mode(DeprecatedString const& initial_location, Depr paths = directory_view->selected_file_paths(); for (auto& path : paths) { - if (Core::File::is_directory(path)) { + if (Core::DeprecatedFile::is_directory(path)) { spawn_terminal(path); } } @@ -1090,7 +1090,7 @@ ErrorOr run_in_windowed_mode(DeprecatedString const& initial_location, Depr if (!segment_index.has_value()) return; auto selected_path = breadcrumbbar.segment_data(*segment_index); - if (Core::File::is_directory(selected_path)) { + if (Core::DeprecatedFile::is_directory(selected_path)) { directory_view->open(selected_path); } else { dbgln("Breadcrumb path '{}' doesn't exist", selected_path); @@ -1121,7 +1121,7 @@ ErrorOr run_in_windowed_mode(DeprecatedString const& initial_location, Depr // If the path change was because the directory we were in was deleted, // remove the breadcrumbs for it. if ((new_segment_index + 1 < breadcrumbbar.segment_count()) - && !Core::File::is_directory(breadcrumbbar.segment_data(new_segment_index + 1))) { + && !Core::DeprecatedFile::is_directory(breadcrumbbar.segment_data(new_segment_index + 1))) { breadcrumbbar.remove_end_segments(new_segment_index + 1); } } else { diff --git a/Userland/Applications/Help/MainWidget.cpp b/Userland/Applications/Help/MainWidget.cpp index 65453b39e40..be58ec69f1c 100644 --- a/Userland/Applications/Help/MainWidget.cpp +++ b/Userland/Applications/Help/MainWidget.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Applications/HexEditor/HexDocument.h b/Userland/Applications/HexEditor/HexDocument.h index 6a5f7943cca..d5e46a4f877 100644 --- a/Userland/Applications/HexEditor/HexDocument.h +++ b/Userland/Applications/HexEditor/HexDocument.h @@ -6,11 +6,13 @@ #pragma once +#include +#include #include #include #include #include -#include +#include #include constexpr Time COMMAND_COMMIT_TIME = Time::from_milliseconds(400); diff --git a/Userland/Applications/ImageViewer/ViewWidget.cpp b/Userland/Applications/ImageViewer/ViewWidget.cpp index 52f7a454bb9..6bdfd5d05ba 100644 --- a/Userland/Applications/ImageViewer/ViewWidget.cpp +++ b/Userland/Applications/ImageViewer/ViewWidget.cpp @@ -11,8 +11,8 @@ #include "ViewWidget.h" #include #include +#include #include -#include #include #include #include @@ -195,7 +195,7 @@ void ViewWidget::load_from_file(DeprecatedString const& path) m_timer->stop(); } - m_path = Core::File::real_path_for(path); + m_path = Core::DeprecatedFile::real_path_for(path); reset_view(); } diff --git a/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp b/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp index d368ec0e7bb..83624bef9f1 100644 --- a/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp +++ b/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp @@ -12,8 +12,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -153,7 +153,7 @@ KeyboardSettingsWidget::KeyboardSettingsWidget() { load_from_gml(keyboard_widget_gml).release_value_but_fixme_should_propagate_errors(); - auto proc_keymap = Core::File::construct("/sys/kernel/keymap"); + auto proc_keymap = Core::DeprecatedFile::construct("/sys/kernel/keymap"); if (!proc_keymap->open(Core::OpenMode::ReadOnly)) VERIFY_NOT_REACHED(); diff --git a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp index 5678029ca06..a57685df360 100644 --- a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp +++ b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Applications/NetworkSettings/main.cpp b/Userland/Applications/NetworkSettings/main.cpp index 22354b10bb0..63270f49cf7 100644 --- a/Userland/Applications/NetworkSettings/main.cpp +++ b/Userland/Applications/NetworkSettings/main.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp index 1f4d91b376b..b98629302e8 100644 --- a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp +++ b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Applications/PartitionEditor/PartitionModel.cpp b/Userland/Applications/PartitionEditor/PartitionModel.cpp index f6cf48cf49a..73f7da320eb 100644 --- a/Userland/Applications/PartitionEditor/PartitionModel.cpp +++ b/Userland/Applications/PartitionEditor/PartitionModel.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -62,7 +63,7 @@ GUI::Variant PartitionModel::data(GUI::ModelIndex const& index, GUI::ModelRole r ErrorOr PartitionModel::set_device_path(DeprecatedString const& path) { - auto file = TRY(Core::File::open(path, Core::OpenMode::ReadOnly)); + auto file = TRY(Core::DeprecatedFile::open(path, Core::OpenMode::ReadOnly)); auto mbr_table_or_error = Partition::MBRPartitionTable::try_to_initialize(file); if (!mbr_table_or_error.is_error()) { diff --git a/Userland/Applications/PartitionEditor/main.cpp b/Userland/Applications/PartitionEditor/main.cpp index 8bf735f3699..9c05c24ccb8 100644 --- a/Userland/Applications/PartitionEditor/main.cpp +++ b/Userland/Applications/PartitionEditor/main.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -22,7 +23,7 @@ static Vector get_device_paths() Core::DirIterator iterator("/dev", Core::DirIterator::SkipParentAndBaseDir); while (iterator.has_next()) { auto path = iterator.next_full_path(); - if (Core::File::is_block_device(path)) + if (Core::DeprecatedFile::is_block_device(path)) device_paths.append(path); } return device_paths; diff --git a/Userland/Applications/Run/RunWindow.cpp b/Userland/Applications/Run/RunWindow.cpp index d961eb98944..4c86e9df8ee 100644 --- a/Userland/Applications/Run/RunWindow.cpp +++ b/Userland/Applications/Run/RunWindow.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -143,9 +143,9 @@ bool RunWindow::run_via_launch(DeprecatedString const& run_input) auto url = URL::create_with_url_or_path(run_input); if (url.scheme() == "file") { - auto real_path = Core::File::real_path_for(url.path()); + auto real_path = Core::DeprecatedFile::real_path_for(url.path()); if (real_path.is_null()) { - // errno *should* be preserved from Core::File::real_path_for(). + // errno *should* be preserved from Core::DeprecatedFile::real_path_for(). warnln("Failed to launch '{}': {}", url.path(), strerror(errno)); return false; } diff --git a/Userland/Applications/SoundPlayer/AlbumCoverVisualizationWidget.cpp b/Userland/Applications/SoundPlayer/AlbumCoverVisualizationWidget.cpp index 8d3cdbb6938..3eeda05ed70 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::File::exists(cover_path.string())) + if (Core::DeprecatedFile::exists(cover_path.string())) return Gfx::Bitmap::load_from_file(cover_path.string()); } diff --git a/Userland/Applications/SoundPlayer/Player.cpp b/Userland/Applications/SoundPlayer/Player.cpp index 87c3684e489..af254a04809 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::File::exists(path)) { + if (!Core::DeprecatedFile::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 991f368040f..63bd4e97742 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::File::size(entry.path); + auto size = Core::DeprecatedFile::size(entry.path); if (size.is_error()) continue; entry.extended_info->file_size_in_bytes = size.value(); - } else if (!Core::File::exists(entry.path)) { + } else if (!Core::DeprecatedFile::exists(entry.path)) { to_delete.append(&entry); continue; } diff --git a/Userland/Applications/SpaceAnalyzer/main.cpp b/Userland/Applications/SpaceAnalyzer/main.cpp index 856746c9b5e..f7a584cd26c 100644 --- a/Userland/Applications/SpaceAnalyzer/main.cpp +++ b/Userland/Applications/SpaceAnalyzer/main.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -97,7 +97,7 @@ ErrorOr serenity_main(Main::Arguments arguments) while (try_again) { try_again = false; - auto deletion_result = Core::File::remove(selected_node_path, Core::File::RecursionMode::Allowed); + auto deletion_result = Core::DeprecatedFile::remove(selected_node_path, Core::DeprecatedFile::RecursionMode::Allowed); if (deletion_result.is_error()) { auto retry_message_result = GUI::MessageBox::show(window, DeprecatedString::formatted("Failed to delete \"{}\": {}. Retry?", @@ -164,8 +164,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::File::can_delete_or_move(selected_node_path)); - if (Core::File::is_directory(selected_node_path)) { + delete_action->set_enabled(Core::DeprecatedFile::can_delete_or_move(selected_node_path)); + if (Core::DeprecatedFile::is_directory(selected_node_path)) { open_folder_action->set_visible(true); open_containing_folder_action->set_visible(false); } else { diff --git a/Userland/Applications/Spreadsheet/ImportDialog.cpp b/Userland/Applications/Spreadsheet/ImportDialog.cpp index a22c32bfe4b..f27cfdf8b27 100644 --- a/Userland/Applications/Spreadsheet/ImportDialog.cpp +++ b/Userland/Applications/Spreadsheet/ImportDialog.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Applications/Spreadsheet/Readers/Test/TestXSV.cpp b/Userland/Applications/Spreadsheet/Readers/Test/TestXSV.cpp index 82a0df5ab31..b0c93e2ed51 100644 --- a/Userland/Applications/Spreadsheet/Readers/Test/TestXSV.cpp +++ b/Userland/Applications/Spreadsheet/Readers/Test/TestXSV.cpp @@ -9,7 +9,6 @@ #include "../CSV.h" #include "../XSV.h" #include -#include #include TEST_CASE(should_parse_valid_data) diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp index 3893e3988ea..94b12d07f00 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -49,7 +49,7 @@ Sheet::Sheet(Workbook& workbook) // Sadly, these have to be evaluated once per sheet. constexpr auto runtime_file_path = "/res/js/Spreadsheet/runtime.js"sv; - auto file_or_error = Core::File::open(runtime_file_path, Core::OpenMode::ReadOnly); + auto file_or_error = Core::DeprecatedFile::open(runtime_file_path, Core::OpenMode::ReadOnly); if (!file_or_error.is_error()) { auto buffer = file_or_error.value()->read_all(); auto script_or_error = JS::Script::parse(buffer, interpreter().realm(), runtime_file_path); diff --git a/Userland/Applications/Spreadsheet/main.cpp b/Userland/Applications/Spreadsheet/main.cpp index 73bfcab70fd..31d1dbafed2 100644 --- a/Userland/Applications/Spreadsheet/main.cpp +++ b/Userland/Applications/Spreadsheet/main.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -34,7 +33,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.parse(arguments); if (filename) { - if (!Core::File::exists({ filename, strlen(filename) }) || Core::File::is_directory(filename)) { + if (!Core::DeprecatedFile::exists({ filename, strlen(filename) }) || Core::DeprecatedFile::is_directory(filename)) { warnln("File does not exist or is a directory: {}", filename); return 1; } diff --git a/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp b/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp index 85b2727c14f..5c952bae9bd 100644 --- a/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp +++ b/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp @@ -9,7 +9,7 @@ #include "GraphWidget.h" #include #include -#include +#include #include #include #include @@ -104,7 +104,7 @@ static inline u64 page_count_to_bytes(size_t count) void MemoryStatsWidget::refresh() { - auto proc_memstat = Core::File::construct("/sys/kernel/memstat"); + auto proc_memstat = Core::DeprecatedFile::construct("/sys/kernel/memstat"); if (!proc_memstat->open(Core::OpenMode::ReadOnly)) VERIFY_NOT_REACHED(); diff --git a/Userland/Applications/SystemMonitor/ProcessModel.cpp b/Userland/Applications/SystemMonitor/ProcessModel.cpp index 716ad23c1c7..f32d84ad25b 100644 --- a/Userland/Applications/SystemMonitor/ProcessModel.cpp +++ b/Userland/Applications/SystemMonitor/ProcessModel.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -32,7 +32,7 @@ ProcessModel::ProcessModel() VERIFY(!s_the); s_the = this; - auto file = Core::File::construct("/sys/kernel/cpuinfo"); + auto file = Core::DeprecatedFile::construct("/sys/kernel/cpuinfo"); if (file->open(Core::OpenMode::ReadOnly)) { auto buffer = file->read_all(); auto json = JsonValue::from_string({ buffer }); diff --git a/Userland/Applications/SystemMonitor/ProcessModel.h b/Userland/Applications/SystemMonitor/ProcessModel.h index 9822ffbcccf..c9100de39fd 100644 --- a/Userland/Applications/SystemMonitor/ProcessModel.h +++ b/Userland/Applications/SystemMonitor/ProcessModel.h @@ -245,7 +245,7 @@ private: HashMap> m_threads; NonnullOwnPtrVector m_processes; NonnullOwnPtrVector m_cpus; - RefPtr m_proc_all; + RefPtr m_proc_all; GUI::Icon m_kernel_process_icon; u64 m_total_time_scheduled { 0 }; u64 m_total_time_scheduled_kernel { 0 }; diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index a2e5a591b04..07da8ba6744 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -10,8 +10,8 @@ #include #include #include +#include #include -#include #include #include #include diff --git a/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp b/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp index 9d1e9014028..6f5c559568e 100644 --- a/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp +++ b/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Applications/TextEditor/FileArgument.cpp b/Userland/Applications/TextEditor/FileArgument.cpp index 590c7fc985a..a507e1258c7 100644 --- a/Userland/Applications/TextEditor/FileArgument.cpp +++ b/Userland/Applications/TextEditor/FileArgument.cpp @@ -6,7 +6,6 @@ */ #include "FileArgument.h" -#include #include namespace TextEditor { diff --git a/Userland/Applications/TextEditor/MainWidget.cpp b/Userland/Applications/TextEditor/MainWidget.cpp index 03fed823794..99a42a31783 100644 --- a/Userland/Applications/TextEditor/MainWidget.cpp +++ b/Userland/Applications/TextEditor/MainWidget.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Applications/ThemeEditor/MainWidget.cpp b/Userland/Applications/ThemeEditor/MainWidget.cpp index ef8131d3d46..ff4e6453ddf 100644 --- a/Userland/Applications/ThemeEditor/MainWidget.cpp +++ b/Userland/Applications/ThemeEditor/MainWidget.cpp @@ -589,8 +589,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::File::exists(target_path)) { - if (!Core::File::is_directory(target_path)) + if (Core::DeprecatedFile::exists(target_path)) { + if (!Core::DeprecatedFile::is_directory(target_path)) target_path = LexicalPath::dirname(target_path); } else { target_path = "/res/icons"; diff --git a/Userland/Applications/ThemeEditor/main.cpp b/Userland/Applications/ThemeEditor/main.cpp index 93498e581ea..da97df06264 100644 --- a/Userland/Applications/ThemeEditor/main.cpp +++ b/Userland/Applications/ThemeEditor/main.cpp @@ -36,7 +36,7 @@ ErrorOr serenity_main(Main::Arguments arguments) Optional path = {}; if (!file_to_edit.is_empty()) - path = Core::File::absolute_path(file_to_edit); + path = Core::DeprecatedFile::absolute_path(file_to_edit); TRY(Core::System::pledge("stdio recvfd sendfd thread rpath unix")); TRY(Core::System::unveil("/tmp/session/%sid/portal/filesystemaccess", "rw")); diff --git a/Userland/Demos/CatDog/CatDog.h b/Userland/Demos/CatDog/CatDog.h index ddabc8f39f0..f5daca0e4d3 100644 --- a/Userland/Demos/CatDog/CatDog.h +++ b/Userland/Demos/CatDog/CatDog.h @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp index 1bf96a70e8b..597b50860c3 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::File::exists(DeprecatedString::formatted("{}/{}", create_in, candidate))) + if (!Core::DeprecatedFile::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::File::exists(create_in) || !Core::File::is_directory(create_in)) { + if (!Core::DeprecatedFile::exists(create_in) || !Core::DeprecatedFile::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 c4c15a402dd..4fe98a0b61e 100644 --- a/Userland/DevTools/HackStudio/Editor.cpp +++ b/Userland/DevTools/HackStudio/Editor.cpp @@ -15,8 +15,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -420,7 +420,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::File::is_directory(path)) { + if (!Core::DeprecatedFile::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/Git/GitWidget.cpp b/Userland/DevTools/HackStudio/Git/GitWidget.cpp index 8c2a1590517..e079a84dd51 100644 --- a/Userland/DevTools/HackStudio/Git/GitWidget.cpp +++ b/Userland/DevTools/HackStudio/Git/GitWidget.cpp @@ -7,7 +7,6 @@ #include "GitWidget.h" #include "../Dialogs/Git/GitCommitDialog.h" #include "GitFilesModel.h" -#include #include #include #include diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 7cfd771a4cf..464baebc50a 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -27,9 +27,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -312,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::File::is_directory(filename) || !Core::File::exists(filename)) + if (Core::DeprecatedFile::is_directory(filename) || !Core::DeprecatedFile::exists(filename)) return false; auto editor_wrapper_or_none = m_all_editor_wrappers.first_matching([&](auto& wrapper) { @@ -534,13 +534,13 @@ ErrorOr> HackStudioWidget::create_new_file_action(Dep DeprecatedString filepath; if (!path_to_selected.is_empty()) { - VERIFY(Core::File::exists(path_to_selected.first())); + VERIFY(Core::DeprecatedFile::exists(path_to_selected.first())); LexicalPath selected(path_to_selected.first()); DeprecatedString dir_path; - if (Core::File::is_directory(selected.string())) + if (Core::DeprecatedFile::is_directory(selected.string())) dir_path = selected.string(); else dir_path = selected.dirname(); @@ -574,7 +574,7 @@ ErrorOr> HackStudioWidget::create_new_directory_actio DeprecatedString dir_path; - if (Core::File::is_directory(selected.string())) + if (Core::DeprecatedFile::is_directory(selected.string())) dir_path = selected.string(); else dir_path = selected.dirname(); @@ -682,7 +682,7 @@ NonnullRefPtr HackStudioWidget::create_delete_action() } bool is_directory = S_ISDIR(st.st_mode); - if (auto result = Core::File::remove(file, Core::File::RecursionMode::Allowed); result.is_error()) { + if (auto result = Core::DeprecatedFile::remove(file, Core::DeprecatedFile::RecursionMode::Allowed); result.is_error()) { auto& error = result.error(); if (is_directory) { GUI::MessageBox::show(window(), @@ -904,7 +904,7 @@ NonnullRefPtr HackStudioWidget::create_save_as_action() Optional save_path = GUI::FilePicker::get_save_filepath(window(), old_filename.is_null() ? "Untitled"sv : old_path.title(), old_filename.is_null() ? "txt"sv : old_path.extension(), - Core::File::absolute_path(old_path.dirname())); + Core::DeprecatedFile::absolute_path(old_path.dirname())); if (!save_path.has_value()) { return; } @@ -1001,7 +1001,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::File::exists(get_project_executable_path())) { + if (!Core::DeprecatedFile::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; } @@ -1245,7 +1245,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::File::can_delete_or_move(m_project->model().full_path(selected_file)); + return Core::DeprecatedFile::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); @@ -1779,10 +1779,10 @@ ErrorOr> HackStudioWidget::create_open_project_config DeprecatedString formatted_error_string_holder; auto save_configuration_or_error = [&]() -> ErrorOr { - if (Core::File::exists(absolute_config_file_path)) + if (Core::DeprecatedFile::exists(absolute_config_file_path)) return {}; - if (Core::File::exists(parent_directory) && !Core::File::is_directory(parent_directory)) { + if (Core::DeprecatedFile::exists(parent_directory) && !Core::DeprecatedFile::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/LanguageServers/ConnectionFromClient.cpp b/Userland/DevTools/HackStudio/LanguageServers/ConnectionFromClient.cpp index 8efddd65fd4..500b3be695f 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/ConnectionFromClient.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/ConnectionFromClient.cpp @@ -8,7 +8,6 @@ #include "ConnectionFromClient.h" #include #include -#include #include namespace LanguageServers { diff --git a/Userland/DevTools/HackStudio/Project.cpp b/Userland/DevTools/HackStudio/Project.cpp index f78472771d2..f15a33fc6c9 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::File::is_directory(root_path)) + if (!Core::DeprecatedFile::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 71089a49a49..8fc1c058122 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 @@ -125,15 +125,15 @@ ErrorOr ProjectBuilder::component_name(StringView cmake_file_p ErrorOr ProjectBuilder::initialize_build_directory() { - if (!Core::File::exists(build_directory())) { + if (!Core::DeprecatedFile::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::File::exists(cmake_file_path)) - MUST(Core::File::remove(cmake_file_path, Core::File::RecursionMode::Disallowed)); + if (Core::DeprecatedFile::exists(cmake_file_path)) + MUST(Core::DeprecatedFile::remove(cmake_file_path, Core::DeprecatedFile::RecursionMode::Disallowed)); auto cmake_file = TRY(Core::Stream::File::open(cmake_file_path, Core::Stream::OpenMode::Write)); TRY(cmake_file->write_entire_buffer(generate_cmake_file_content().bytes())); @@ -151,7 +151,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::File::exists(cmake_path.string())) + if (Core::DeprecatedFile::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 66c7f39a83a..3f4983ab2ee 100644 --- a/Userland/DevTools/HackStudio/ProjectTemplate.cpp +++ b/Userland/DevTools/HackStudio/ProjectTemplate.cpp @@ -9,8 +9,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -52,7 +52,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::File::exists(bitmap_path_32)) { + if (Core::DeprecatedFile::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,15 +64,15 @@ 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::File::exists(path)) + if (Core::DeprecatedFile::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::File::is_directory(content_path())) { - auto result = Core::File::copy_file_or_directory(path, content_path()); + if (Core::DeprecatedFile::is_directory(content_path())) { + auto result = Core::DeprecatedFile::copy_file_or_directory(path, content_path()); dbgln("Copying {} -> {}", content_path(), path); if (result.is_error()) return DeprecatedString::formatted("Failed to copy template contents. Error code: {}", static_cast(result.error())); diff --git a/Userland/DevTools/HackStudio/main.cpp b/Userland/DevTools/HackStudio/main.cpp index 089f43540a8..7025f00bd00 100644 --- a/Userland/DevTools/HackStudio/main.cpp +++ b/Userland/DevTools/HackStudio/main.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -60,9 +60,9 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_option(mode_coredump, "Debug a coredump in HackStudio", "coredump", 'c'); args_parser.parse(arguments); - auto argument_absolute_path = Core::File::real_path_for(path_argument); + auto argument_absolute_path = Core::DeprecatedFile::real_path_for(path_argument); - auto project_path = Core::File::real_path_for("."); + auto project_path = Core::DeprecatedFile::real_path_for("."); if (!mode_coredump) { if (!argument_absolute_path.is_null()) project_path = argument_absolute_path; @@ -143,7 +143,7 @@ static Optional last_opened_project_path() if (projects.size() == 0) return {}; - if (!Core::File::exists(projects[0])) + if (!Core::DeprecatedFile::exists(projects[0])) return {}; return { projects[0] }; diff --git a/Userland/DevTools/Profiler/Process.cpp b/Userland/DevTools/Profiler/Process.cpp index a2c592e783e..2fdcb376ea8 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::File::looks_like_shared_library(path_string)) + else if (Core::DeprecatedFile::looks_like_shared_library(path_string)) full_path = DeprecatedString::formatted("/usr/lib/{}", path); else full_path = path_string; diff --git a/Userland/DevTools/SQLStudio/MainWidget.cpp b/Userland/DevTools/SQLStudio/MainWidget.cpp index 43ef8d83a2b..09700fb2054 100644 --- a/Userland/DevTools/SQLStudio/MainWidget.cpp +++ b/Userland/DevTools/SQLStudio/MainWidget.cpp @@ -6,8 +6,8 @@ */ #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::File::exists(database_path)) + if (!Core::DeprecatedFile::exists(database_path)) return {}; Core::DirIterator iterator(move(database_path), Core::DirIterator::SkipParentAndBaseDir); diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.cpp b/Userland/DevTools/UserspaceEmulator/Emulator.cpp index 2034d456b2a..c4157b1ca43 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -424,7 +423,7 @@ MmapRegion const* Emulator::load_library_from_address(FlatPtr address) return {}; DeprecatedString lib_path = lib_name; - if (Core::File::looks_like_shared_library(lib_name)) + if (Core::DeprecatedFile::looks_like_shared_library(lib_name)) lib_path = DeprecatedString::formatted("/usr/lib/{}", lib_path); if (!m_dynamic_library_cache.contains(lib_path)) { @@ -462,7 +461,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::File::looks_like_shared_library(lib_name)) { + if (Core::DeprecatedFile::looks_like_shared_library(lib_name)) { lib_path = DeprecatedString::formatted("/usr/lib/{}", lib_name); } diff --git a/Userland/DevTools/UserspaceEmulator/main.cpp b/Userland/DevTools/UserspaceEmulator/main.cpp index 336cc192e0f..eda37b6d7e2 100644 --- a/Userland/DevTools/UserspaceEmulator/main.cpp +++ b/Userland/DevTools/UserspaceEmulator/main.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -46,9 +45,9 @@ int main(int argc, char** argv, char** env) DeprecatedString executable_path; if (arguments[0].contains("/"sv)) - executable_path = Core::File::real_path_for(arguments[0]); + executable_path = Core::DeprecatedFile::real_path_for(arguments[0]); else - executable_path = Core::File::resolve_executable_from_environment(arguments[0]).value_or({}); + executable_path = Core::DeprecatedFile::resolve_executable_from_environment(arguments[0]).value_or({}); if (executable_path.is_empty()) { reportln("Cannot find executable for '{}'."sv, arguments[0]); return 1; diff --git a/Userland/Games/Chess/Engine.cpp b/Userland/Games/Chess/Engine.cpp index e28c9b08ee8..a28b5fc13cd 100644 --- a/Userland/Games/Chess/Engine.cpp +++ b/Userland/Games/Chess/Engine.cpp @@ -5,7 +5,7 @@ */ #include "Engine.h" -#include +#include #include #include #include @@ -48,12 +48,12 @@ Engine::Engine(StringView command) close(wpipefds[0]); close(rpipefds[1]); - auto infile = Core::File::construct(); - infile->open(rpipefds[0], Core::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescriptor::Yes); + auto infile = Core::DeprecatedFile::construct(); + infile->open(rpipefds[0], Core::OpenMode::ReadOnly, Core::DeprecatedFile::ShouldCloseFileDescriptor::Yes); set_in(infile); - auto outfile = Core::File::construct(); - outfile->open(wpipefds[1], Core::OpenMode::WriteOnly, Core::File::ShouldCloseFileDescriptor::Yes); + auto outfile = Core::DeprecatedFile::construct(); + outfile->open(wpipefds[1], Core::OpenMode::WriteOnly, Core::DeprecatedFile::ShouldCloseFileDescriptor::Yes); set_out(outfile); send_command(Chess::UCI::UCICommand()); diff --git a/Userland/Libraries/LibAudio/WavLoader.h b/Userland/Libraries/LibAudio/WavLoader.h index 28be15af862..d43b1e91292 100644 --- a/Userland/Libraries/LibAudio/WavLoader.h +++ b/Userland/Libraries/LibAudio/WavLoader.h @@ -14,7 +14,6 @@ #include #include #include -#include #include namespace Audio { diff --git a/Userland/Libraries/LibAudio/WavWriter.cpp b/Userland/Libraries/LibAudio/WavWriter.cpp index 521a0a15f83..bbba9b15e86 100644 --- a/Userland/Libraries/LibAudio/WavWriter.cpp +++ b/Userland/Libraries/LibAudio/WavWriter.cpp @@ -5,6 +5,7 @@ */ #include +#include namespace Audio { @@ -31,7 +32,7 @@ WavWriter::~WavWriter() void WavWriter::set_file(StringView path) { - m_file = Core::File::construct(path); + m_file = Core::DeprecatedFile::construct(path); if (!m_file->open(Core::OpenMode::ReadWrite)) { m_error_string = DeprecatedString::formatted("Can't open file: {}", m_file->error_string()); return; diff --git a/Userland/Libraries/LibAudio/WavWriter.h b/Userland/Libraries/LibAudio/WavWriter.h index 7d6b31eeb5f..dbfbd5457ee 100644 --- a/Userland/Libraries/LibAudio/WavWriter.h +++ b/Userland/Libraries/LibAudio/WavWriter.h @@ -6,10 +6,13 @@ #pragma once +#include #include +#include #include #include -#include +#include +#include namespace Audio { @@ -31,7 +34,7 @@ public: u32 sample_rate() const { return m_sample_rate; } u16 num_channels() const { return m_num_channels; } u16 bits_per_sample() const { return m_bits_per_sample; } - RefPtr file() const { return m_file; } + RefPtr file() const { return m_file; } void set_file(StringView path); void set_num_channels(int num_channels) { m_num_channels = num_channels; } @@ -42,7 +45,7 @@ public: private: void write_header(); - RefPtr m_file; + RefPtr m_file; DeprecatedString m_error_string; bool m_finalized { false }; diff --git a/Userland/Libraries/LibC/unistd.cpp b/Userland/Libraries/LibC/unistd.cpp index 108b3a2be1a..8eb07571485 100644 --- a/Userland/Libraries/LibC/unistd.cpp +++ b/Userland/Libraries/LibC/unistd.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -188,7 +188,7 @@ int execvpe(char const* filename, char* const argv[], char* const envp[]) ScopedValueRollback errno_rollback(errno); - // TODO: Make this use the PATH search implementation from Core::File. + // TODO: Make this use the PATH search implementation from Core::DeprecatedFile. DeprecatedString path = getenv("PATH"); if (path.is_empty()) path = DEFAULT_PATH; diff --git a/Userland/Libraries/LibChess/UCIEndpoint.cpp b/Userland/Libraries/LibChess/UCIEndpoint.cpp index 286adaa4094..fad07d619e7 100644 --- a/Userland/Libraries/LibChess/UCIEndpoint.cpp +++ b/Userland/Libraries/LibChess/UCIEndpoint.cpp @@ -9,7 +9,6 @@ #include #include #include -#include namespace Chess::UCI { diff --git a/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp b/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp index 53d6bed7e93..5b6780da198 100644 --- a/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp +++ b/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp @@ -9,8 +9,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -736,7 +736,7 @@ Optional> CppComprehensionEng if (!path.starts_with(partial_basename)) continue; - if (Core::File::is_directory(LexicalPath::join(full_dir, path).string())) { + if (Core::DeprecatedFile::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/LibCodeComprehension/Cpp/Tests.cpp b/Userland/Libraries/LibCodeComprehension/Cpp/Tests.cpp index 3cd1e8dc38d..fbe9d92b177 100644 --- a/Userland/Libraries/LibCodeComprehension/Cpp/Tests.cpp +++ b/Userland/Libraries/LibCodeComprehension/Cpp/Tests.cpp @@ -8,7 +8,7 @@ #include "../FileDB.h" #include "CppComprehensionEngine.h" #include -#include +#include #include static bool s_some_test_failed = false; @@ -77,7 +77,7 @@ int run_tests() static void add_file(FileDB& filedb, DeprecatedString const& name) { - auto file = Core::File::open(LexicalPath::join(TESTS_ROOT_DIR, name).string(), Core::OpenMode::ReadOnly); + auto file = Core::DeprecatedFile::open(LexicalPath::join(TESTS_ROOT_DIR, name).string(), Core::OpenMode::ReadOnly); VERIFY(!file.is_error()); filedb.add(name, DeprecatedString::copy(file.value()->read_all())); } diff --git a/Userland/Libraries/LibConfig/Client.h b/Userland/Libraries/LibConfig/Client.h index 4394fe276ca..3c711fc97f6 100644 --- a/Userland/Libraries/LibConfig/Client.h +++ b/Userland/Libraries/LibConfig/Client.h @@ -8,7 +8,6 @@ #include #include -#include #include #include #include diff --git a/Userland/Libraries/LibCore/CMakeLists.txt b/Userland/Libraries/LibCore/CMakeLists.txt index 473812dae4d..7d32e1b1a15 100644 --- a/Userland/Libraries/LibCore/CMakeLists.txt +++ b/Userland/Libraries/LibCore/CMakeLists.txt @@ -4,12 +4,12 @@ set(SOURCES Command.cpp ConfigFile.cpp DateTime.cpp + DeprecatedFile.cpp Directory.cpp DirIterator.cpp ElapsedTimer.cpp Event.cpp EventLoop.cpp - File.cpp IODevice.cpp LockFile.cpp MappedFile.cpp diff --git a/Userland/Libraries/LibCore/Command.cpp b/Userland/Libraries/LibCore/Command.cpp index e3a318c680e..ee89735247b 100644 --- a/Userland/Libraries/LibCore/Command.cpp +++ b/Userland/Libraries/LibCore/Command.cpp @@ -7,7 +7,7 @@ #include "Command.h" #include #include -#include +#include #include #include #include @@ -73,8 +73,8 @@ ErrorOr command(DeprecatedString const& program, Vectoropen(pipe[0], Core::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescriptor::Yes)) { + auto result_file = Core::DeprecatedFile::construct(); + if (!result_file->open(pipe[0], Core::OpenMode::ReadOnly, Core::DeprecatedFile::ShouldCloseFileDescriptor::Yes)) { perror("open"); VERIFY_NOT_REACHED(); } diff --git a/Userland/Libraries/LibCore/File.cpp b/Userland/Libraries/LibCore/DeprecatedFile.cpp similarity index 80% rename from Userland/Libraries/LibCore/File.cpp rename to Userland/Libraries/LibCore/DeprecatedFile.cpp index 77a649fc333..7bf17fa971b 100644 --- a/Userland/Libraries/LibCore/File.cpp +++ b/Userland/Libraries/LibCore/DeprecatedFile.cpp @@ -7,8 +7,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -30,27 +30,27 @@ namespace Core { -ErrorOr> File::open(DeprecatedString filename, OpenMode mode, mode_t permissions) +ErrorOr> DeprecatedFile::open(DeprecatedString filename, OpenMode mode, mode_t permissions) { - auto file = File::construct(move(filename)); + auto file = DeprecatedFile::construct(move(filename)); if (!file->open_impl(mode, permissions)) return Error::from_errno(file->error()); return file; } -File::File(DeprecatedString filename, Object* parent) +DeprecatedFile::DeprecatedFile(DeprecatedString filename, Object* parent) : IODevice(parent) , m_filename(move(filename)) { } -File::~File() +DeprecatedFile::~DeprecatedFile() { if (m_should_close_file_descriptor == ShouldCloseFileDescriptor::Yes && mode() != OpenMode::NotOpen) close(); } -bool File::open(int fd, OpenMode mode, ShouldCloseFileDescriptor should_close) +bool DeprecatedFile::open(int fd, OpenMode mode, ShouldCloseFileDescriptor should_close) { set_fd(fd); set_mode(mode); @@ -58,12 +58,12 @@ bool File::open(int fd, OpenMode mode, ShouldCloseFileDescriptor should_close) return true; } -bool File::open(OpenMode mode) +bool DeprecatedFile::open(OpenMode mode) { return open_impl(mode, 0666); } -bool File::open_impl(OpenMode mode, mode_t permissions) +bool DeprecatedFile::open_impl(OpenMode mode, mode_t permissions) { VERIFY(!m_filename.is_null()); int flags = 0; @@ -96,18 +96,18 @@ bool File::open_impl(OpenMode mode, mode_t permissions) return true; } -int File::leak_fd() +int DeprecatedFile::leak_fd() { m_should_close_file_descriptor = ShouldCloseFileDescriptor::No; return fd(); } -bool File::is_device() const +bool DeprecatedFile::is_device() const { return is_device(fd()); } -bool File::is_device(DeprecatedString const& filename) +bool DeprecatedFile::is_device(DeprecatedString const& filename) { struct stat st; if (stat(filename.characters(), &st) < 0) @@ -115,7 +115,7 @@ bool File::is_device(DeprecatedString const& filename) return S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode); } -bool File::is_device(int fd) +bool DeprecatedFile::is_device(int fd) { struct stat st; if (fstat(fd, &st) < 0) @@ -123,7 +123,7 @@ bool File::is_device(int fd) return S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode); } -bool File::is_block_device() const +bool DeprecatedFile::is_block_device() const { struct stat stat; if (fstat(fd(), &stat) < 0) @@ -131,7 +131,7 @@ bool File::is_block_device() const return S_ISBLK(stat.st_mode); } -bool File::is_block_device(DeprecatedString const& filename) +bool DeprecatedFile::is_block_device(DeprecatedString const& filename) { struct stat st; if (stat(filename.characters(), &st) < 0) @@ -139,7 +139,7 @@ bool File::is_block_device(DeprecatedString const& filename) return S_ISBLK(st.st_mode); } -bool File::is_char_device() const +bool DeprecatedFile::is_char_device() const { struct stat stat; if (fstat(fd(), &stat) < 0) @@ -147,7 +147,7 @@ bool File::is_char_device() const return S_ISCHR(stat.st_mode); } -bool File::is_char_device(DeprecatedString const& filename) +bool DeprecatedFile::is_char_device(DeprecatedString const& filename) { struct stat st; if (stat(filename.characters(), &st) < 0) @@ -155,12 +155,12 @@ bool File::is_char_device(DeprecatedString const& filename) return S_ISCHR(st.st_mode); } -bool File::is_directory() const +bool DeprecatedFile::is_directory() const { return is_directory(fd()); } -bool File::is_directory(DeprecatedString const& filename) +bool DeprecatedFile::is_directory(DeprecatedString const& filename) { struct stat st; if (stat(filename.characters(), &st) < 0) @@ -168,7 +168,7 @@ bool File::is_directory(DeprecatedString const& filename) return S_ISDIR(st.st_mode); } -bool File::is_directory(int fd) +bool DeprecatedFile::is_directory(int fd) { struct stat st; if (fstat(fd, &st) < 0) @@ -176,7 +176,7 @@ bool File::is_directory(int fd) return S_ISDIR(st.st_mode); } -bool File::is_link() const +bool DeprecatedFile::is_link() const { struct stat stat; if (fstat(fd(), &stat) < 0) @@ -184,7 +184,7 @@ bool File::is_link() const return S_ISLNK(stat.st_mode); } -bool File::is_link(DeprecatedString const& filename) +bool DeprecatedFile::is_link(DeprecatedString const& filename) { struct stat st; if (lstat(filename.characters(), &st) < 0) @@ -192,17 +192,17 @@ bool File::is_link(DeprecatedString const& filename) return S_ISLNK(st.st_mode); } -bool File::looks_like_shared_library() const +bool DeprecatedFile::looks_like_shared_library() const { - return File::looks_like_shared_library(m_filename); + return DeprecatedFile::looks_like_shared_library(m_filename); } -bool File::looks_like_shared_library(DeprecatedString const& filename) +bool DeprecatedFile::looks_like_shared_library(DeprecatedString const& filename) { return filename.ends_with(".so"sv) || filename.contains(".so."sv); } -bool File::can_delete_or_move(StringView path) +bool DeprecatedFile::can_delete_or_move(StringView path) { VERIFY(!path.is_empty()); auto directory = LexicalPath::dirname(path); @@ -229,12 +229,12 @@ bool File::can_delete_or_move(StringView path) return user_id == 0 || directory_stat.st_uid == user_id || stat_or_empty(path).st_uid == user_id; } -bool File::exists(StringView filename) +bool DeprecatedFile::exists(StringView filename) { return !Core::System::stat(filename).is_error(); } -ErrorOr File::size(DeprecatedString const& filename) +ErrorOr DeprecatedFile::size(DeprecatedString const& filename) { struct stat st; if (stat(filename.characters(), &st) < 0) @@ -242,7 +242,7 @@ ErrorOr File::size(DeprecatedString const& filename) return st.st_size; } -DeprecatedString File::real_path_for(DeprecatedString const& filename) +DeprecatedString DeprecatedFile::real_path_for(DeprecatedString const& filename) { if (filename.is_null()) return {}; @@ -252,7 +252,7 @@ DeprecatedString File::real_path_for(DeprecatedString const& filename) return real_path; } -DeprecatedString File::current_working_directory() +DeprecatedString DeprecatedFile::current_working_directory() { char* cwd = getcwd(nullptr, 0); if (!cwd) { @@ -266,15 +266,15 @@ DeprecatedString File::current_working_directory() return cwd_as_string; } -DeprecatedString File::absolute_path(DeprecatedString const& path) +DeprecatedString DeprecatedFile::absolute_path(DeprecatedString const& path) { - if (File::exists(path)) - return File::real_path_for(path); + if (DeprecatedFile::exists(path)) + return DeprecatedFile::real_path_for(path); if (path.starts_with("/"sv)) return LexicalPath::canonicalized_path(path); - auto working_directory = File::current_working_directory(); + auto working_directory = DeprecatedFile::current_working_directory(); auto full_path = LexicalPath::join(working_directory, path); return LexicalPath::canonicalized_path(full_path.string()); @@ -282,7 +282,7 @@ DeprecatedString File::absolute_path(DeprecatedString const& path) #ifdef AK_OS_SERENITY -ErrorOr File::read_link(DeprecatedString const& link_path) +ErrorOr DeprecatedFile::read_link(DeprecatedString const& link_path) { // First, try using a 64-byte buffer, that ought to be enough for anybody. char small_buffer[64]; @@ -323,7 +323,7 @@ ErrorOr File::read_link(DeprecatedString const& link_path) // This is a sad version for other systems. It has to always make a copy of the // link path, and to always make two syscalls to get the right size first. -ErrorOr File::read_link(DeprecatedString const& link_path) +ErrorOr DeprecatedFile::read_link(DeprecatedString const& link_path) { struct stat statbuf = {}; int rc = lstat(link_path.characters(), &statbuf); @@ -341,32 +341,32 @@ ErrorOr File::read_link(DeprecatedString const& link_path) #endif -static RefPtr stdin_file; -static RefPtr stdout_file; -static RefPtr stderr_file; +static RefPtr stdin_file; +static RefPtr stdout_file; +static RefPtr stderr_file; -NonnullRefPtr File::standard_input() +NonnullRefPtr DeprecatedFile::standard_input() { if (!stdin_file) { - stdin_file = File::construct(); + stdin_file = DeprecatedFile::construct(); stdin_file->open(STDIN_FILENO, OpenMode::ReadOnly, ShouldCloseFileDescriptor::No); } return *stdin_file; } -NonnullRefPtr File::standard_output() +NonnullRefPtr DeprecatedFile::standard_output() { if (!stdout_file) { - stdout_file = File::construct(); + stdout_file = DeprecatedFile::construct(); stdout_file->open(STDOUT_FILENO, OpenMode::WriteOnly, ShouldCloseFileDescriptor::No); } return *stdout_file; } -NonnullRefPtr File::standard_error() +NonnullRefPtr DeprecatedFile::standard_error() { if (!stderr_file) { - stderr_file = File::construct(); + stderr_file = DeprecatedFile::construct(); stderr_file->open(STDERR_FILENO, OpenMode::WriteOnly, ShouldCloseFileDescriptor::No); } return *stderr_file; @@ -397,7 +397,7 @@ static DeprecatedString get_duplicate_name(DeprecatedString const& path, int dup return duplicated_name.to_deprecated_string(); } -ErrorOr File::copy_file_or_directory(DeprecatedString const& dst_path, DeprecatedString const& src_path, RecursionMode recursion_mode, LinkMode link_mode, AddDuplicateFileMarker add_duplicate_file_marker, PreserveMode preserve_mode) +ErrorOr DeprecatedFile::copy_file_or_directory(DeprecatedString const& dst_path, DeprecatedString const& src_path, RecursionMode recursion_mode, LinkMode link_mode, AddDuplicateFileMarker add_duplicate_file_marker, PreserveMode preserve_mode) { if (add_duplicate_file_marker == AddDuplicateFileMarker::Yes) { int duplicate_count = 0; @@ -409,7 +409,7 @@ ErrorOr File::copy_file_or_directory(DeprecatedString con } } - auto source_or_error = File::open(src_path, OpenMode::ReadOnly); + auto source_or_error = DeprecatedFile::open(src_path, OpenMode::ReadOnly); if (source_or_error.is_error()) return CopyError { errno, false }; @@ -435,7 +435,7 @@ ErrorOr File::copy_file_or_directory(DeprecatedString con return copy_file(dst_path, src_stat, source, preserve_mode); } -ErrorOr File::copy_file(DeprecatedString const& dst_path, struct stat const& src_stat, File& source, PreserveMode preserve_mode) +ErrorOr DeprecatedFile::copy_file(DeprecatedString const& dst_path, struct stat const& src_stat, DeprecatedFile& source, PreserveMode preserve_mode) { int dst_fd = creat(dst_path.characters(), 0666); if (dst_fd < 0) { @@ -507,14 +507,14 @@ ErrorOr File::copy_file(DeprecatedString const& dst_path, return {}; } -ErrorOr File::copy_directory(DeprecatedString const& dst_path, DeprecatedString const& src_path, struct stat const& src_stat, LinkMode link, PreserveMode preserve_mode) +ErrorOr DeprecatedFile::copy_directory(DeprecatedString const& dst_path, DeprecatedString const& src_path, struct stat const& src_stat, LinkMode link, PreserveMode preserve_mode) { if (mkdir(dst_path.characters(), 0755) < 0) return CopyError { errno, false }; - DeprecatedString src_rp = File::real_path_for(src_path); + DeprecatedString src_rp = DeprecatedFile::real_path_for(src_path); src_rp = DeprecatedString::formatted("{}/", src_rp); - DeprecatedString dst_rp = File::real_path_for(dst_path); + DeprecatedString dst_rp = DeprecatedFile::real_path_for(dst_path); dst_rp = DeprecatedString::formatted("{}/", dst_rp); if (!dst_rp.is_empty() && dst_rp.starts_with(src_rp)) @@ -562,7 +562,7 @@ ErrorOr File::copy_directory(DeprecatedString const& dst_ return {}; } -ErrorOr File::link_file(DeprecatedString const& dst_path, DeprecatedString const& src_path) +ErrorOr DeprecatedFile::link_file(DeprecatedString const& dst_path, DeprecatedString const& src_path) { int duplicate_count = 0; while (access(get_duplicate_name(dst_path, duplicate_count).characters(), F_OK) == 0) { @@ -576,7 +576,7 @@ ErrorOr File::link_file(DeprecatedString const& dst_path, DeprecatedString return {}; } -ErrorOr File::remove(StringView path, RecursionMode mode) +ErrorOr DeprecatedFile::remove(StringView path, RecursionMode mode) { auto path_stat = TRY(Core::System::lstat(path)); @@ -597,7 +597,7 @@ ErrorOr File::remove(StringView path, RecursionMode mode) return {}; } -Optional File::resolve_executable_from_environment(StringView filename) +Optional DeprecatedFile::resolve_executable_from_environment(StringView filename) { if (filename.is_empty()) return {}; diff --git a/Userland/Libraries/LibCore/File.h b/Userland/Libraries/LibCore/DeprecatedFile.h similarity index 84% rename from Userland/Libraries/LibCore/File.h rename to Userland/Libraries/LibCore/DeprecatedFile.h index 4dbeaa1414f..7f9c1b70829 100644 --- a/Userland/Libraries/LibCore/File.h +++ b/Userland/Libraries/LibCore/DeprecatedFile.h @@ -21,12 +21,12 @@ namespace Core { /// Use of Core::File for reading/writing data is deprecated. /// Please use Core::Stream::File and Core::Stream::BufferedFile instead. /// -class File final : public IODevice { - C_OBJECT(File) +class DeprecatedFile final : public IODevice { + C_OBJECT(DeprecatedFile) public: - virtual ~File() override; + virtual ~DeprecatedFile() override; - static ErrorOr> open(DeprecatedString filename, OpenMode, mode_t = 0644); + static ErrorOr> open(DeprecatedString filename, OpenMode, mode_t = 0644); DeprecatedString filename() const { return m_filename; } void set_filename(const DeprecatedString filename) { m_filename = move(filename); } @@ -86,7 +86,7 @@ public: bool tried_recursing; }; - static ErrorOr copy_file(DeprecatedString const& dst_path, struct stat const& src_stat, File& source, PreserveMode = PreserveMode::Nothing); + static ErrorOr copy_file(DeprecatedString const& dst_path, struct stat const& src_stat, DeprecatedFile& source, PreserveMode = PreserveMode::Nothing); static ErrorOr copy_directory(DeprecatedString const& dst_path, DeprecatedString const& src_path, struct stat const& src_stat, LinkMode = LinkMode::Disallowed, PreserveMode = PreserveMode::Nothing); static ErrorOr copy_file_or_directory(DeprecatedString const& dst_path, DeprecatedString const& src_path, RecursionMode = RecursionMode::Allowed, LinkMode = LinkMode::Disallowed, AddDuplicateFileMarker = AddDuplicateFileMarker::Yes, PreserveMode = PreserveMode::Nothing); @@ -105,18 +105,18 @@ public: bool open(int fd, OpenMode, ShouldCloseFileDescriptor); [[nodiscard]] int leak_fd(); - static NonnullRefPtr standard_input(); - static NonnullRefPtr standard_output(); - static NonnullRefPtr standard_error(); + static NonnullRefPtr standard_input(); + static NonnullRefPtr standard_output(); + static NonnullRefPtr standard_error(); static Optional resolve_executable_from_environment(StringView filename); private: - File(Object* parent = nullptr) + DeprecatedFile(Object* parent = nullptr) : IODevice(parent) { } - explicit File(DeprecatedString filename, Object* parent = nullptr); + explicit DeprecatedFile(DeprecatedString filename, Object* parent = nullptr); bool open_impl(OpenMode, mode_t); @@ -124,6 +124,6 @@ private: ShouldCloseFileDescriptor m_should_close_file_descriptor { ShouldCloseFileDescriptor::Yes }; }; -AK_ENUM_BITWISE_OPERATORS(File::PreserveMode); +AK_ENUM_BITWISE_OPERATORS(DeprecatedFile::PreserveMode); } diff --git a/Userland/Libraries/LibCore/Forward.h b/Userland/Libraries/LibCore/Forward.h index 15e45cc4055..db977053127 100644 --- a/Userland/Libraries/LibCore/Forward.h +++ b/Userland/Libraries/LibCore/Forward.h @@ -14,12 +14,12 @@ class ChildEvent; class ConfigFile; class CustomEvent; class DateTime; +class DeprecatedFile; class DirIterator; class DeferredInvocationContext; class ElapsedTimer; class Event; class EventLoop; -class File; class IODevice; class LocalServer; class MimeData; diff --git a/Userland/Libraries/LibCore/Group.cpp b/Userland/Libraries/LibCore/Group.cpp index 0f07a0b5eed..bf99278b1b8 100644 --- a/Userland/Libraries/LibCore/Group.cpp +++ b/Userland/Libraries/LibCore/Group.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Libraries/LibCore/Stream.cpp b/Userland/Libraries/LibCore/Stream.cpp index 796b50f0720..821d15436a4 100644 --- a/Userland/Libraries/LibCore/Stream.cpp +++ b/Userland/Libraries/LibCore/Stream.cpp @@ -36,7 +36,7 @@ ErrorOr> File::adopt_fd(int fd, OpenMode mode, ShouldCloseFi } if (!has_any_flag(mode, OpenMode::ReadWrite)) { - dbgln("Core::File::adopt_fd: Attempting to adopt a file with neither Read nor Write specified in mode"); + dbgln("Core::DeprecatedFile::adopt_fd: Attempting to adopt a file with neither Read nor Write specified in mode"); return Error::from_errno(EINVAL); } diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index 941c21987e4..0c36c839386 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -1156,7 +1156,7 @@ ErrorOr exec(StringView filename, ReadonlySpan arguments, Sear DeprecatedString exec_filename; if (search_in_path == SearchInPath::Yes) { - auto maybe_executable = Core::File::resolve_executable_from_environment(filename); + auto maybe_executable = Core::DeprecatedFile::resolve_executable_from_environment(filename); if (!maybe_executable.has_value()) return ENOENT; @@ -1195,7 +1195,7 @@ ErrorOr exec(StringView filename, ReadonlySpan arguments, Sear // These BSDs don't support execvpe(), so we'll have to manually search the PATH. ScopedValueRollback errno_rollback(errno); - auto maybe_executable = Core::File::resolve_executable_from_environment(filename_string); + auto maybe_executable = Core::DeprecatedFile::resolve_executable_from_environment(filename_string); if (!maybe_executable.has_value()) { errno_rollback.set_override_rollback_value(ENOENT); diff --git a/Userland/Libraries/LibCore/TempFile.cpp b/Userland/Libraries/LibCore/TempFile.cpp index e13f5ccec63..527ad911e41 100644 --- a/Userland/Libraries/LibCore/TempFile.cpp +++ b/Userland/Libraries/LibCore/TempFile.cpp @@ -6,7 +6,7 @@ #include "TempFile.h" #include -#include +#include #include #include #include @@ -45,11 +45,11 @@ TempFile::TempFile(Type type) TempFile::~TempFile() { - File::RecursionMode recursion_allowed { File::RecursionMode::Disallowed }; + DeprecatedFile::RecursionMode recursion_allowed { DeprecatedFile::RecursionMode::Disallowed }; if (m_type == Type::Directory) - recursion_allowed = File::RecursionMode::Allowed; + recursion_allowed = DeprecatedFile::RecursionMode::Allowed; - auto rc = File::remove(m_path, recursion_allowed); + auto rc = DeprecatedFile::remove(m_path, recursion_allowed); if (rc.is_error()) { warnln("File::remove failed: {}", rc.error().string_literal()); } diff --git a/Userland/Libraries/LibCoredump/Backtrace.cpp b/Userland/Libraries/LibCoredump/Backtrace.cpp index 54fdfbd2213..94ae94859b6 100644 --- a/Userland/Libraries/LibCoredump/Backtrace.cpp +++ b/Userland/Libraries/LibCoredump/Backtrace.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -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::File::exists(path)) + if (!Core::DeprecatedFile::exists(path)) return nullptr; auto file_or_error = Core::MappedFile::map(path); diff --git a/Userland/Libraries/LibCoredump/Reader.cpp b/Userland/Libraries/LibCoredump/Reader.cpp index 5f84958909d..dbbdc2285d9 100644 --- a/Userland/Libraries/LibCoredump/Reader.cpp +++ b/Userland/Libraries/LibCoredump/Reader.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -297,7 +297,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::File::looks_like_shared_library(name)) { + if (name.starts_with('/') || !Core::DeprecatedFile::looks_like_shared_library(name)) { return name; } diff --git a/Userland/Libraries/LibCpp/Tests/parser/strace.ast b/Userland/Libraries/LibCpp/Tests/parser/strace.ast index 7eb2d0d36d1..91c7265c86c 100644 --- a/Userland/Libraries/LibCpp/Tests/parser/strace.ast +++ b/Userland/Libraries/LibCpp/Tests/parser/strace.ast @@ -108,13 +108,13 @@ TranslationUnit[0:0->144:0] [const] char output_filename NullPointerLiteral[21:34->21:40] - VariableDeclaration[22:4->22:50] + VariableDeclaration[22:4->22:60] NamedType[22:4->22:7] auto trace_file - FunctionCall[22:22->22:50] - Name[22:22->22:47] - Core::File::standard_error + FunctionCall[22:22->22:60] + Name[22:22->22:57] + Core::DeprecatedFile::standard_error VariableDeclaration[24:4->24:27] NamedType[24:4->24:19] Core::ArgsParser @@ -192,16 +192,16 @@ TranslationUnit[0:0->144:0] NullPointerLiteral[33:27->33:33] Then: BlockStatement[33:36->42:4] - VariableDeclaration[34:8->34:87] + VariableDeclaration[34:8->34:97] NamedType[34:8->34:11] auto open_result - FunctionCall[34:27->34:87] - Name[34:27->34:42] - Core::File::open - Name[34:44->34:58] + FunctionCall[34:27->34:97] + Name[34:27->34:52] + Core::DeprecatedFile::open + Name[34:54->34:68] output_filename - Name[34:61->34:85] + Name[34:71->34:95] Core::OpenMode::WriteOnly IfStatement[35:8->39:8] Predicate: diff --git a/Userland/Libraries/LibCpp/Tests/parser/strace.cpp b/Userland/Libraries/LibCpp/Tests/parser/strace.cpp index 9844198f63c..b7f1c2d6d1c 100644 --- a/Userland/Libraries/LibCpp/Tests/parser/strace.cpp +++ b/Userland/Libraries/LibCpp/Tests/parser/strace.cpp @@ -20,7 +20,7 @@ int main(int argc, char** argv) Vector child_argv; const char* output_filename = nullptr; - auto trace_file = Core::File::standard_error(); + auto trace_file = Core::DeprecatedFile::standard_error(); Core::ArgsParser parser; parser.set_general_help( @@ -32,7 +32,7 @@ int main(int argc, char** argv) parser.parse(argc, argv); if (output_filename != nullptr) { - auto open_result = Core::File::open(output_filename, Core::OpenMode::WriteOnly); + auto open_result = Core::DeprecatedFile::open(output_filename, Core::OpenMode::WriteOnly); if (open_result.is_error()) { outln(stderr, "Failed to open output file: {}", open_result.error()); return 1; diff --git a/Userland/Libraries/LibDebug/DebugSession.cpp b/Userland/Libraries/LibDebug/DebugSession.cpp index 6566da1b783..b135814118c 100644 --- a/Userland/Libraries/LibDebug/DebugSession.cpp +++ b/Userland/Libraries/LibDebug/DebugSession.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -444,7 +444,7 @@ Optional DebugSession::ins void DebugSession::update_loaded_libs() { - auto file = Core::File::construct(DeprecatedString::formatted("/proc/{}/vm", m_debuggee_pid)); + auto file = Core::DeprecatedFile::construct(DeprecatedString::formatted("/proc/{}/vm", m_debuggee_pid)); bool rc = file->open(Core::OpenMode::ReadOnly); VERIFY(rc); @@ -476,7 +476,7 @@ void DebugSession::update_loaded_libs() return IterationDecision::Continue; DeprecatedString lib_name = object_path.value(); - if (Core::File::looks_like_shared_library(lib_name)) + if (Core::DeprecatedFile::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/Client.cpp b/Userland/Libraries/LibFileSystemAccessClient/Client.cpp index 8ddfd71c506..ea57978b0b6 100644 --- a/Userland/Libraries/LibFileSystemAccessClient/Client.cpp +++ b/Userland/Libraries/LibFileSystemAccessClient/Client.cpp @@ -6,7 +6,6 @@ */ #include -#include #include #include #include @@ -41,7 +40,7 @@ DeprecatedResult Client::try_request_file_read_only_approved_deprecated(GUI::Win if (path.starts_with('/')) { async_request_file_read_only_approved(id, parent_window_server_client_id, parent_window_id, path); } else { - auto full_path = LexicalPath::join(Core::File::current_working_directory(), path).string(); + auto full_path = LexicalPath::join(Core::DeprecatedFile::current_working_directory(), path).string(); async_request_file_read_only_approved(id, parent_window_server_client_id, parent_window_id, full_path); } @@ -66,7 +65,7 @@ Result Client::request_file_read_only_approved(GUI::Window* parent_window, Depre if (path.starts_with('/')) { async_request_file_read_only_approved(id, parent_window_server_client_id, parent_window_id, path); } else { - auto full_path = LexicalPath::join(Core::File::current_working_directory(), path).string(); + auto full_path = LexicalPath::join(Core::DeprecatedFile::current_working_directory(), path).string(); async_request_file_read_only_approved(id, parent_window_server_client_id, parent_window_id, full_path); } @@ -114,7 +113,7 @@ DeprecatedResult Client::try_request_file_deprecated(GUI::Window* parent_window, if (path.starts_with('/')) { async_request_file(id, parent_window_server_client_id, parent_window_id, path, mode); } else { - auto full_path = LexicalPath::join(Core::File::current_working_directory(), path).string(); + auto full_path = LexicalPath::join(Core::DeprecatedFile::current_working_directory(), path).string(); async_request_file(id, parent_window_server_client_id, parent_window_id, full_path, mode); } @@ -139,7 +138,7 @@ Result Client::request_file(GUI::Window* parent_window, DeprecatedString const& if (path.starts_with('/')) { async_request_file(id, parent_window_server_client_id, parent_window_id, path, mode); } else { - auto full_path = LexicalPath::join(Core::File::current_working_directory(), path).string(); + auto full_path = LexicalPath::join(Core::DeprecatedFile::current_working_directory(), path).string(); async_request_file(id, parent_window_server_client_id, parent_window_id, full_path, mode); } @@ -253,22 +252,22 @@ void Client::handle_prompt_end(i32 request_id, i32 error, Optional co return; } - if (Core::File::is_device(ipc_file->fd())) { + if (Core::DeprecatedFile::is_device(ipc_file->fd())) { GUI::MessageBox::show_error(request_data.parent_window, DeprecatedString::formatted("Opening \"{}\" failed: Cannot open device files", *chosen_file)); resolve_any_promise(Error::from_string_literal("Cannot open device files")); return; } - if (Core::File::is_directory(ipc_file->fd())) { + if (Core::DeprecatedFile::is_directory(ipc_file->fd())) { GUI::MessageBox::show_error(request_data.parent_window, DeprecatedString::formatted("Opening \"{}\" failed: Cannot open directory", *chosen_file)); resolve_any_promise(Error::from_errno(EISDIR)); return; } if (request_data.promise.has>()) { - auto file = Core::File::construct(); + auto file = Core::DeprecatedFile::construct(); auto fd = ipc_file->take_fd(); - file->open(fd, Core::OpenMode::ReadWrite, Core::File::ShouldCloseFileDescriptor::Yes); + file->open(fd, Core::OpenMode::ReadWrite, Core::DeprecatedFile::ShouldCloseFileDescriptor::Yes); file->set_filename(*chosen_file); request_data.promise.get>()->resolve(file); diff --git a/Userland/Libraries/LibFileSystemAccessClient/Client.h b/Userland/Libraries/LibFileSystemAccessClient/Client.h index 32236bc0f09..a1ca4209aed 100644 --- a/Userland/Libraries/LibFileSystemAccessClient/Client.h +++ b/Userland/Libraries/LibFileSystemAccessClient/Client.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -37,7 +37,7 @@ private: String m_filename; }; -using DeprecatedResult = ErrorOr>; +using DeprecatedResult = ErrorOr>; using Result = ErrorOr; class Client final diff --git a/Userland/Libraries/LibGUI/AbstractThemePreview.cpp b/Userland/Libraries/LibGUI/AbstractThemePreview.cpp index 658c9e15eaa..df70abeb012 100644 --- a/Userland/Libraries/LibGUI/AbstractThemePreview.cpp +++ b/Userland/Libraries/LibGUI/AbstractThemePreview.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp b/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp index 75b187615ca..9beebbf0056 100644 --- a/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp +++ b/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp @@ -8,7 +8,7 @@ #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::File::exists(user_config)) { + if (Core::DeprecatedFile::exists(user_config)) { auto maybe_error = CommonLocationsProvider::load_from_json(user_config); if (!maybe_error.is_error()) return; diff --git a/Userland/Libraries/LibGUI/FileIconProvider.cpp b/Userland/Libraries/LibGUI/FileIconProvider.cpp index 31797d73888..74a331b1035 100644 --- a/Userland/Libraries/LibGUI/FileIconProvider.cpp +++ b/Userland/Libraries/LibGUI/FileIconProvider.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -255,7 +255,7 @@ Icon FileIconProvider::icon_for_path(DeprecatedString const& path, mode_t mode) return s_directory_icon; } if (S_ISLNK(mode)) { - auto raw_symlink_target_or_error = Core::File::read_link(path); + auto raw_symlink_target_or_error = Core::DeprecatedFile::read_link(path); if (raw_symlink_target_or_error.is_error()) return s_symlink_icon; @@ -267,7 +267,7 @@ Icon FileIconProvider::icon_for_path(DeprecatedString const& path, mode_t mode) if (raw_symlink_target.starts_with('/')) { target_path = raw_symlink_target; } else { - target_path = Core::File::real_path_for(DeprecatedString::formatted("{}/{}", LexicalPath::dirname(path), raw_symlink_target)); + target_path = Core::DeprecatedFile::real_path_for(DeprecatedString::formatted("{}/{}", LexicalPath::dirname(path), raw_symlink_target)); } auto target_icon = icon_for_path(target_path); diff --git a/Userland/Libraries/LibGUI/FilePicker.cpp b/Userland/Libraries/LibGUI/FilePicker.cpp index 97fb785394d..b5db27f7da4 100644 --- a/Userland/Libraries/LibGUI/FilePicker.cpp +++ b/Userland/Libraries/LibGUI/FilePicker.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include @@ -310,7 +310,7 @@ void FilePicker::on_file_return() path = LexicalPath::join(m_model->root_path(), path).string(); } - bool file_exists = Core::File::exists(path); + bool file_exists = Core::DeprecatedFile::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/FileSystemModel.cpp b/Userland/Libraries/LibGUI/FileSystemModel.cpp index 545b4fda7c8..287e12a5818 100644 --- a/Userland/Libraries/LibGUI/FileSystemModel.cpp +++ b/Userland/Libraries/LibGUI/FileSystemModel.cpp @@ -10,8 +10,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -61,7 +61,7 @@ bool FileSystemModel::Node::fetch_data(DeprecatedString const& full_path, bool i mtime = st.st_mtime; if (S_ISLNK(mode)) { - auto sym_link_target_or_error = Core::File::read_link(full_path); + auto sym_link_target_or_error = Core::DeprecatedFile::read_link(full_path); if (sym_link_target_or_error.is_error()) perror("readlink"); else { diff --git a/Userland/Libraries/LibGUI/JsonArrayModel.cpp b/Userland/Libraries/LibGUI/JsonArrayModel.cpp index cedb394b997..f92cb9e84ac 100644 --- a/Userland/Libraries/LibGUI/JsonArrayModel.cpp +++ b/Userland/Libraries/LibGUI/JsonArrayModel.cpp @@ -5,14 +5,14 @@ */ #include -#include +#include #include namespace GUI { void JsonArrayModel::invalidate() { - auto file = Core::File::construct(m_json_path); + auto file = Core::DeprecatedFile::construct(m_json_path); if (!file->open(Core::OpenMode::ReadOnly)) { dbgln("Unable to open {}", file->filename()); m_array.clear(); @@ -30,7 +30,7 @@ void JsonArrayModel::invalidate() void JsonArrayModel::update() { - auto file = Core::File::construct(m_json_path); + auto file = Core::DeprecatedFile::construct(m_json_path); if (!file->open(Core::OpenMode::ReadOnly)) { dbgln("Unable to open {}", file->filename()); m_array.clear(); @@ -48,7 +48,7 @@ void JsonArrayModel::update() bool JsonArrayModel::store() { - auto file = Core::File::construct(m_json_path); + auto file = Core::DeprecatedFile::construct(m_json_path); if (!file->open(Core::OpenMode::WriteOnly)) { dbgln("Unable to open {}", file->filename()); return false; diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index 2f23fdad78a..622a8902eea 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Userland/Libraries/LibGfx/Font/FontDatabase.cpp b/Userland/Libraries/LibGfx/Font/FontDatabase.cpp index 746d02f830e..4088f97596d 100644 --- a/Userland/Libraries/LibGfx/Font/FontDatabase.cpp +++ b/Userland/Libraries/LibGfx/Font/FontDatabase.cpp @@ -8,8 +8,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -136,7 +136,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::File::is_directory(path)) { + if (Core::DeprecatedFile::is_directory(path)) { path_queue.enqueue(path); continue; } diff --git a/Userland/Libraries/LibIDL/IDLParser.cpp b/Userland/Libraries/LibIDL/IDLParser.cpp index 3fac6549e7b..2fe98cdd211 100644 --- a/Userland/Libraries/LibIDL/IDLParser.cpp +++ b/Userland/Libraries/LibIDL/IDLParser.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include [[noreturn]] static void report_parsing_error(StringView message, StringView filename, StringView input, size_t offset) @@ -138,10 +138,10 @@ static HashTable import_stack; Optional Parser::resolve_import(auto path) { auto include_path = LexicalPath::join(import_base_path, path).string(); - if (!Core::File::exists(include_path)) + if (!Core::DeprecatedFile::exists(include_path)) report_parsing_error(DeprecatedString::formatted("{}: No such file or directory", include_path), filename, input, lexer.tell()); - auto real_path = Core::File::real_path_for(include_path); + auto real_path = Core::DeprecatedFile::real_path_for(include_path); if (top_level_resolved_imports().contains(real_path)) return *top_level_resolved_imports().find(real_path)->value; @@ -884,7 +884,7 @@ void resolve_function_typedefs(Interface& interface, FunctionType& function) Interface& Parser::parse() { - auto this_module = Core::File::real_path_for(filename); + auto this_module = Core::DeprecatedFile::real_path_for(filename); auto interface_ptr = make(); auto& interface = *interface_ptr; diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp index d1001a86e98..f4b7e62458e 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.cpp +++ b/Userland/Libraries/LibJS/Runtime/VM.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -833,18 +833,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::File::exists(filename)) { + if (!Core::DeprecatedFile::exists(filename)) { for (auto extension : extensions) { // import "./foo" -> import "./foo.ext" auto resolved_filepath = DeprecatedString::formatted("{}.{}", filename, extension); - if (Core::File::exists(resolved_filepath)) + if (Core::DeprecatedFile::exists(resolved_filepath)) return resolved_filepath; } - } else if (Core::File::is_directory(filename)) { + } else if (Core::DeprecatedFile::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::File::exists(resolved_filepath)) + if (Core::DeprecatedFile::exists(resolved_filepath)) return resolved_filepath; } } @@ -916,7 +916,7 @@ ThrowCompletionOr> VM::resolve_imported_module(ScriptOrModu dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] reading and parsing module {}", filename); - auto file_or_error = Core::File::open(filename, Core::OpenMode::ReadOnly); + auto file_or_error = Core::DeprecatedFile::open(filename, Core::OpenMode::ReadOnly); if (file_or_error.is_error()) { return throw_completion(ErrorType::ModuleNotFound, module_request.module_specifier); diff --git a/Userland/Libraries/LibKeyboard/CharacterMapFile.cpp b/Userland/Libraries/LibKeyboard/CharacterMapFile.cpp index 7b3cae78212..38e5904549c 100644 --- a/Userland/Libraries/LibKeyboard/CharacterMapFile.cpp +++ b/Userland/Libraries/LibKeyboard/CharacterMapFile.cpp @@ -7,7 +7,7 @@ #include "CharacterMapFile.h" #include #include -#include +#include namespace Keyboard { @@ -22,7 +22,7 @@ ErrorOr CharacterMapFile::load_from_file(DeprecatedString cons path = full_path.to_deprecated_string(); } - auto file = TRY(Core::File::open(path, Core::OpenMode::ReadOnly)); + auto file = TRY(Core::DeprecatedFile::open(path, Core::OpenMode::ReadOnly)); auto file_contents = file->read_all(); auto json_result = TRY(JsonValue::from_string(file_contents)); auto const& json = json_result.as_object(); diff --git a/Userland/Libraries/LibLine/Editor.cpp b/Userland/Libraries/LibLine/Editor.cpp index fc6dc6d358f..ad165c79c36 100644 --- a/Userland/Libraries/LibLine/Editor.cpp +++ b/Userland/Libraries/LibLine/Editor.cpp @@ -18,9 +18,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -251,7 +251,7 @@ void Editor::add_to_history(DeprecatedString const& line) bool Editor::load_history(DeprecatedString const& path) { - auto history_file = Core::File::construct(path); + auto history_file = Core::DeprecatedFile::construct(path); if (!history_file->open(Core::OpenMode::ReadOnly)) return false; auto data = history_file->read_all(); @@ -311,7 +311,7 @@ bool Editor::save_history(DeprecatedString const& path) { Vector final_history { { "", 0 } }; { - auto file_or_error = Core::File::open(path, Core::OpenMode::ReadWrite, 0600); + auto file_or_error = Core::DeprecatedFile::open(path, Core::OpenMode::ReadWrite, 0600); if (file_or_error.is_error()) return false; auto file = file_or_error.release_value(); @@ -326,7 +326,7 @@ bool Editor::save_history(DeprecatedString const& path) [](HistoryEntry const& left, HistoryEntry const& right) { return left.timestamp < right.timestamp; }); } - auto file_or_error = Core::File::open(path, Core::OpenMode::WriteOnly, 0600); + auto file_or_error = Core::DeprecatedFile::open(path, Core::OpenMode::WriteOnly, 0600); if (file_or_error.is_error()) return false; auto file = file_or_error.release_value(); diff --git a/Userland/Libraries/LibManual/Node.cpp b/Userland/Libraries/LibManual/Node.cpp index 57b596aeb29..044b4143b73 100644 --- a/Userland/Libraries/LibManual/Node.cpp +++ b/Userland/Libraries/LibManual/Node.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include @@ -49,7 +49,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::File::exists(TRY(page->path()))) { + if (Core::DeprecatedFile::exists(TRY(page->path()))) { maybe_page = page; break; } @@ -62,7 +62,7 @@ ErrorOr> Node::try_create_from_query(Vector(section, TRY(String::from_utf8(second_query_parameter)))); - if (Core::File::exists(TRY(page->path()))) + if (Core::DeprecatedFile::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 1dc0e447ffd..a4077a134d0 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::File::is_directory(LexicalPath::absolute_path(own_path.to_deprecated_string(), lexical_path.string()))) { + if (Core::DeprecatedFile::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/LibPartition/EBRPartitionTable.cpp b/Userland/Libraries/LibPartition/EBRPartitionTable.cpp index 74d873b51b8..a2c039f7966 100644 --- a/Userland/Libraries/LibPartition/EBRPartitionTable.cpp +++ b/Userland/Libraries/LibPartition/EBRPartitionTable.cpp @@ -6,6 +6,10 @@ #include +#ifndef KERNEL +# include +#endif + namespace Partition { #ifdef KERNEL @@ -13,7 +17,7 @@ ErrorOr> EBRPartitionTable::try_to_initialize(K { auto table = TRY(adopt_nonnull_own_or_enomem(new (nothrow) EBRPartitionTable(device))); #else -ErrorOr> EBRPartitionTable::try_to_initialize(NonnullRefPtr device_file) +ErrorOr> EBRPartitionTable::try_to_initialize(NonnullRefPtr device_file) { auto table = TRY(adopt_nonnull_own_or_enomem(new (nothrow) EBRPartitionTable(move(device_file)))); #endif @@ -27,7 +31,7 @@ ErrorOr> EBRPartitionTable::try_to_initialize(N #ifdef KERNEL void EBRPartitionTable::search_extended_partition(Kernel::StorageDevice const& device, MBRPartitionTable& checked_ebr, u64 current_block_offset, size_t limit) #else -void EBRPartitionTable::search_extended_partition(NonnullRefPtr device, MBRPartitionTable& checked_ebr, u64 current_block_offset, size_t limit) +void EBRPartitionTable::search_extended_partition(NonnullRefPtr device, MBRPartitionTable& checked_ebr, u64 current_block_offset, size_t limit) #endif { if (limit == 0) @@ -51,7 +55,7 @@ void EBRPartitionTable::search_extended_partition(NonnullRefPtr devi #ifdef KERNEL EBRPartitionTable::EBRPartitionTable(Kernel::StorageDevice const& device) #else -EBRPartitionTable::EBRPartitionTable(NonnullRefPtr device) +EBRPartitionTable::EBRPartitionTable(NonnullRefPtr device) #endif : MBRPartitionTable(device) { diff --git a/Userland/Libraries/LibPartition/EBRPartitionTable.h b/Userland/Libraries/LibPartition/EBRPartitionTable.h index 0e381293a3c..36598b054a5 100644 --- a/Userland/Libraries/LibPartition/EBRPartitionTable.h +++ b/Userland/Libraries/LibPartition/EBRPartitionTable.h @@ -19,8 +19,8 @@ public: static ErrorOr> try_to_initialize(Kernel::StorageDevice const&); explicit EBRPartitionTable(Kernel::StorageDevice const&); #else - static ErrorOr> try_to_initialize(NonnullRefPtr); - explicit EBRPartitionTable(NonnullRefPtr); + static ErrorOr> try_to_initialize(NonnullRefPtr); + explicit EBRPartitionTable(NonnullRefPtr); #endif virtual bool is_valid() const override @@ -32,7 +32,7 @@ private: #ifdef KERNEL void search_extended_partition(Kernel::StorageDevice const&, MBRPartitionTable&, u64, size_t limit); #else - void search_extended_partition(NonnullRefPtr, MBRPartitionTable&, u64, size_t limit); + void search_extended_partition(NonnullRefPtr, MBRPartitionTable&, u64, size_t limit); #endif bool m_valid { false }; diff --git a/Userland/Libraries/LibPartition/GUIDPartitionTable.cpp b/Userland/Libraries/LibPartition/GUIDPartitionTable.cpp index fb2c261b321..284771b7a2e 100644 --- a/Userland/Libraries/LibPartition/GUIDPartitionTable.cpp +++ b/Userland/Libraries/LibPartition/GUIDPartitionTable.cpp @@ -7,6 +7,10 @@ #include #include +#ifndef KERNEL +# include +#endif + namespace Partition { #define GPT_SIGNATURE2 0x54524150 @@ -49,7 +53,7 @@ ErrorOr> GUIDPartitionTable::try_to_initialize { auto table = TRY(adopt_nonnull_own_or_enomem(new (nothrow) GUIDPartitionTable(device))); #else -ErrorOr> GUIDPartitionTable::try_to_initialize(NonnullRefPtr device_file) +ErrorOr> GUIDPartitionTable::try_to_initialize(NonnullRefPtr device_file) { auto table = TRY(adopt_nonnull_own_or_enomem(new (nothrow) GUIDPartitionTable(move(device_file)))); #endif @@ -62,7 +66,7 @@ ErrorOr> GUIDPartitionTable::try_to_initialize GUIDPartitionTable::GUIDPartitionTable(Kernel::StorageDevice const& device) : MBRPartitionTable(device) #else -GUIDPartitionTable::GUIDPartitionTable(NonnullRefPtr device_file) +GUIDPartitionTable::GUIDPartitionTable(NonnullRefPtr device_file) : MBRPartitionTable(move(device_file)) #endif { diff --git a/Userland/Libraries/LibPartition/GUIDPartitionTable.h b/Userland/Libraries/LibPartition/GUIDPartitionTable.h index c36110e480c..f8e21dcd01e 100644 --- a/Userland/Libraries/LibPartition/GUIDPartitionTable.h +++ b/Userland/Libraries/LibPartition/GUIDPartitionTable.h @@ -19,8 +19,8 @@ public: static ErrorOr> try_to_initialize(Kernel::StorageDevice const&); explicit GUIDPartitionTable(Kernel::StorageDevice const&); #else - static ErrorOr> try_to_initialize(NonnullRefPtr); - explicit GUIDPartitionTable(NonnullRefPtr); + static ErrorOr> try_to_initialize(NonnullRefPtr); + explicit GUIDPartitionTable(NonnullRefPtr); #endif virtual bool is_valid() const override diff --git a/Userland/Libraries/LibPartition/MBRPartitionTable.cpp b/Userland/Libraries/LibPartition/MBRPartitionTable.cpp index 9ba3a271476..2064df17a36 100644 --- a/Userland/Libraries/LibPartition/MBRPartitionTable.cpp +++ b/Userland/Libraries/LibPartition/MBRPartitionTable.cpp @@ -7,6 +7,10 @@ #include #include +#ifndef KERNEL +# include +#endif + namespace Partition { #define MBR_SIGNATURE 0xaa55 @@ -19,7 +23,7 @@ ErrorOr> MBRPartitionTable::try_to_initialize(K { auto table = TRY(adopt_nonnull_own_or_enomem(new (nothrow) MBRPartitionTable(device))); #else -ErrorOr> MBRPartitionTable::try_to_initialize(NonnullRefPtr device_file) +ErrorOr> MBRPartitionTable::try_to_initialize(NonnullRefPtr device_file) { auto table = TRY(adopt_nonnull_own_or_enomem(new (nothrow) MBRPartitionTable(move(device_file)))); #endif @@ -37,7 +41,7 @@ OwnPtr MBRPartitionTable::try_to_initialize(Kernel::StorageDe { auto table = adopt_nonnull_own_or_enomem(new (nothrow) MBRPartitionTable(device, start_lba)).release_value_but_fixme_should_propagate_errors(); #else -OwnPtr MBRPartitionTable::try_to_initialize(NonnullRefPtr device_file, u32 start_lba) +OwnPtr MBRPartitionTable::try_to_initialize(NonnullRefPtr device_file, u32 start_lba) { auto table = adopt_nonnull_own_or_enomem(new (nothrow) MBRPartitionTable(move(device_file), start_lba)).release_value_but_fixme_should_propagate_errors(); #endif @@ -65,7 +69,7 @@ bool MBRPartitionTable::read_boot_record() MBRPartitionTable::MBRPartitionTable(Kernel::StorageDevice const& device, u32 start_lba) : PartitionTable(device) #else -MBRPartitionTable::MBRPartitionTable(NonnullRefPtr device_file, u32 start_lba) +MBRPartitionTable::MBRPartitionTable(NonnullRefPtr device_file, u32 start_lba) : PartitionTable(move(device_file)) #endif , m_start_lba(start_lba) @@ -91,7 +95,7 @@ MBRPartitionTable::MBRPartitionTable(NonnullRefPtr device_file, u32 MBRPartitionTable::MBRPartitionTable(Kernel::StorageDevice const& device) : PartitionTable(device) #else -MBRPartitionTable::MBRPartitionTable(NonnullRefPtr device_file) +MBRPartitionTable::MBRPartitionTable(NonnullRefPtr device_file) : PartitionTable(move(device_file)) #endif , m_start_lba(0) diff --git a/Userland/Libraries/LibPartition/MBRPartitionTable.h b/Userland/Libraries/LibPartition/MBRPartitionTable.h index 62c126fc796..48bc24a6dd6 100644 --- a/Userland/Libraries/LibPartition/MBRPartitionTable.h +++ b/Userland/Libraries/LibPartition/MBRPartitionTable.h @@ -44,10 +44,10 @@ public: explicit MBRPartitionTable(Kernel::StorageDevice const&); MBRPartitionTable(Kernel::StorageDevice const&, u32 start_lba); #else - static ErrorOr> try_to_initialize(NonnullRefPtr); - static OwnPtr try_to_initialize(NonnullRefPtr, u32 start_lba); - explicit MBRPartitionTable(NonnullRefPtr); - MBRPartitionTable(NonnullRefPtr, u32 start_lba); + static ErrorOr> try_to_initialize(NonnullRefPtr); + static OwnPtr try_to_initialize(NonnullRefPtr, u32 start_lba); + explicit MBRPartitionTable(NonnullRefPtr); + MBRPartitionTable(NonnullRefPtr, u32 start_lba); #endif bool is_protective_mbr() const; diff --git a/Userland/Libraries/LibPartition/PartitionTable.cpp b/Userland/Libraries/LibPartition/PartitionTable.cpp index b3e16ea2dc1..19940da3673 100644 --- a/Userland/Libraries/LibPartition/PartitionTable.cpp +++ b/Userland/Libraries/LibPartition/PartitionTable.cpp @@ -7,6 +7,7 @@ #include #ifndef KERNEL +# include # include #endif @@ -19,7 +20,7 @@ PartitionTable::PartitionTable(Kernel::StorageDevice const& device) { } #else -PartitionTable::PartitionTable(NonnullRefPtr device_file) +PartitionTable::PartitionTable(NonnullRefPtr device_file) : m_device_file(device_file) { VERIFY(ioctl(m_device_file->leak_fd(), STORAGE_DEVICE_GET_BLOCK_SIZE, &m_block_size) >= 0); diff --git a/Userland/Libraries/LibPartition/PartitionTable.h b/Userland/Libraries/LibPartition/PartitionTable.h index fcbccf9bf82..d1026c5f710 100644 --- a/Userland/Libraries/LibPartition/PartitionTable.h +++ b/Userland/Libraries/LibPartition/PartitionTable.h @@ -6,12 +6,13 @@ #pragma once +#include #include #ifdef KERNEL # include #else -# include +# include #endif namespace Partition { @@ -31,8 +32,8 @@ protected: explicit PartitionTable(Kernel::StorageDevice const&); NonnullRefPtr m_device; #else - explicit PartitionTable(NonnullRefPtr); - NonnullRefPtr m_device_file; + explicit PartitionTable(NonnullRefPtr); + NonnullRefPtr m_device_file; #endif Vector m_partitions; diff --git a/Userland/Libraries/LibSQL/BTree.h b/Userland/Libraries/LibSQL/BTree.h index 1bc149e9c59..c47be1f2a76 100644 --- a/Userland/Libraries/LibSQL/BTree.h +++ b/Userland/Libraries/LibSQL/BTree.h @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Libraries/LibSQL/SQLClient.cpp b/Userland/Libraries/LibSQL/SQLClient.cpp index 00618df647e..2cad3e8c8d9 100644 --- a/Userland/Libraries/LibSQL/SQLClient.cpp +++ b/Userland/Libraries/LibSQL/SQLClient.cpp @@ -10,8 +10,8 @@ #include #if !defined(AK_OS_SERENITY) +# include # include -# include # include # include # include @@ -25,7 +25,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::File::exists(socket_path)) + if (Core::DeprecatedFile::exists(socket_path)) TRY(Core::System::unlink(socket_path)); # ifdef SOCK_NONBLOCK @@ -103,7 +103,7 @@ static ErrorOr launch_server(DeprecatedString const& socket_path, Deprecat static ErrorOr should_launch_server(DeprecatedString const& pid_path) { - if (!Core::File::exists(pid_path)) + if (!Core::DeprecatedFile::exists(pid_path)) return true; Optional pid; diff --git a/Userland/Libraries/LibSymbolication/Symbolication.cpp b/Userland/Libraries/LibSymbolication/Symbolication.cpp index 9f5995f1228..911be1fc411 100644 --- a/Userland/Libraries/LibSymbolication/Symbolication.cpp +++ b/Userland/Libraries/LibSymbolication/Symbolication.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -37,7 +37,7 @@ static KernelBaseState s_kernel_base_state = KernelBaseState::Uninitialized; Optional kernel_base() { if (s_kernel_base_state == KernelBaseState::Uninitialized) { - auto file = Core::File::open("/sys/kernel/load_base", Core::OpenMode::ReadOnly); + auto file = Core::DeprecatedFile::open("/sys/kernel/load_base", Core::OpenMode::ReadOnly); if (file.is_error()) { s_kernel_base_state = KernelBaseState::Invalid; return {}; @@ -65,7 +65,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::File::exists(full_path)) { + if (Core::DeprecatedFile::exists(full_path)) { found = true; break; } @@ -147,7 +147,7 @@ Vector symbolicate_thread(pid_t pid, pid_t tid, IncludeSourcePosition in { auto stack_path = DeprecatedString::formatted("/proc/{}/stacks/{}", pid, tid); - auto file_or_error = Core::File::open(stack_path, Core::OpenMode::ReadOnly); + auto file_or_error = Core::DeprecatedFile::open(stack_path, Core::OpenMode::ReadOnly); if (file_or_error.is_error()) { warnln("Could not open {}: {}", stack_path, file_or_error.error()); return {}; @@ -167,7 +167,7 @@ Vector symbolicate_thread(pid_t pid, pid_t tid, IncludeSourcePosition in { auto vm_path = DeprecatedString::formatted("/proc/{}/vm", pid); - auto file_or_error = Core::File::open(vm_path, Core::OpenMode::ReadOnly); + auto file_or_error = Core::DeprecatedFile::open(vm_path, Core::OpenMode::ReadOnly); if (file_or_error.is_error()) { warnln("Could not open {}: {}", vm_path, file_or_error.error()); return {}; diff --git a/Userland/Libraries/LibTLS/TLSv12.cpp b/Userland/Libraries/LibTLS/TLSv12.cpp index fefd7272be3..4228f1a6655 100644 --- a/Userland/Libraries/LibTLS/TLSv12.cpp +++ b/Userland/Libraries/LibTLS/TLSv12.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Libraries/LibTest/JavaScriptTestRunner.h b/Userland/Libraries/LibTest/JavaScriptTestRunner.h index 9f39623e74c..997802532a8 100644 --- a/Userland/Libraries/LibTest/JavaScriptTestRunner.h +++ b/Userland/Libraries/LibTest/JavaScriptTestRunner.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp b/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp index 5618e78b308..579c3be5fdd 100644 --- a/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp +++ b/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -152,7 +153,7 @@ int main(int argc, char** argv) common_path = DeprecatedString::formatted("{}/Userland/Libraries/LibJS/Tests/test-common.js", serenity_source_dir); #endif } - if (!Core::File::is_directory(test_root)) { + if (!Core::DeprecatedFile::is_directory(test_root)) { warnln("Test root is not a directory: {}", test_root); return 1; } @@ -170,8 +171,8 @@ int main(int argc, char** argv) #endif } - test_root = Core::File::real_path_for(test_root); - common_path = Core::File::real_path_for(common_path); + test_root = Core::DeprecatedFile::real_path_for(test_root); + common_path = Core::DeprecatedFile::real_path_for(common_path); if (chdir(test_root.characters()) < 0) { auto saved_errno = errno; diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp index 7b50a85ea99..ac104ff7445 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Libraries/LibWebView/RequestServerAdapter.cpp b/Userland/Libraries/LibWebView/RequestServerAdapter.cpp index 5dcac0eca86..b08f293233b 100644 --- a/Userland/Libraries/LibWebView/RequestServerAdapter.cpp +++ b/Userland/Libraries/LibWebView/RequestServerAdapter.cpp @@ -4,7 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include #include #include #include diff --git a/Userland/Services/AudioServer/Mixer.cpp b/Userland/Services/AudioServer/Mixer.cpp index 25cd8ab26e8..ff5abf9a977 100644 --- a/Userland/Services/AudioServer/Mixer.cpp +++ b/Userland/Services/AudioServer/Mixer.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -21,7 +22,7 @@ namespace AudioServer { Mixer::Mixer(NonnullRefPtr config) // FIXME: Allow AudioServer to use other audio channels as well - : m_device(Core::File::construct("/dev/audio/0", this)) + : m_device(Core::DeprecatedFile::construct("/dev/audio/0", this)) , m_sound_thread(Threading::Thread::construct( [this] { mix(); diff --git a/Userland/Services/AudioServer/Mixer.h b/Userland/Services/AudioServer/Mixer.h index 67628019b62..fcb7367cd83 100644 --- a/Userland/Services/AudioServer/Mixer.h +++ b/Userland/Services/AudioServer/Mixer.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -129,7 +128,7 @@ private: Threading::Mutex m_pending_mutex; Threading::ConditionVariable m_mixing_necessary { m_pending_mutex }; - RefPtr m_device; + RefPtr m_device; NonnullRefPtr m_sound_thread; diff --git a/Userland/Services/ChessEngine/ChessEngine.cpp b/Userland/Services/ChessEngine/ChessEngine.cpp index 4c92f4c221f..15a8040a62d 100644 --- a/Userland/Services/ChessEngine/ChessEngine.cpp +++ b/Userland/Services/ChessEngine/ChessEngine.cpp @@ -7,6 +7,7 @@ #include "ChessEngine.h" #include "MCTSTree.h" #include +#include #include using namespace Chess::UCI; diff --git a/Userland/Services/ChessEngine/main.cpp b/Userland/Services/ChessEngine/main.cpp index 7f7902e359a..a16ca4e8a21 100644 --- a/Userland/Services/ChessEngine/main.cpp +++ b/Userland/Services/ChessEngine/main.cpp @@ -5,8 +5,8 @@ */ #include "ChessEngine.h" +#include #include -#include #include #include @@ -16,6 +16,6 @@ ErrorOr serenity_main(Main::Arguments) Core::EventLoop loop; TRY(Core::System::unveil(nullptr, nullptr)); - auto engine = TRY(ChessEngine::try_create(Core::File::standard_input(), Core::File::standard_output())); + auto engine = TRY(ChessEngine::try_create(Core::DeprecatedFile::standard_input(), Core::DeprecatedFile::standard_output())); return loop.exec(); } diff --git a/Userland/Services/DHCPClient/DHCPv4Client.cpp b/Userland/Services/DHCPClient/DHCPv4Client.cpp index 9ea10573b2b..1573a812804 100644 --- a/Userland/Services/DHCPClient/DHCPv4Client.cpp +++ b/Userland/Services/DHCPClient/DHCPv4Client.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include @@ -179,7 +179,7 @@ void DHCPv4Client::try_discover_ifs() ErrorOr DHCPv4Client::get_discoverable_interfaces() { - auto file = TRY(Core::File::open("/sys/kernel/net/adapters", Core::OpenMode::ReadOnly)); + auto file = TRY(Core::DeprecatedFile::open("/sys/kernel/net/adapters", Core::OpenMode::ReadOnly)); auto file_contents = file->read_all(); auto json = JsonValue::from_string(file_contents); diff --git a/Userland/Services/FileSystemAccessServer/ConnectionFromClient.cpp b/Userland/Services/FileSystemAccessServer/ConnectionFromClient.cpp index d368182a249..b4c5f97ef1d 100644 --- a/Userland/Services/FileSystemAccessServer/ConnectionFromClient.cpp +++ b/Userland/Services/FileSystemAccessServer/ConnectionFromClient.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include @@ -67,7 +67,7 @@ void ConnectionFromClient::request_file_handler(i32 request_id, i32 window_serve auto pid = this->socket().peer_pid().release_value_but_fixme_should_propagate_errors(); auto exe_link = LexicalPath("/proc").append(DeprecatedString::number(pid)).append("exe"sv).string(); - auto exe_path = Core::File::real_path_for(exe_link); + auto exe_path = Core::DeprecatedFile::real_path_for(exe_link); auto main_window = create_dummy_child_window(window_server_client_id, parent_window_id); diff --git a/Userland/Services/KeyboardPreferenceLoader/main.cpp b/Userland/Services/KeyboardPreferenceLoader/main.cpp index 1d6ab4112c9..6fac3009fce 100644 --- a/Userland/Services/KeyboardPreferenceLoader/main.cpp +++ b/Userland/Services/KeyboardPreferenceLoader/main.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include @@ -38,7 +38,7 @@ ErrorOr serenity_main(Main::Arguments) } bool enable_num_lock = keyboard_settings_config->read_bool_entry("StartupEnable", "NumLock", true); - auto keyboard_device = TRY(Core::File::open("/dev/input/keyboard/0", Core::OpenMode::ReadOnly)); + auto keyboard_device = TRY(Core::DeprecatedFile::open("/dev/input/keyboard/0", Core::OpenMode::ReadOnly)); TRY(Core::System::ioctl(keyboard_device->fd(), KEYBOARD_IOCTL_SET_NUM_LOCK, enable_num_lock)); return 0; diff --git a/Userland/Services/LaunchServer/Launcher.cpp b/Userland/Services/LaunchServer/Launcher.cpp index 1c0be751c0e..b90d59409e7 100644 --- a/Userland/Services/LaunchServer/Launcher.cpp +++ b/Userland/Services/LaunchServer/Launcher.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -179,7 +179,7 @@ Vector Launcher::handlers_with_details_for_url(const URL& url) Optional Launcher::mime_type_for_file(DeprecatedString path) { - auto file_or_error = Core::File::open(path, Core::OpenMode::ReadOnly); + auto file_or_error = Core::DeprecatedFile::open(path, Core::OpenMode::ReadOnly); if (file_or_error.is_error()) { return {}; } else { @@ -308,7 +308,7 @@ void Launcher::for_each_handler_for_path(DeprecatedString const& path, Function< return; if (S_ISLNK(st.st_mode)) { - auto link_target_or_error = Core::File::read_link(path); + auto link_target_or_error = Core::DeprecatedFile::read_link(path); if (link_target_or_error.is_error()) { perror("read_link"); return; @@ -316,7 +316,7 @@ void Launcher::for_each_handler_for_path(DeprecatedString const& path, Function< auto link_target = LexicalPath { link_target_or_error.release_value() }; LexicalPath absolute_link_target = link_target.is_absolute() ? link_target : LexicalPath::join(LexicalPath::dirname(path), link_target.string()); - auto real_path = Core::File::real_path_for(absolute_link_target.string()); + auto real_path = Core::DeprecatedFile::real_path_for(absolute_link_target.string()); return for_each_handler_for_path(real_path, [&](auto const& handler) -> bool { return f(handler); }); diff --git a/Userland/Services/LookupServer/LookupServer.cpp b/Userland/Services/LookupServer/LookupServer.cpp index b0fdbfe7d2d..653de85efbe 100644 --- a/Userland/Services/LookupServer/LookupServer.cpp +++ b/Userland/Services/LookupServer/LookupServer.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -83,7 +83,7 @@ void LookupServer::load_etc_hosts() m_etc_hosts.ensure(name).empend(name, record_type, RecordClass::IN, s_static_ttl, move(data), false); }; - auto file = Core::File::construct("/etc/hosts"); + auto file = Core::DeprecatedFile::construct("/etc/hosts"); if (!file->open(Core::OpenMode::ReadOnly)) { dbgln("Failed to open '/etc/hosts'"); return; diff --git a/Userland/Services/LookupServer/MulticastDNS.cpp b/Userland/Services/LookupServer/MulticastDNS.cpp index 15472b03109..7499391a63e 100644 --- a/Userland/Services/LookupServer/MulticastDNS.cpp +++ b/Userland/Services/LookupServer/MulticastDNS.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -119,7 +119,7 @@ ErrorOr MulticastDNS::emit_packet(Packet const& packet, sockaddr_in cons Vector MulticastDNS::local_addresses() const { - auto file = Core::File::construct("/sys/kernel/net/adapters"); + auto file = Core::DeprecatedFile::construct("/sys/kernel/net/adapters"); if (!file->open(Core::OpenMode::ReadOnly)) { dbgln("Failed to open /sys/kernel/net/adapters: {}", file->error_string()); return {}; diff --git a/Userland/Services/NetworkServer/main.cpp b/Userland/Services/NetworkServer/main.cpp index 6ede99f447a..6e4ba5d7a16 100644 --- a/Userland/Services/NetworkServer/main.cpp +++ b/Userland/Services/NetworkServer/main.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Services/SystemServer/Service.cpp b/Userland/Services/SystemServer/Service.cpp index d484b4fae7b..56590f0d9e8 100644 --- a/Userland/Services/SystemServer/Service.cpp +++ b/Userland/Services/SystemServer/Service.cpp @@ -12,8 +12,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -123,7 +123,7 @@ ErrorOr Service::activate() ErrorOr Service::spawn(int socket_fd) { - if (!Core::File::exists(m_executable_path)) { + if (!Core::DeprecatedFile::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/SystemServer/main.cpp b/Userland/Services/SystemServer/main.cpp index b27f138d25a..6b8c77cba2d 100644 --- a/Userland/Services/SystemServer/main.cpp +++ b/Userland/Services/SystemServer/main.cpp @@ -13,10 +13,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -72,7 +72,7 @@ static ErrorOr determine_system_mode() g_system_mode = "text"; }); - auto f = Core::File::construct("/sys/kernel/system_mode"); + auto f = Core::DeprecatedFile::construct("/sys/kernel/system_mode"); if (!f->open(Core::OpenMode::ReadOnly)) { dbgln("Failed to read system_mode: {}", f->error_string()); // Continue and assume "text" mode. @@ -188,7 +188,7 @@ static ErrorOr populate_devtmpfs_char_devices_based_on_sysfs() static ErrorOr populate_devtmpfs_devices_based_on_devctl() { - auto f = Core::File::construct("/dev/devctl"); + auto f = Core::DeprecatedFile::construct("/dev/devctl"); if (!f->open(Core::OpenMode::ReadOnly)) { warnln("Failed to open /dev/devctl - {}", f->error_string()); VERIFY_NOT_REACHED(); diff --git a/Userland/Services/TelnetServer/main.cpp b/Userland/Services/TelnetServer/main.cpp index fceae0fd2ab..ca8a07e3b8e 100644 --- a/Userland/Services/TelnetServer/main.cpp +++ b/Userland/Services/TelnetServer/main.cpp @@ -9,8 +9,8 @@ #include #include #include +#include #include -#include #include #include #include diff --git a/Userland/Services/WebContent/main.cpp b/Userland/Services/WebContent/main.cpp index dda03d5330c..a19831cf807 100644 --- a/Userland/Services/WebContent/main.cpp +++ b/Userland/Services/WebContent/main.cpp @@ -5,8 +5,8 @@ */ #include "ImageCodecPluginSerenity.h" +#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::File::exists(webdriver_socket_path)) + if (Core::DeprecatedFile::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/Client.cpp b/Userland/Services/WebServer/Client.cpp index beb497438b1..5e06d223381 100644 --- a/Userland/Services/WebServer/Client.cpp +++ b/Userland/Services/WebServer/Client.cpp @@ -14,8 +14,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -132,7 +132,7 @@ ErrorOr Client::handle_request(ReadonlyBytes raw_request) path_builder.append(requested_path); auto real_path = TRY(path_builder.to_string()); - if (Core::File::is_directory(real_path.bytes_as_string_view())) { + if (Core::DeprecatedFile::is_directory(real_path.bytes_as_string_view())) { if (!resource_decoded.ends_with('/')) { StringBuilder red; @@ -147,14 +147,14 @@ 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::File::exists(index_html_path)) { + if (!Core::DeprecatedFile::exists(index_html_path)) { TRY(handle_directory_listing(requested_path, real_path, request)); return true; } real_path = index_html_path; } - auto file = Core::File::construct(real_path.bytes_as_string_view()); + auto file = Core::DeprecatedFile::construct(real_path.bytes_as_string_view()); if (!file->open(Core::OpenMode::ReadOnly)) { TRY(send_error_response(404, request)); return false; @@ -169,7 +169,7 @@ ErrorOr Client::handle_request(ReadonlyBytes raw_request) auto const info = ContentInfo { .type = TRY(String::from_deprecated_string(Core::guess_mime_type_based_on_filename(real_path.bytes_as_string_view()))), - .length = TRY(Core::File::size(real_path.bytes_as_string_view())) + .length = TRY(Core::DeprecatedFile::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 dc6c6f3856d..56ba18a2fae 100644 --- a/Userland/Services/WebServer/main.cpp +++ b/Userland/Services/WebServer/main.cpp @@ -8,8 +8,8 @@ #include #include +#include #include -#include #include #include #include @@ -56,8 +56,8 @@ ErrorOr serenity_main(Main::Arguments arguments) return 1; } - auto real_document_root_path = Core::File::real_path_for(document_root_path); - if (!Core::File::exists(real_document_root_path)) { + auto real_document_root_path = Core::DeprecatedFile::real_path_for(document_root_path); + if (!Core::DeprecatedFile::exists(real_document_root_path)) { warnln("Root path does not exist: '{}'", document_root_path); return 1; } diff --git a/Userland/Services/WindowServer/KeymapSwitcher.cpp b/Userland/Services/WindowServer/KeymapSwitcher.cpp index 92adcb0adb3..68c75391820 100644 --- a/Userland/Services/WindowServer/KeymapSwitcher.cpp +++ b/Userland/Services/WindowServer/KeymapSwitcher.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include @@ -90,7 +90,7 @@ void KeymapSwitcher::next_keymap() DeprecatedString KeymapSwitcher::get_current_keymap() const { - auto proc_keymap = Core::File::construct("/sys/kernel/keymap"); + auto proc_keymap = Core::DeprecatedFile::construct("/sys/kernel/keymap"); if (!proc_keymap->open(Core::OpenMode::ReadOnly)) VERIFY_NOT_REACHED(); diff --git a/Userland/Services/WindowServer/main.cpp b/Userland/Services/WindowServer/main.cpp index 57c3920a126..5fc766a26c1 100644 --- a/Userland/Services/WindowServer/main.cpp +++ b/Userland/Services/WindowServer/main.cpp @@ -11,8 +11,8 @@ #include "WindowManager.h" #include #include +#include #include -#include #include #include #include @@ -85,7 +85,7 @@ ErrorOr serenity_main(Main::Arguments) if (!path.starts_with("connector"sv)) continue; auto full_path = DeprecatedString::formatted("/dev/gpu/{}", path); - if (!Core::File::is_device(full_path)) + if (!Core::DeprecatedFile::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 be2195db00b..26fce6e092f 100644 --- a/Userland/Shell/AST.cpp +++ b/Userland/Shell/AST.cpp @@ -12,8 +12,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -658,7 +658,7 @@ void BarewordLiteral::highlight_in_editor(Line::Editor& editor, Shell& shell, Hi editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Foreground(Line::Style::XtermColor::Cyan) }); } } - if (Core::File::exists(m_text)) { + if (Core::DeprecatedFile::exists(m_text)) { auto realpath = shell.resolve_path(m_text); auto url = URL::create_with_file_scheme(realpath); url.set_host(shell.hostname); @@ -3053,7 +3053,7 @@ void Juxtaposition::highlight_in_editor(Line::Editor& editor, Shell& shell, High path_builder.append(bareword_value); auto path = path_builder.to_deprecated_string(); - if (Core::File::exists(path)) { + if (Core::DeprecatedFile::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/Builtin.cpp b/Userland/Shell/Builtin.cpp index ec45f907111..1c7268c938f 100644 --- a/Userland/Shell/Builtin.cpp +++ b/Userland/Shell/Builtin.cpp @@ -12,8 +12,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -61,7 +61,7 @@ static Vector find_matching_executables_in_path(StringView fil auto file = DeprecatedString::formatted("{}/{}", directory, filename); if (follow_symlinks == FollowSymlinks::Yes) { - auto path_or_error = Core::File::read_link(file); + auto path_or_error = Core::DeprecatedFile::read_link(file); if (!path_or_error.is_error()) file = path_or_error.release_value(); } @@ -332,7 +332,7 @@ int Shell::builtin_type(int argc, char const** argv) } // check if its an executable in PATH - auto fullpath = Core::File::resolve_executable_from_environment(command); + auto fullpath = Core::DeprecatedFile::resolve_executable_from_environment(command); if (fullpath.has_value()) { printf("%s is %s\n", command.characters(), escape_token(fullpath.release_value()).characters()); continue; @@ -372,7 +372,7 @@ int Shell::builtin_cd(int argc, char const** argv) } } - auto real_path = Core::File::real_path_for(new_path); + auto real_path = Core::DeprecatedFile::real_path_for(new_path); if (real_path.is_empty()) { warnln("Invalid path '{}'", new_path); return 1; @@ -1175,7 +1175,7 @@ int Shell::builtin_kill(int argc, char const** argv) { // Simply translate the arguments and pass them to `kill' Vector replaced_values; - auto kill_path = Core::File::resolve_executable_from_environment("kill"sv); + auto kill_path = Core::DeprecatedFile::resolve_executable_from_environment("kill"sv); if (!kill_path.has_value()) { warnln("kill: `kill' not found in PATH"); return 126; diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp index fa349cb68f9..3bbe927eed9 100644 --- a/Userland/Shell/Shell.cpp +++ b/Userland/Shell/Shell.cpp @@ -19,10 +19,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -220,7 +220,7 @@ Vector Shell::expand_globs(StringView path, StringView base) } StringBuilder resolved_base_path_builder; - resolved_base_path_builder.append(Core::File::real_path_for(base)); + resolved_base_path_builder.append(Core::DeprecatedFile::real_path_for(base)); if (S_ISDIR(statbuf.st_mode)) resolved_base_path_builder.append('/'); @@ -337,7 +337,7 @@ DeprecatedString Shell::resolve_path(DeprecatedString path) const if (!path.starts_with('/')) path = DeprecatedString::formatted("{}/{}", cwd, path); - return Core::File::real_path_for(path); + return Core::DeprecatedFile::real_path_for(path); } Shell::LocalFrame* Shell::find_frame_containing_local_variable(StringView name) @@ -522,7 +522,7 @@ Optional Shell::runnable_path_for(StringView name) auto parts = name.split_view('/'); auto path = name.to_deprecated_string(); if (parts.size() > 1) { - auto file = Core::File::open(path.characters(), Core::OpenMode::ReadOnly); + auto file = Core::DeprecatedFile::open(path.characters(), Core::OpenMode::ReadOnly); if (!file.is_error() && !file.value()->is_directory() && access(path.characters(), X_OK) == 0) return RunnablePath { RunnablePath::Kind::Executable, name }; } @@ -906,7 +906,7 @@ void Shell::execute_process(Vector&& argv) } if (saved_errno == ENOENT) { do { - auto file_result = Core::File::open(argv[0], Core::OpenMode::ReadOnly); + auto file_result = Core::DeprecatedFile::open(argv[0], Core::OpenMode::ReadOnly); if (file_result.is_error()) break; auto& file = file_result.value(); @@ -1045,7 +1045,7 @@ bool Shell::run_file(DeprecatedString const& filename, bool explicitly_invoked) TemporaryChange interactive_change { m_is_interactive, false }; TemporaryChange> source_change { m_source_position, SourcePosition { .source_file = filename, .literal_source_text = {}, .position = {} } }; - auto file_result = Core::File::open(filename, Core::OpenMode::ReadOnly); + auto file_result = Core::DeprecatedFile::open(filename, Core::OpenMode::ReadOnly); if (file_result.is_error()) { auto error = DeprecatedString::formatted("'{}': {}", escape_token_for_single_quotes(filename), file_result.error()); if (explicitly_invoked) @@ -1364,7 +1364,7 @@ void Shell::cache_path() cached_path.append({ RunnablePath::Kind::Alias, name }); } - // TODO: Can we make this rely on Core::File::resolve_executable_from_environment()? + // TODO: Can we make this rely on Core::DeprecatedFile::resolve_executable_from_environment()? DeprecatedString path = getenv("PATH"); if (!path.is_empty()) { auto directories = path.split(':'); @@ -2391,7 +2391,7 @@ void Shell::possibly_print_error() const i64 line_to_skip_to = max(source_position.position->start_line.line_number, 2ul) - 2; if (!source_position.source_file.is_null()) { - auto file = Core::File::open(source_position.source_file, Core::OpenMode::ReadOnly); + auto file = Core::DeprecatedFile::open(source_position.source_file, Core::OpenMode::ReadOnly); if (file.is_error()) { warnln("Shell: Internal error while trying to display source information: {} (while reading '{}')", file.error(), source_position.source_file); return; diff --git a/Userland/Shell/main.cpp b/Userland/Shell/main.cpp index 5512d2240f1..dc89853a1cd 100644 --- a/Userland/Shell/main.cpp +++ b/Userland/Shell/main.cpp @@ -6,9 +6,9 @@ #include "Shell.h" #include +#include #include #include -#include #include #include #include @@ -183,7 +183,7 @@ ErrorOr serenity_main(Main::Arguments arguments) parser.parse(arguments); if (format) { - auto file = TRY(Core::File::open(format, Core::OpenMode::ReadOnly)); + auto file = TRY(Core::DeprecatedFile::open(format, Core::OpenMode::ReadOnly)); initialize(); @@ -224,7 +224,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::File::exists(file_path)) { + if (Core::DeprecatedFile::exists(file_path)) { shell->run_file(file_path, false); } }; diff --git a/Userland/Utilities/abench.cpp b/Userland/Utilities/abench.cpp index 7ad08b38c94..2920e05498a 100644 --- a/Userland/Utilities/abench.cpp +++ b/Userland/Utilities/abench.cpp @@ -8,8 +8,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -28,7 +28,7 @@ ErrorOr serenity_main(Main::Arguments args) args_parser.add_option(sample_count, "How many samples to load at maximum", "sample-count", 's', "samples"); args_parser.parse(args); - TRY(Core::System::unveil(Core::File::absolute_path(path), "r"sv)); + TRY(Core::System::unveil(Core::DeprecatedFile::absolute_path(path), "r"sv)); TRY(Core::System::unveil(nullptr, nullptr)); TRY(Core::System::pledge("stdio recvfd rpath")); diff --git a/Userland/Utilities/aplay.cpp b/Userland/Utilities/aplay.cpp index 18d693de424..20884b14175 100644 --- a/Userland/Utilities/aplay.cpp +++ b/Userland/Utilities/aplay.cpp @@ -10,8 +10,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -36,7 +36,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.parse(arguments); TRY(Core::System::unveil("/tmp/session/%sid/portal/audio", "rw")); - TRY(Core::System::unveil(Core::File::absolute_path(path), "r"sv)); + TRY(Core::System::unveil(Core::DeprecatedFile::absolute_path(path), "r"sv)); TRY(Core::System::unveil(nullptr, nullptr)); Core::EventLoop loop; diff --git a/Userland/Utilities/asctl.cpp b/Userland/Utilities/asctl.cpp index 4bdb8eb1cde..0256423188e 100644 --- a/Userland/Utilities/asctl.cpp +++ b/Userland/Utilities/asctl.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Utilities/comm.cpp b/Userland/Utilities/comm.cpp index 6d755298fbb..370bdc4ea10 100644 --- a/Userland/Utilities/comm.cpp +++ b/Userland/Utilities/comm.cpp @@ -6,7 +6,7 @@ */ #include -#include +#include #include #include #include @@ -68,7 +68,7 @@ ErrorOr serenity_main(Main::Arguments arguments) return false; } - if (path != "-" && Core::File::is_directory(path)) { + if (path != "-" && Core::DeprecatedFile::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 5c544080212..af26144087c 100644 --- a/Userland/Utilities/cp.cpp +++ b/Userland/Utilities/cp.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include @@ -17,7 +17,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio rpath wpath cpath fattr chown")); bool link = false; - auto preserve = Core::File::PreserveMode::Nothing; + auto preserve = Core::DeprecatedFile::PreserveMode::Nothing; bool recursion_allowed = false; bool verbose = false; Vector sources; @@ -33,7 +33,7 @@ ErrorOr serenity_main(Main::Arguments arguments) "attributes", [&preserve](char const* s) { if (!s) { - preserve = Core::File::PreserveMode::Permissions | Core::File::PreserveMode::Ownership | Core::File::PreserveMode::Timestamps; + preserve = Core::DeprecatedFile::PreserveMode::Permissions | Core::DeprecatedFile::PreserveMode::Ownership | Core::DeprecatedFile::PreserveMode::Timestamps; return true; } @@ -41,11 +41,11 @@ ErrorOr serenity_main(Main::Arguments arguments) StringView { s, strlen(s) }.for_each_split_view(',', SplitBehavior::Nothing, [&](StringView value) { if (value == "mode"sv) { - preserve |= Core::File::PreserveMode::Permissions; + preserve |= Core::DeprecatedFile::PreserveMode::Permissions; } else if (value == "ownership"sv) { - preserve |= Core::File::PreserveMode::Ownership; + preserve |= Core::DeprecatedFile::PreserveMode::Ownership; } else if (value == "timestamps"sv) { - preserve |= Core::File::PreserveMode::Timestamps; + preserve |= Core::DeprecatedFile::PreserveMode::Timestamps; } else { warnln("cp: Unknown or unimplemented --preserve attribute: '{}'", value); values_ok = false; @@ -63,24 +63,24 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(destination, "Destination file path", "destination"); args_parser.parse(arguments); - if (has_flag(preserve, Core::File::PreserveMode::Permissions)) { + if (has_flag(preserve, Core::DeprecatedFile::PreserveMode::Permissions)) { umask(0); } else { TRY(Core::System::pledge("stdio rpath wpath cpath fattr")); } - bool destination_is_existing_dir = Core::File::is_directory(destination); + bool destination_is_existing_dir = Core::DeprecatedFile::is_directory(destination); for (auto& source : sources) { auto destination_path = destination_is_existing_dir ? DeprecatedString::formatted("{}/{}", destination, LexicalPath::basename(source)) : destination; - auto result = Core::File::copy_file_or_directory( + auto result = Core::DeprecatedFile::copy_file_or_directory( destination_path, source, - recursion_allowed ? Core::File::RecursionMode::Allowed : Core::File::RecursionMode::Disallowed, - link ? Core::File::LinkMode::Allowed : Core::File::LinkMode::Disallowed, - Core::File::AddDuplicateFileMarker::No, + recursion_allowed ? Core::DeprecatedFile::RecursionMode::Allowed : Core::DeprecatedFile::RecursionMode::Disallowed, + link ? Core::DeprecatedFile::LinkMode::Allowed : Core::DeprecatedFile::LinkMode::Disallowed, + Core::DeprecatedFile::AddDuplicateFileMarker::No, preserve); if (result.is_error()) { diff --git a/Userland/Utilities/functrace.cpp b/Userland/Utilities/functrace.cpp index 4368ce35757..0e65262a566 100644 --- a/Userland/Utilities/functrace.cpp +++ b/Userland/Utilities/functrace.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Utilities/grep.cpp b/Userland/Utilities/grep.cpp index dc24f31c6d0..9004e841f69 100644 --- a/Userland/Utilities/grep.cpp +++ b/Userland/Utilities/grep.cpp @@ -11,8 +11,8 @@ #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::File::is_directory(path)) { + if (!Core::DeprecatedFile::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/groupdel.cpp b/Userland/Utilities/groupdel.cpp index 9021fd64c2f..03ade32609b 100644 --- a/Userland/Utilities/groupdel.cpp +++ b/Userland/Utilities/groupdel.cpp @@ -8,7 +8,6 @@ */ #include -#include #include #include #include diff --git a/Userland/Utilities/headless-browser.cpp b/Userland/Utilities/headless-browser.cpp index de0783c0994..9b08624b56a 100644 --- a/Userland/Utilities/headless-browser.cpp +++ b/Userland/Utilities/headless-browser.cpp @@ -14,8 +14,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -691,8 +691,8 @@ static void load_page_for_screenshot_and_exit(HeadlessBrowserPageClient& page_cl DeprecatedString output_file_path = "output.png"; dbgln("Saving to {}", output_file_path); - if (Core::File::exists(output_file_path)) - MUST(Core::File::remove(output_file_path, Core::File::RecursionMode::Disallowed)); + if (Core::DeprecatedFile::exists(output_file_path)) + MUST(Core::DeprecatedFile::remove(output_file_path, Core::DeprecatedFile::RecursionMode::Disallowed)); auto output_file = MUST(Core::Stream::File::open(output_file_path, Core::Stream::OpenMode::Write)); diff --git a/Userland/Utilities/ini.cpp b/Userland/Utilities/ini.cpp index da82d076a66..19e92bb76b3 100644 --- a/Userland/Utilities/ini.cpp +++ b/Userland/Utilities/ini.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include @@ -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::File::exists(path)) { + if (!Core::DeprecatedFile::exists(path)) { warnln("File does not exist: '{}'", path); return 1; } diff --git a/Userland/Utilities/install.cpp b/Userland/Utilities/install.cpp index c33331aca0a..8afe3f50a41 100644 --- a/Userland/Utilities/install.cpp +++ b/Userland/Utilities/install.cpp @@ -7,8 +7,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -35,7 +35,7 @@ ErrorOr serenity_main(Main::Arguments arguments) DeprecatedString destination_dir = (sources.size() > 1 ? DeprecatedString { destination } : LexicalPath::dirname(destination)); if (create_leading_dest_components) { - DeprecatedString destination_dir_absolute = Core::File::absolute_path(destination_dir); + DeprecatedString destination_dir_absolute = Core::DeprecatedFile::absolute_path(destination_dir); MUST(Core::Directory::create(destination_dir_absolute, Core::Directory::CreateDirectories::Yes)); } @@ -47,9 +47,9 @@ ErrorOr serenity_main(Main::Arguments arguments) final_destination = destination; } - TRY(Core::File::copy_file_or_directory(final_destination, source, Core::File::RecursionMode::Allowed, - Core::File::LinkMode::Disallowed, Core::File::AddDuplicateFileMarker::No, - Core::File::PreserveMode::Nothing)); + TRY(Core::DeprecatedFile::copy_file_or_directory(final_destination, source, Core::DeprecatedFile::RecursionMode::Allowed, + Core::DeprecatedFile::LinkMode::Disallowed, Core::DeprecatedFile::AddDuplicateFileMarker::No, + Core::DeprecatedFile::PreserveMode::Nothing)); auto current_access = TRY(Core::System::stat(final_destination)); TRY(Core::System::chmod(final_destination, permission_mask.apply(current_access.st_mode))); diff --git a/Userland/Utilities/ldd.cpp b/Userland/Utilities/ldd.cpp index 47fa61062b7..972c267230e 100644 --- a/Userland/Utilities/ldd.cpp +++ b/Userland/Utilities/ldd.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Utilities/ls.cpp b/Userland/Utilities/ls.cpp index 109ea0edb7a..b41aec19d13 100644 --- a/Userland/Utilities/ls.cpp +++ b/Userland/Utilities/ls.cpp @@ -15,8 +15,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -164,7 +164,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::File::is_directory(path)) { + if (flag_recursive && Core::DeprecatedFile::is_directory(path)) { size_t subdirs = 0; Core::DirIterator di(path, Core::DirIterator::SkipParentAndBaseDir); @@ -175,7 +175,7 @@ ErrorOr serenity_main(Main::Arguments arguments) while (di.has_next()) { DeprecatedString directory = di.next_full_path(); - if (Core::File::is_directory(directory) && !Core::File::is_link(directory)) { + if (Core::DeprecatedFile::is_directory(directory) && !Core::DeprecatedFile::is_link(directory)) { ++subdirs; FileMetadata new_file; new_file.name = move(directory); @@ -184,7 +184,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } } - bool show_dir_separator = files.size() > 1 && Core::File::is_directory(path) && !flag_list_directories_only; + bool show_dir_separator = files.size() > 1 && Core::DeprecatedFile::is_directory(path) && !flag_list_directories_only; if (show_dir_separator) { printf("%s:\n", path.characters()); } @@ -237,7 +237,7 @@ static DeprecatedString& hostname() static size_t print_name(const struct stat& st, DeprecatedString const& name, char const* path_for_link_resolution, char const* path_for_hyperlink) { if (!flag_disable_hyperlinks) { - auto full_path = Core::File::real_path_for(path_for_hyperlink); + auto full_path = Core::DeprecatedFile::real_path_for(path_for_hyperlink); if (!full_path.is_null()) { auto url = URL::create_with_file_scheme(full_path, {}, hostname()); out("\033]8;;{}\033\\", url.serialize()); @@ -274,7 +274,7 @@ static size_t print_name(const struct stat& st, DeprecatedString const& name, ch } if (S_ISLNK(st.st_mode)) { if (path_for_link_resolution) { - auto link_destination_or_error = Core::File::read_link(path_for_link_resolution); + auto link_destination_or_error = Core::DeprecatedFile::read_link(path_for_link_resolution); if (link_destination_or_error.is_error()) { perror("readlink"); } else { diff --git a/Userland/Utilities/man.cpp b/Userland/Utilities/man.cpp index 4ab40b96941..80546b0e6bd 100644 --- a/Userland/Utilities/man.cpp +++ b/Userland/Utilities/man.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Utilities/markdown-check.cpp b/Userland/Utilities/markdown-check.cpp index 2259e20db4c..55c45d2d75e 100644 --- a/Userland/Utilities/markdown-check.cpp +++ b/Userland/Utilities/markdown-check.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -272,7 +272,7 @@ ErrorOr serenity_main(Main::Arguments arguments) // Since this should never happen anyway, fail early. return 1; } - files.set(Core::File::real_path_for(path), MarkdownLinkage::analyze(*document)); + files.set(Core::DeprecatedFile::real_path_for(path), MarkdownLinkage::analyze(*document)); } outln("Checking links ..."); @@ -293,7 +293,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } else { pointee_file = LexicalPath::absolute_path(file_dir, file_link.file_path); } - if (!Core::File::exists(pointee_file) && !is_missing_file_acceptable(pointee_file)) { + if (!Core::DeprecatedFile::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 772549f93f1..4a30d350ff2 100644 --- a/Userland/Utilities/mv.cpp +++ b/Userland/Utilities/mv.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -69,17 +69,17 @@ ErrorOr serenity_main(Main::Arguments arguments) new_path = combined_new_path.characters(); } - if (no_clobber && Core::File::exists(new_path)) + if (no_clobber && Core::DeprecatedFile::exists(new_path)) continue; rc = rename(old_path.characters(), new_path.characters()); if (rc < 0) { if (errno == EXDEV) { - auto result = Core::File::copy_file_or_directory( + auto result = Core::DeprecatedFile::copy_file_or_directory( new_path, old_path, - Core::File::RecursionMode::Allowed, - Core::File::LinkMode::Disallowed, - Core::File::AddDuplicateFileMarker::No); + Core::DeprecatedFile::RecursionMode::Allowed, + Core::DeprecatedFile::LinkMode::Disallowed, + Core::DeprecatedFile::AddDuplicateFileMarker::No); if (result.is_error()) { warnln("mv: could not move '{}': {}", old_path, static_cast(result.error())); diff --git a/Userland/Utilities/open.cpp b/Userland/Utilities/open.cpp index 72a7a75e8d6..ef2ba4f6144 100644 --- a/Userland/Utilities/open.cpp +++ b/Userland/Utilities/open.cpp @@ -8,8 +8,8 @@ #include #include #include +#include #include -#include #include #include @@ -25,7 +25,7 @@ ErrorOr serenity_main(Main::Arguments arguments) bool all_ok = true; for (auto& url_or_path : urls_or_paths) { - auto path = Core::File::real_path_for(url_or_path); + auto path = Core::DeprecatedFile::real_path_for(url_or_path); auto url = URL::create_with_url_or_path(path.is_null() ? url_or_path : path.view()); if (!Desktop::Launcher::open(url)) { diff --git a/Userland/Utilities/pledge.cpp b/Userland/Utilities/pledge.cpp index 230e1a57128..a056c6cd196 100644 --- a/Userland/Utilities/pledge.cpp +++ b/Userland/Utilities/pledge.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include @@ -13,7 +13,7 @@ static ErrorOr is_dynamically_linked_executable(StringView filename) { - auto maybe_executable = Core::File::resolve_executable_from_environment(filename); + auto maybe_executable = Core::DeprecatedFile::resolve_executable_from_environment(filename); if (!maybe_executable.has_value()) return ENOENT; diff --git a/Userland/Utilities/pro.cpp b/Userland/Utilities/pro.cpp index c02b2660073..0f8b8dda3be 100644 --- a/Userland/Utilities/pro.cpp +++ b/Userland/Utilities/pro.cpp @@ -13,8 +13,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -339,7 +339,7 @@ ErrorOr serenity_main(Main::Arguments arguments) if (i > -1) output_name = DeprecatedString::formatted("{}.{}", output_name, i); ++i; - } while (Core::File::exists(output_name)); + } while (Core::DeprecatedFile::exists(output_name)); } int target_file_fd = open(output_name.characters(), O_WRONLY | O_CREAT | O_TRUNC, 0644); diff --git a/Userland/Utilities/readelf.cpp b/Userland/Utilities/readelf.cpp index 74bb8f9d08c..25d5cc525e6 100644 --- a/Userland/Utilities/readelf.cpp +++ b/Userland/Utilities/readelf.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Utilities/readlink.cpp b/Userland/Utilities/readlink.cpp index f32492676bb..c2d1f095353 100644 --- a/Userland/Utilities/readlink.cpp +++ b/Userland/Utilities/readlink.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include @@ -22,7 +22,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.parse(arguments); for (auto path : paths) { - auto destination = TRY(Core::File::read_link(path)); + auto destination = TRY(Core::DeprecatedFile::read_link(path)); out("{}", destination); if (!no_newline) outln(); diff --git a/Userland/Utilities/rm.cpp b/Userland/Utilities/rm.cpp index 15670ec53d1..e2d026d5f12 100644 --- a/Userland/Utilities/rm.cpp +++ b/Userland/Utilities/rm.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -43,7 +43,7 @@ ErrorOr serenity_main(Main::Arguments arguments) continue; } - auto result = Core::File::remove(path, recursive ? Core::File::RecursionMode::Allowed : Core::File::RecursionMode::Disallowed); + auto result = Core::DeprecatedFile::remove(path, recursive ? Core::DeprecatedFile::RecursionMode::Allowed : Core::DeprecatedFile::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 fa93cfaa466..eefc23b124e 100644 --- a/Userland/Utilities/run-tests.cpp +++ b/Userland/Utilities/run-tests.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -365,12 +365,12 @@ ErrorOr serenity_main(Main::Arguments arguments) } else { test_root = "/usr/Tests"; } - if (!Core::File::is_directory(test_root)) { + if (!Core::DeprecatedFile::is_directory(test_root)) { warnln("Test root is not a directory: {}", test_root); return 1; } - test_root = Core::File::real_path_for(test_root); + test_root = Core::DeprecatedFile::real_path_for(test_root); auto void_or_error = Core::System::chdir(test_root); if (void_or_error.is_error()) { diff --git a/Userland/Utilities/shot.cpp b/Userland/Utilities/shot.cpp index 624fde7921a..3ecbfff3cb3 100644 --- a/Userland/Utilities/shot.cpp +++ b/Userland/Utilities/shot.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -175,7 +175,7 @@ ErrorOr serenity_main(Main::Arguments arguments) bool printed_hyperlink = false; if (isatty(STDOUT_FILENO)) { - auto full_path = Core::File::real_path_for(output_path); + auto full_path = Core::DeprecatedFile::real_path_for(output_path); if (!full_path.is_null()) { char hostname[HOST_NAME_MAX]; VERIFY(gethostname(hostname, sizeof(hostname)) == 0); diff --git a/Userland/Utilities/sql.cpp b/Userland/Utilities/sql.cpp index d4d630cbf2e..9158cc793e9 100644 --- a/Userland/Utilities/sql.cpp +++ b/Userland/Utilities/sql.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -366,7 +366,7 @@ ErrorOr serenity_main(Main::Arguments arguments) SQLRepl repl(loop, database_name, move(sql_client)); - if (!suppress_sqlrc && Core::File::exists(sqlrc_path)) + if (!suppress_sqlrc && Core::DeprecatedFile::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 75fa1ff0fec..c7af3500051 100644 --- a/Userland/Utilities/tar.cpp +++ b/Userland/Utilities/tar.cpp @@ -11,9 +11,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -150,7 +150,7 @@ ErrorOr serenity_main(Main::Arguments arguments) outln("{}", filename); if (extract) { - DeprecatedString absolute_path = Core::File::absolute_path(filename); + DeprecatedString absolute_path = Core::DeprecatedFile::absolute_path(filename); auto parent_path = LexicalPath(absolute_path).parent(); auto header_mode = TRY(header.mode()); @@ -220,7 +220,7 @@ ErrorOr serenity_main(Main::Arguments arguments) Archive::TarOutputStream tar_stream(move(output_stream)); auto add_file = [&](DeprecatedString path) -> ErrorOr { - auto file = Core::File::construct(path); + auto file = Core::DeprecatedFile::construct(path); if (!file->open(Core::OpenMode::ReadOnly)) { warnln("Failed to open {}: {}", path, file->error_string()); return {}; @@ -257,9 +257,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::File::is_link(child_path)) { + if (!dereference && Core::DeprecatedFile::is_link(child_path)) { TRY(add_link(child_path)); - } else if (!Core::File::is_directory(child_path)) { + } else if (!Core::DeprecatedFile::is_directory(child_path)) { TRY(add_file(child_path)); } else { TRY(handle_directory(child_path, handle_directory)); @@ -270,7 +270,7 @@ ErrorOr serenity_main(Main::Arguments arguments) }; for (auto const& path : paths) { - if (Core::File::is_directory(path)) { + if (Core::DeprecatedFile::is_directory(path)) { TRY(add_directory(path, add_directory)); } else { TRY(add_file(path)); diff --git a/Userland/Utilities/test-imap.cpp b/Userland/Utilities/test-imap.cpp index 0bd15559340..2211cf017a1 100644 --- a/Userland/Utilities/test-imap.cpp +++ b/Userland/Utilities/test-imap.cpp @@ -5,8 +5,8 @@ */ #include +#include #include -#include #include #include #include @@ -38,7 +38,7 @@ ErrorOr serenity_main(Main::Arguments arguments) if (interactive_password) { password = TRY(Core::get_password()); } else { - auto standard_input = Core::File::standard_input(); + auto standard_input = Core::DeprecatedFile::standard_input(); password = Core::SecretString::take_ownership(standard_input->read_all()); } diff --git a/Userland/Utilities/touch.cpp b/Userland/Utilities/touch.cpp index 3b8691fcbcb..41ff23113ac 100644 --- a/Userland/Utilities/touch.cpp +++ b/Userland/Utilities/touch.cpp @@ -9,7 +9,7 @@ #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::File::exists(path)) { + if (Core::DeprecatedFile::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/unveil.cpp b/Userland/Utilities/unveil.cpp index ff026d384e5..4683585a870 100644 --- a/Userland/Utilities/unveil.cpp +++ b/Userland/Utilities/unveil.cpp @@ -5,7 +5,6 @@ */ #include -#include #include #include #include diff --git a/Userland/Utilities/unzip.cpp b/Userland/Utilities/unzip.cpp index 3e9c9d3eea5..3014ce503ae 100644 --- a/Userland/Utilities/unzip.cpp +++ b/Userland/Utilities/unzip.cpp @@ -11,8 +11,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -42,7 +42,7 @@ static bool unpack_zip_member(Archive::ZipMember zip_member, bool quiet) return true; } MUST(Core::Directory::create(LexicalPath(zip_member.name.to_deprecated_string()).parent(), Core::Directory::CreateDirectories::Yes)); - auto new_file = Core::File::construct(zip_member.name.to_deprecated_string()); + auto new_file = Core::DeprecatedFile::construct(zip_member.name.to_deprecated_string()); if (!new_file->open(Core::OpenMode::WriteOnly)) { warnln("Can't write file {}: {}", zip_member.name, new_file->error_string()); return false; @@ -94,7 +94,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::File::remove(zip_member.name, Core::File::RecursionMode::Disallowed)); + MUST(Core::DeprecatedFile::remove(zip_member.name, Core::DeprecatedFile::RecursionMode::Disallowed)); return false; } diff --git a/Userland/Utilities/userdel.cpp b/Userland/Utilities/userdel.cpp index 90e56ef845e..a2aa9ae5b23 100644 --- a/Userland/Utilities/userdel.cpp +++ b/Userland/Utilities/userdel.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -47,14 +47,14 @@ ErrorOr serenity_main(Main::Arguments arguments) if (access(target_account.home_directory().characters(), F_OK) == -1) return 0; - auto const real_path = Core::File::real_path_for(target_account.home_directory()); + auto const real_path = Core::DeprecatedFile::real_path_for(target_account.home_directory()); if (real_path == "/") { warnln("home directory is /, not deleted!"); return 12; } - if (auto result = Core::File::remove(real_path, Core::File::RecursionMode::Allowed); result.is_error()) { + if (auto result = Core::DeprecatedFile::remove(real_path, Core::DeprecatedFile::RecursionMode::Allowed); result.is_error()) { warnln("{}", result.release_error()); return 12; } diff --git a/Userland/Utilities/usermod.cpp b/Userland/Utilities/usermod.cpp index 5dce973db0d..534560f9a3b 100644 --- a/Userland/Utilities/usermod.cpp +++ b/Userland/Utilities/usermod.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include @@ -103,11 +103,11 @@ ErrorOr serenity_main(Main::Arguments arguments) auto maybe_error = Core::System::rename(target_account.home_directory(), new_home_directory); if (maybe_error.is_error()) { if (maybe_error.error().code() == EXDEV) { - auto result = Core::File::copy_file_or_directory( + auto result = Core::DeprecatedFile::copy_file_or_directory( new_home_directory, target_account.home_directory().characters(), - Core::File::RecursionMode::Allowed, - Core::File::LinkMode::Disallowed, - Core::File::AddDuplicateFileMarker::No); + Core::DeprecatedFile::RecursionMode::Allowed, + Core::DeprecatedFile::LinkMode::Disallowed, + Core::DeprecatedFile::AddDuplicateFileMarker::No); if (result.is_error()) { warnln("usermod: could not move directory {} : {}", target_account.home_directory().characters(), static_cast(result.error())); diff --git a/Userland/Utilities/wasm.cpp b/Userland/Utilities/wasm.cpp index ae368f5888c..5dababeb101 100644 --- a/Userland/Utilities/wasm.cpp +++ b/Userland/Utilities/wasm.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include #include diff --git a/Userland/Utilities/watch.cpp b/Userland/Utilities/watch.cpp index 9adfbe68c08..b0f30510204 100644 --- a/Userland/Utilities/watch.cpp +++ b/Userland/Utilities/watch.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -163,7 +163,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto file_watcher = Core::BlockingFileWatcher(); for (auto const& file : files_to_watch) { - if (!Core::File::exists(file)) { + if (!Core::DeprecatedFile::exists(file)) { warnln("Cannot watch '{}', it does not exist.", file); return 1; } diff --git a/Userland/Utilities/which.cpp b/Userland/Utilities/which.cpp index 96cceb09586..4403eb5abe0 100644 --- a/Userland/Utilities/which.cpp +++ b/Userland/Utilities/which.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include @@ -20,7 +20,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(filename, "Name of executable", "executable"); args_parser.parse(arguments); - auto fullpath = Core::File::resolve_executable_from_environment({ filename, strlen(filename) }); + auto fullpath = Core::DeprecatedFile::resolve_executable_from_environment({ filename, strlen(filename) }); if (!fullpath.has_value()) { warnln("no '{}' in path", filename); return 1; diff --git a/Userland/Utilities/xml.cpp b/Userland/Utilities/xml.cpp index 6ccd0b9f6d4..7be705dd6ae 100644 --- a/Userland/Utilities/xml.cpp +++ b/Userland/Utilities/xml.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -515,7 +515,7 @@ ErrorOr serenity_main(Main::Arguments arguments) parser.add_positional_argument(filename, "File to read from", "file"); parser.parse(arguments); - s_path = Core::File::real_path_for(filename); + s_path = Core::DeprecatedFile::real_path_for(filename); auto file = TRY(Core::Stream::File::open(s_path, Core::Stream::OpenMode::Read)); auto contents = TRY(file->read_until_eof()); diff --git a/Userland/Utilities/zip.cpp b/Userland/Utilities/zip.cpp index 44d71acef6f..7a9b88deff8 100644 --- a/Userland/Utilities/zip.cpp +++ b/Userland/Utilities/zip.cpp @@ -10,8 +10,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -40,7 +40,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil(nullptr, nullptr)); DeprecatedString zip_file_path { zip_path }; - if (Core::File::exists(zip_file_path)) { + if (Core::DeprecatedFile::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::File::is_link(child_path)) + if (Core::DeprecatedFile::is_link(child_path)) return {}; - if (!Core::File::is_directory(child_path)) { + if (!Core::DeprecatedFile::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::File::is_directory(source_path)) { + if (Core::DeprecatedFile::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());