1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 00:57:44 +00:00

LibCore: Rename File to DeprecatedFile

As usual, this removes many unused includes and moves used includes
further down the chain.
This commit is contained in:
Tim Schumacher 2023-02-08 21:08:01 +01:00 committed by Linus Groh
parent 14951b92ca
commit d43a7eae54
193 changed files with 536 additions and 556 deletions

View file

@ -5,7 +5,7 @@
*/
#include <AK/DeprecatedString.h>
#include <LibCore/File.h>
#include <LibCore/DeprecatedFile.h>
#include <LibTest/TestCase.h>
#include <fcntl.h>
#include <stdio.h>
@ -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();

View file

@ -7,7 +7,7 @@
#include <AK/Assertions.h>
#include <AK/Types.h>
#include <LibCore/File.h>
#include <LibCore/DeprecatedFile.h>
#include <LibTest/TestCase.h>
#include <fcntl.h>
#include <stdio.h>
@ -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();

View file

@ -6,7 +6,7 @@
*/
#include <AK/DeprecatedString.h>
#include <LibCore/File.h>
#include <LibCore/DeprecatedFile.h>
#include <LibTest/TestCase.h>
#include <fcntl.h>
#include <stdio.h>
@ -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();

View file

@ -4,14 +4,14 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibCore/File.h>
#include <LibCore/DeprecatedFile.h>
#include <LibTest/TestCase.h>
#include <unistd.h>
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);

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibCore/File.h>
#include <LibCore/DeprecatedFile.h>
#include <LibTest/TestCase.h>
#include <elf.h>
#include <fcntl.h>
@ -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();

View file

@ -13,7 +13,7 @@
#include <AK/QuickSort.h>
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/File.h>
#include <LibCore/DeprecatedFile.h>
#include <LibCore/Process.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
@ -322,7 +322,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
// Normalize the path to ensure filenames are consistent
Vector<DeprecatedString> 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) {

View file

@ -6,8 +6,8 @@
#include <AK/Base64.h>
#include <LibCore/ConfigFile.h>
#include <LibCore/DeprecatedFile.h>
#include <LibCore/EventLoop.h>
#include <LibCore/File.h>
#include <LibCrypto/ASN1/ASN1.h>
#include <LibTLS/TLSv12.h>
#include <LibTest/TestCase.h>
@ -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 "";