1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:17: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

@ -12,8 +12,8 @@
#include <AK/ScopedValueRollback.h>
#include <AK/StringBuilder.h>
#include <AK/URL.h>
#include <LibCore/DeprecatedFile.h>
#include <LibCore/EventLoop.h>
#include <LibCore/File.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
@ -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);

View file

@ -12,8 +12,8 @@
#include <AK/ScopeGuard.h>
#include <AK/Statistics.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/DeprecatedFile.h>
#include <LibCore/EventLoop.h>
#include <LibCore/File.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
@ -61,7 +61,7 @@ static Vector<DeprecatedString> 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<DeprecatedString> 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;

View file

@ -19,10 +19,10 @@
#include <AK/StringBuilder.h>
#include <AK/TemporaryChange.h>
#include <AK/URL.h>
#include <LibCore/DeprecatedFile.h>
#include <LibCore/DirIterator.h>
#include <LibCore/Event.h>
#include <LibCore/EventLoop.h>
#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibCore/Timer.h>
@ -220,7 +220,7 @@ Vector<DeprecatedString> 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::RunnablePath> 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<char const*>&& 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<Optional<SourcePosition>> 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;

View file

@ -6,9 +6,9 @@
#include "Shell.h"
#include <LibCore/ArgsParser.h>
#include <LibCore/DeprecatedFile.h>
#include <LibCore/Event.h>
#include <LibCore/EventLoop.h>
#include <LibCore/File.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
#include <signal.h>
@ -183,7 +183,7 @@ ErrorOr<int> 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<int> 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);
}
};