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

Everywhere: Use LibFileSystem where trivial

This commit is contained in:
Cameron Youell 2023-03-22 02:35:30 +11:00 committed by Linus Groh
parent edab0cbf41
commit 1d24f394c6
115 changed files with 275 additions and 228 deletions

View file

@ -10,4 +10,4 @@ set(SOURCES
)
serenity_bin(SystemServer)
target_link_libraries(SystemServer PRIVATE LibCore LibMain)
target_link_libraries(SystemServer PRIVATE LibCore LibFileSystem LibMain)

View file

@ -12,11 +12,11 @@
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <LibCore/ConfigFile.h>
#include <LibCore/DeprecatedFile.h>
#include <LibCore/Directory.h>
#include <LibCore/SessionManagement.h>
#include <LibCore/SocketAddress.h>
#include <LibCore/System.h>
#include <LibFileSystem/FileSystem.h>
#include <fcntl.h>
#include <sched.h>
#include <stdio.h>
@ -123,7 +123,7 @@ ErrorOr<void> Service::activate()
ErrorOr<void> Service::spawn(int socket_fd)
{
if (!Core::DeprecatedFile::exists(m_executable_path)) {
if (!FileSystem::exists(m_executable_path)) {
dbgln("{}: binary \"{}\" does not exist, skipping service.", name(), m_executable_path);
return Error::from_errno(ENOENT);
}

View file

@ -28,5 +28,5 @@ set(GENERATED_SOURCES
)
serenity_bin(WebContent)
target_link_libraries(WebContent PRIVATE LibCore LibIPC LibGfx LibImageDecoderClient LibJS LibWebView LibWeb LibLocale LibMain)
target_link_libraries(WebContent PRIVATE LibCore LibFileSystem LibIPC LibGfx LibImageDecoderClient LibJS LibWebView LibWeb LibLocale LibMain)
link_with_locale_data(WebContent)

View file

@ -5,11 +5,11 @@
*/
#include "ImageCodecPluginSerenity.h"
#include <LibCore/DeprecatedFile.h>
#include <LibCore/EventLoop.h>
#include <LibCore/LocalServer.h>
#include <LibCore/StandardPaths.h>
#include <LibCore/System.h>
#include <LibFileSystem/FileSystem.h>
#include <LibIPC/SingleServer.h>
#include <LibMain/Main.h>
#include <LibWeb/Bindings/MainThreadVM.h>
@ -29,7 +29,7 @@ ErrorOr<int> 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::DeprecatedFile::exists(webdriver_socket_path))
if (FileSystem::exists(webdriver_socket_path))
TRY(Core::System::unveil(webdriver_socket_path, "rw"sv));
TRY(Core::System::unveil("/res", "r"));

View file

@ -10,4 +10,4 @@ set(SOURCES
)
serenity_bin(WebServer)
target_link_libraries(WebServer PRIVATE LibCore LibHTTP LibMain)
target_link_libraries(WebServer PRIVATE LibCore LibFileSystem LibHTTP LibMain)

View file

@ -19,6 +19,7 @@
#include <LibCore/File.h>
#include <LibCore/MappedFile.h>
#include <LibCore/MimeData.h>
#include <LibFileSystem/FileSystem.h>
#include <LibHTTP/HttpRequest.h>
#include <LibHTTP/HttpResponse.h>
#include <WebServer/Client.h>
@ -133,7 +134,7 @@ ErrorOr<bool> Client::handle_request(ReadonlyBytes raw_request)
path_builder.append(requested_path);
auto real_path = TRY(path_builder.to_string());
if (Core::DeprecatedFile::is_directory(real_path.bytes_as_string_view())) {
if (FileSystem::is_directory(real_path.bytes_as_string_view())) {
if (!resource_decoded.ends_with('/')) {
StringBuilder red;
@ -148,7 +149,7 @@ ErrorOr<bool> 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::DeprecatedFile::exists(index_html_path)) {
if (!FileSystem::exists(index_html_path)) {
TRY(handle_directory_listing(requested_path, real_path, request));
return true;
}
@ -170,7 +171,7 @@ ErrorOr<bool> Client::handle_request(ReadonlyBytes raw_request)
auto const info = ContentInfo {
.type = TRY(String::from_utf8(Core::guess_mime_type_based_on_filename(real_path.bytes_as_string_view()))),
.length = TRY(Core::DeprecatedFile::size(real_path.bytes_as_string_view()))
.length = TRY(FileSystem::size(real_path.bytes_as_string_view()))
};
TRY(send_response(*stream, request, move(info)));
return true;

View file

@ -13,6 +13,7 @@
#include <LibCore/MappedFile.h>
#include <LibCore/System.h>
#include <LibCore/TCPServer.h>
#include <LibFileSystem/FileSystem.h>
#include <LibHTTP/HttpRequest.h>
#include <LibMain/Main.h>
#include <WebServer/Client.h>
@ -57,7 +58,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
auto real_document_root_path = Core::DeprecatedFile::real_path_for(document_root_path);
if (!Core::DeprecatedFile::exists(real_document_root_path)) {
if (!FileSystem::exists(real_document_root_path)) {
warnln("Root path does not exist: '{}'", document_root_path);
return 1;
}

View file

@ -45,5 +45,5 @@ set(GENERATED_SOURCES
)
serenity_bin(WindowServer)
target_link_libraries(WindowServer PRIVATE LibCore LibGfx LibThreading LibIPC LibMain)
target_link_libraries(WindowServer PRIVATE LibCore LibFileSystem LibGfx LibThreading LibIPC LibMain)
serenity_install_headers(Services/WindowServer)

View file

@ -11,9 +11,9 @@
#include "WindowManager.h"
#include <Kernel/API/Graphics.h>
#include <LibCore/ConfigFile.h>
#include <LibCore/DeprecatedFile.h>
#include <LibCore/DirIterator.h>
#include <LibCore/System.h>
#include <LibFileSystem/FileSystem.h>
#include <LibGfx/Palette.h>
#include <LibGfx/SystemTheme.h>
#include <LibMain/Main.h>
@ -89,7 +89,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
if (!path.starts_with("connector"sv))
continue;
auto full_path = DeprecatedString::formatted("/dev/gpu/{}", path);
if (!Core::DeprecatedFile::is_device(full_path))
if (!FileSystem::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)