mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:27:35 +00:00
Everywhere: Use LibFileSystem
where trivial
This commit is contained in:
parent
edab0cbf41
commit
1d24f394c6
115 changed files with 275 additions and 228 deletions
|
@ -54,5 +54,5 @@ set(GENERATED_SOURCES
|
|||
)
|
||||
|
||||
serenity_app(HackStudio ICON app-hack-studio)
|
||||
target_link_libraries(HackStudio PRIVATE LibWebView LibWeb LibMarkdown LibGUI LibCpp LibCMake LibGfx LibCore LibVT LibDebug LibX86 LibDiff LibShell LibSymbolication LibSyntax LibRegex LibSQL LibConfig LibCore LibCoredump LibDesktop LibIPC LibJS LibMain LibThreading)
|
||||
target_link_libraries(HackStudio PRIVATE LibWebView LibWeb LibMarkdown LibGUI LibCpp LibCMake LibGfx LibCore LibVT LibDebug LibX86 LibDiff LibShell LibSymbolication LibSyntax LibRegex LibSQL LibConfig LibCore LibCoredump LibDesktop LibFileSystem LibIPC LibJS LibMain LibThreading)
|
||||
add_dependencies(HackStudio CppLanguageServer)
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibCore/Directory.h>
|
||||
#include <LibFileSystem/FileSystem.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::DeprecatedFile::exists(DeprecatedString::formatted("{}/{}", create_in, candidate)))
|
||||
if (!FileSystem::exists(DeprecatedString::formatted("{}/{}", create_in, candidate)))
|
||||
return candidate;
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ void NewProjectDialog::do_create_project()
|
|||
}
|
||||
|
||||
auto create_in = m_create_in_input->text();
|
||||
if (!Core::DeprecatedFile::exists(create_in) || !Core::DeprecatedFile::is_directory(create_in)) {
|
||||
if (!FileSystem::exists(create_in) || !FileSystem::is_directory(create_in)) {
|
||||
auto result = GUI::MessageBox::show(this, DeprecatedString::formatted("The directory {} does not exist yet, would you like to create it?", create_in), "New project"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
|
||||
if (result != GUI::MessageBox::ExecResult::Yes)
|
||||
return;
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
#include <LibCMake/CMakeCache/SyntaxHighlighter.h>
|
||||
#include <LibCMake/SyntaxHighlighter.h>
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibCpp/SemanticSyntaxHighlighter.h>
|
||||
#include <LibCpp/SyntaxHighlighter.h>
|
||||
#include <LibFileSystem/FileSystem.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/GML/AutocompleteProvider.h>
|
||||
|
@ -424,7 +424,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::DeprecatedFile::is_directory(path)) {
|
||||
if (!FileSystem::is_directory(path)) {
|
||||
auto key = path.substring(base.length() + 1, path.length() - base.length() - 1);
|
||||
dbgln_if(EDITOR_DEBUG, "Adding header \"{}\" in path \"{}\"", key, path);
|
||||
paths.set(key, path);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <LibCore/System.h>
|
||||
#include <LibDebug/DebugSession.h>
|
||||
#include <LibDesktop/Launcher.h>
|
||||
#include <LibFileSystem/FileSystem.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/ActionGroup.h>
|
||||
#include <LibGUI/Application.h>
|
||||
|
@ -311,7 +312,7 @@ bool HackStudioWidget::open_file(DeprecatedString const& full_filename, size_t l
|
|||
if (full_filename.starts_with(project().root_path())) {
|
||||
filename = LexicalPath::relative_path(full_filename, project().root_path());
|
||||
}
|
||||
if (Core::DeprecatedFile::is_directory(filename) || !Core::DeprecatedFile::exists(filename))
|
||||
if (FileSystem::is_directory(filename) || !FileSystem::exists(filename))
|
||||
return false;
|
||||
|
||||
auto editor_wrapper_or_none = m_all_editor_wrappers.first_matching([&](auto& wrapper) {
|
||||
|
@ -533,13 +534,13 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_new_file_action(Dep
|
|||
DeprecatedString filepath;
|
||||
|
||||
if (!path_to_selected.is_empty()) {
|
||||
VERIFY(Core::DeprecatedFile::exists(path_to_selected.first()));
|
||||
VERIFY(FileSystem::exists(path_to_selected.first()));
|
||||
|
||||
LexicalPath selected(path_to_selected.first());
|
||||
|
||||
DeprecatedString dir_path;
|
||||
|
||||
if (Core::DeprecatedFile::is_directory(selected.string()))
|
||||
if (FileSystem::is_directory(selected.string()))
|
||||
dir_path = selected.string();
|
||||
else
|
||||
dir_path = selected.dirname();
|
||||
|
@ -573,7 +574,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_new_directory_actio
|
|||
|
||||
DeprecatedString dir_path;
|
||||
|
||||
if (Core::DeprecatedFile::is_directory(selected.string()))
|
||||
if (FileSystem::is_directory(selected.string()))
|
||||
dir_path = selected.string();
|
||||
else
|
||||
dir_path = selected.dirname();
|
||||
|
@ -681,7 +682,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action()
|
|||
}
|
||||
|
||||
bool is_directory = S_ISDIR(st.st_mode);
|
||||
if (auto result = Core::DeprecatedFile::remove(file, Core::DeprecatedFile::RecursionMode::Allowed); result.is_error()) {
|
||||
if (auto result = FileSystem::remove(file, FileSystem::RecursionMode::Allowed); result.is_error()) {
|
||||
auto& error = result.error();
|
||||
if (is_directory) {
|
||||
GUI::MessageBox::show(window(),
|
||||
|
@ -1001,7 +1002,7 @@ ErrorOr<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::DeprecatedFile::exists(get_project_executable_path())) {
|
||||
if (!FileSystem::exists(get_project_executable_path())) {
|
||||
GUI::MessageBox::show(window(), DeprecatedString::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error"sv, GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
}
|
||||
|
@ -1249,7 +1250,7 @@ void HackStudioWidget::configure_project_tree_view()
|
|||
|
||||
auto selections = m_project_tree_view->selection().indices();
|
||||
auto it = selections.find_if([&](auto selected_file) {
|
||||
return Core::DeprecatedFile::can_delete_or_move(m_project->model().full_path(selected_file));
|
||||
return FileSystem::can_delete_or_move(m_project->model().full_path(selected_file));
|
||||
});
|
||||
bool has_permissions = it != selections.end();
|
||||
m_tree_view_rename_action->set_enabled(has_permissions);
|
||||
|
@ -1794,10 +1795,10 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_open_project_config
|
|||
|
||||
DeprecatedString formatted_error_string_holder;
|
||||
auto save_configuration_or_error = [&]() -> ErrorOr<void> {
|
||||
if (Core::DeprecatedFile::exists(absolute_config_file_path))
|
||||
if (FileSystem::exists(absolute_config_file_path))
|
||||
return {};
|
||||
|
||||
if (Core::DeprecatedFile::exists(parent_directory) && !Core::DeprecatedFile::is_directory(parent_directory)) {
|
||||
if (FileSystem::exists(parent_directory) && !FileSystem::is_directory(parent_directory)) {
|
||||
formatted_error_string_holder = DeprecatedString::formatted("Cannot create the '{}' directory because there is already a file with that name", parent_directory);
|
||||
return Error::from_string_view(formatted_error_string_holder);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "Project.h"
|
||||
#include "HackStudio.h"
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibFileSystem/FileSystem.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::DeprecatedFile::is_directory(root_path))
|
||||
if (!FileSystem::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/DeprecatedFile.h>
|
||||
#include <LibFileSystem/FileSystem.h>
|
||||
#include <LibRegex/Regex.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -124,15 +124,15 @@ ErrorOr<DeprecatedString> ProjectBuilder::component_name(StringView cmake_file_p
|
|||
|
||||
ErrorOr<void> ProjectBuilder::initialize_build_directory()
|
||||
{
|
||||
if (!Core::DeprecatedFile::exists(build_directory())) {
|
||||
if (!FileSystem::exists(build_directory())) {
|
||||
if (mkdir(LexicalPath::join(build_directory()).string().characters(), 0700)) {
|
||||
return Error::from_errno(errno);
|
||||
}
|
||||
}
|
||||
|
||||
auto cmake_file_path = LexicalPath::join(build_directory(), "CMakeLists.txt"sv).string();
|
||||
if (Core::DeprecatedFile::exists(cmake_file_path))
|
||||
MUST(Core::DeprecatedFile::remove(cmake_file_path, Core::DeprecatedFile::RecursionMode::Disallowed));
|
||||
if (FileSystem::exists(cmake_file_path))
|
||||
MUST(FileSystem::remove(cmake_file_path, FileSystem::RecursionMode::Disallowed));
|
||||
|
||||
auto cmake_file = TRY(Core::File::open(cmake_file_path, Core::File::OpenMode::Write));
|
||||
TRY(cmake_file->write_until_depleted(generate_cmake_file_content().bytes()));
|
||||
|
@ -150,7 +150,7 @@ Optional<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::DeprecatedFile::exists(cmake_path.string()))
|
||||
if (FileSystem::exists(cmake_path.string()))
|
||||
return cmake_path.string();
|
||||
directory = LexicalPath::dirname(directory);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibFileSystem/FileSystem.h>
|
||||
#include <fcntl.h>
|
||||
#include <spawn.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -52,7 +53,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::DeprecatedFile::exists(bitmap_path_32)) {
|
||||
if (FileSystem::exists(bitmap_path_32)) {
|
||||
auto bitmap_or_error = Gfx::Bitmap::load_from_file(bitmap_path_32);
|
||||
if (!bitmap_or_error.is_error())
|
||||
icon = GUI::Icon(bitmap_or_error.release_value());
|
||||
|
@ -64,14 +65,14 @@ RefPtr<ProjectTemplate> 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::DeprecatedFile::exists(path))
|
||||
if (FileSystem::exists(path))
|
||||
return DeprecatedString("File or directory already exists at specified location.");
|
||||
|
||||
dbgln("Creating project at path '{}' with name '{}'", path, name);
|
||||
|
||||
// Verify that the template content directory exists. If it does, copy it's contents.
|
||||
// Otherwise, create an empty directory at the project path.
|
||||
if (Core::DeprecatedFile::is_directory(content_path())) {
|
||||
if (FileSystem::is_directory(content_path())) {
|
||||
auto result = Core::DeprecatedFile::copy_file_or_directory(path, content_path());
|
||||
dbgln("Copying {} -> {}", content_path(), path);
|
||||
if (result.is_error())
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibFileSystem/FileSystem.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/Menubar.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
|
@ -140,7 +141,7 @@ static Optional<DeprecatedString> last_opened_project_path()
|
|||
if (projects.size() == 0)
|
||||
return {};
|
||||
|
||||
if (!Core::DeprecatedFile::exists(projects[0]))
|
||||
if (!FileSystem::exists(projects[0]))
|
||||
return {};
|
||||
|
||||
return { projects[0] };
|
||||
|
|
|
@ -24,4 +24,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_app(Profiler ICON app-profiler)
|
||||
target_link_libraries(Profiler PRIVATE LibCore LibDebug LibGfx LibGUI LibDesktop LibX86 LibSymbolication LibMain)
|
||||
target_link_libraries(Profiler PRIVATE LibCore LibDebug LibFileSystem LibGfx LibGUI LibDesktop LibX86 LibSymbolication LibMain)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include "Process.h"
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibFileSystem/FileSystem.h>
|
||||
|
||||
namespace Profiler {
|
||||
|
||||
|
@ -93,7 +93,7 @@ void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, DeprecatedString co
|
|||
DeprecatedString full_path;
|
||||
if (path_string.starts_with('/'))
|
||||
full_path = path_string;
|
||||
else if (Core::DeprecatedFile::looks_like_shared_library(path_string))
|
||||
else if (FileSystem::looks_like_shared_library(path_string))
|
||||
full_path = DeprecatedString::formatted("/usr/lib/{}", path);
|
||||
else
|
||||
full_path = path_string;
|
||||
|
|
|
@ -17,4 +17,4 @@ set(GENERATED_SOURCES
|
|||
)
|
||||
|
||||
serenity_app(SQLStudio ICON app-sql-studio)
|
||||
target_link_libraries(SQLStudio PRIVATE LibCore LibDesktop LibGfx LibGUI LibIPC LibMain LibSQL LibSyntax)
|
||||
target_link_libraries(SQLStudio PRIVATE LibCore LibDesktop LibFileSystem LibGfx LibGUI LibIPC LibMain LibSQL LibSyntax)
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
*/
|
||||
|
||||
#include <DevTools/SQLStudio/SQLStudioGML.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
#include <LibDesktop/Launcher.h>
|
||||
#include <LibFileSystem/FileSystem.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
|
@ -45,7 +45,7 @@ static Vector<DeprecatedString> lookup_database_names()
|
|||
static constexpr auto database_extension = ".db"sv;
|
||||
|
||||
auto database_path = DeprecatedString::formatted("{}/sql", Core::StandardPaths::data_directory());
|
||||
if (!Core::DeprecatedFile::exists(database_path))
|
||||
if (!FileSystem::exists(database_path))
|
||||
return {};
|
||||
|
||||
Core::DirIterator iterator(move(database_path), Core::DirIterator::SkipParentAndBaseDir);
|
||||
|
|
|
@ -23,4 +23,4 @@ set(SOURCES
|
|||
add_compile_options(-mmmx -Wno-psabi -frounding-math)
|
||||
|
||||
serenity_bin(UserspaceEmulator)
|
||||
target_link_libraries(UserspaceEmulator PRIVATE LibX86 LibDebug LibCore LibLine LibSystem)
|
||||
target_link_libraries(UserspaceEmulator PRIVATE LibX86 LibDebug LibCore LibFileSystem LibLine LibSystem)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <LibELF/AuxiliaryVector.h>
|
||||
#include <LibELF/Image.h>
|
||||
#include <LibELF/Validation.h>
|
||||
#include <LibFileSystem/FileSystem.h>
|
||||
#include <LibX86/ELFSymbolProvider.h>
|
||||
#include <fcntl.h>
|
||||
#include <syscall.h>
|
||||
|
@ -423,7 +424,7 @@ MmapRegion const* Emulator::load_library_from_address(FlatPtr address)
|
|||
return {};
|
||||
|
||||
DeprecatedString lib_path = lib_name;
|
||||
if (Core::DeprecatedFile::looks_like_shared_library(lib_name))
|
||||
if (FileSystem::looks_like_shared_library(lib_name))
|
||||
lib_path = DeprecatedString::formatted("/usr/lib/{}", lib_path);
|
||||
|
||||
if (!m_dynamic_library_cache.contains(lib_path)) {
|
||||
|
@ -461,7 +462,7 @@ Optional<Emulator::SymbolInfo> Emulator::symbol_at(FlatPtr address)
|
|||
auto const* first_region = (lib_name.is_null() || lib_name.is_empty()) ? address_region : first_region_for_object(lib_name);
|
||||
VERIFY(first_region);
|
||||
auto lib_path = lib_name;
|
||||
if (Core::DeprecatedFile::looks_like_shared_library(lib_name)) {
|
||||
if (FileSystem::looks_like_shared_library(lib_name)) {
|
||||
lib_path = DeprecatedString::formatted("/usr/lib/{}", lib_name);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue