mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:57:35 +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:
parent
14951b92ca
commit
d43a7eae54
193 changed files with 536 additions and 556 deletions
|
@ -12,8 +12,8 @@
|
|||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibCore/Directory.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Button.h>
|
||||
#include <LibGUI/FilePicker.h>
|
||||
|
@ -150,7 +150,7 @@ Optional<DeprecatedString> 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;
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
#include <AK/JsonParser.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibCpp/SemanticSyntaxHighlighter.h>
|
||||
|
@ -420,7 +420,7 @@ static HashMap<DeprecatedString, DeprecatedString>& 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);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "GitWidget.h"
|
||||
#include "../Dialogs/Git/GitCommitDialog.h"
|
||||
#include "GitFilesModel.h"
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibDiff/Format.h>
|
||||
#include <LibGUI/Application.h>
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
#include <AK/StringBuilder.h>
|
||||
#include <Kernel/API/InodeWatcherEvent.h>
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibCore/Event.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/FileWatcher.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibDebug/DebugSession.h>
|
||||
|
@ -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<NonnullRefPtr<GUI::Action>> 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<NonnullRefPtr<GUI::Action>> 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<GUI::Action> 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<GUI::Action> HackStudioWidget::create_save_as_action()
|
|||
Optional<DeprecatedString> 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<NonnullRefPtr<GUI::Action>> 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<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_open_project_config
|
|||
|
||||
DeprecatedString formatted_error_string_holder;
|
||||
auto save_configuration_or_error = [&]() -> ErrorOr<void> {
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "ConnectionFromClient.h"
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibGUI/TextDocument.h>
|
||||
|
||||
namespace LanguageServers {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "Project.h"
|
||||
#include "HackStudio.h"
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
|
||||
namespace HackStudio {
|
||||
|
||||
|
@ -18,7 +18,7 @@ Project::Project(DeprecatedString const& root_path)
|
|||
|
||||
OwnPtr<Project> 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));
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "ProjectBuilder.h"
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/Command.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibRegex/Regex.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -125,15 +125,15 @@ ErrorOr<DeprecatedString> ProjectBuilder::component_name(StringView cmake_file_p
|
|||
|
||||
ErrorOr<void> 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<DeprecatedString> 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);
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
#include <AK/LexicalPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <fcntl.h>
|
||||
#include <spawn.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -52,7 +52,7 @@ RefPtr<ProjectTemplate> 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> ProjectTemplate::load_from_manifest(DeprecatedString con
|
|||
Result<void, DeprecatedString> 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<Error const&>(result.error()));
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <AK/StringBuilder.h>
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/Menubar.h>
|
||||
|
@ -60,9 +60,9 @@ ErrorOr<int> 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<DeprecatedString> 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] };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue