summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applets/Network/main.cpp3
-rw-r--r--Userland/Applets/ResourceGraph/main.cpp10
-rw-r--r--Userland/Applications/Browser/BrowserWindow.cpp4
-rw-r--r--Userland/Applications/Browser/DownloadWidget.cpp2
-rw-r--r--Userland/Applications/Browser/DownloadWidget.h2
-rw-r--r--Userland/Applications/Browser/main.cpp4
-rw-r--r--Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp6
-rw-r--r--Userland/Applications/DisplaySettings/ThemePreviewWidget.cpp2
-rw-r--r--Userland/Applications/FileManager/FileOperationProgressWidget.cpp2
-rw-r--r--Userland/Applications/FileManager/FileOperationProgressWidget.h5
-rw-r--r--Userland/Applications/FileManager/FileUtils.cpp4
-rw-r--r--Userland/Applications/HexEditor/HexDocument.cpp13
-rw-r--r--Userland/Applications/HexEditor/HexDocument.h14
-rw-r--r--Userland/Applications/HexEditor/HexEditor.cpp4
-rw-r--r--Userland/Applications/HexEditor/HexEditor.h4
-rw-r--r--Userland/Applications/HexEditor/HexEditorWidget.cpp8
-rw-r--r--Userland/Applications/HexEditor/HexEditorWidget.h2
-rw-r--r--Userland/Applications/HexEditor/main.cpp2
-rw-r--r--Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp3
-rw-r--r--Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp2
-rw-r--r--Userland/Applications/PDFViewer/PDFViewerWidget.cpp4
-rw-r--r--Userland/Applications/PDFViewer/PDFViewerWidget.h4
-rw-r--r--Userland/Applications/PixelPaint/ImageEditor.cpp4
-rw-r--r--Userland/Applications/PixelPaint/ImageEditor.h2
-rw-r--r--Userland/Applications/PixelPaint/MainWidget.cpp2
-rw-r--r--Userland/Applications/PixelPaint/PaletteWidget.cpp8
-rw-r--r--Userland/Applications/PixelPaint/PaletteWidget.h4
-rw-r--r--Userland/Applications/PixelPaint/ProjectLoader.cpp2
-rw-r--r--Userland/Applications/PixelPaint/ProjectLoader.h2
-rw-r--r--Userland/Applications/Presenter/Presentation.cpp3
-rw-r--r--Userland/Applications/Run/RunWindow.cpp6
-rw-r--r--Userland/Applications/SoundPlayer/M3UParser.cpp3
-rw-r--r--Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp2
-rw-r--r--Userland/Applications/Spreadsheet/ExportDialog.cpp2
-rw-r--r--Userland/Applications/Spreadsheet/ExportDialog.h2
-rw-r--r--Userland/Applications/Spreadsheet/ImportDialog.cpp2
-rw-r--r--Userland/Applications/Spreadsheet/ImportDialog.h2
-rw-r--r--Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp8
-rw-r--r--Userland/Applications/Spreadsheet/SpreadsheetWidget.h6
-rw-r--r--Userland/Applications/Spreadsheet/Workbook.cpp6
-rw-r--r--Userland/Applications/Spreadsheet/Workbook.h6
-rw-r--r--Userland/Applications/SystemMonitor/ProcessModel.cpp2
-rw-r--r--Userland/Applications/TextEditor/MainWidget.cpp4
-rw-r--r--Userland/Applications/TextEditor/MainWidget.h2
-rw-r--r--Userland/Applications/ThemeEditor/MainWidget.cpp12
-rw-r--r--Userland/Applications/ThemeEditor/MainWidget.h4
-rw-r--r--Userland/Applications/Welcome/WelcomeWidget.cpp4
-rw-r--r--Userland/Demos/CatDog/CatDog.cpp3
-rw-r--r--Userland/Demos/CatDog/CatDog.h2
-rw-r--r--Userland/DevTools/GMLPlayground/main.cpp2
-rw-r--r--Userland/DevTools/HackStudio/Editor.cpp2
-rw-r--r--Userland/DevTools/HackStudio/Git/GitWidget.cpp2
-rw-r--r--Userland/DevTools/HackStudio/HackStudioWidget.cpp4
-rw-r--r--Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp7
-rw-r--r--Userland/DevTools/HackStudio/LanguageServers/FileDB.h2
-rw-r--r--Userland/DevTools/HackStudio/ProjectBuilder.cpp4
-rw-r--r--Userland/DevTools/HackStudio/ProjectConfig.cpp3
-rw-r--r--Userland/DevTools/HackStudio/ProjectFile.cpp3
-rw-r--r--Userland/DevTools/Profiler/Profile.cpp2
-rw-r--r--Userland/DevTools/Profiler/SourceModel.cpp4
-rw-r--r--Userland/DevTools/SQLStudio/ScriptEditor.cpp4
-rw-r--r--Userland/DevTools/UserspaceEmulator/main.cpp2
-rw-r--r--Userland/Games/Chess/ChessWidget.cpp5
-rw-r--r--Userland/Games/Chess/ChessWidget.h4
-rw-r--r--Userland/Games/MasterWord/WordGame.cpp4
-rw-r--r--Userland/Libraries/LibAudio/FlacLoader.cpp3
-rw-r--r--Userland/Libraries/LibAudio/MP3Loader.cpp3
-rw-r--r--Userland/Libraries/LibAudio/WavLoader.cpp3
-rw-r--r--Userland/Libraries/LibCore/CMakeLists.txt2
-rw-r--r--Userland/Libraries/LibCore/ConfigFile.cpp14
-rw-r--r--Userland/Libraries/LibCore/ConfigFile.h7
-rw-r--r--Userland/Libraries/LibCore/DeprecatedFile.h2
-rw-r--r--Userland/Libraries/LibCore/Directory.cpp6
-rw-r--r--Userland/Libraries/LibCore/Directory.h3
-rw-r--r--Userland/Libraries/LibCore/File.cpp (renamed from Userland/Libraries/LibCore/Stream.cpp)16
-rw-r--r--Userland/Libraries/LibCore/File.h108
-rw-r--r--Userland/Libraries/LibCore/Forward.h5
-rw-r--r--Userland/Libraries/LibCore/ProcessStatisticsReader.cpp3
-rw-r--r--Userland/Libraries/LibCore/Stream.h95
-rw-r--r--Userland/Libraries/LibFileSystemAccessClient/Client.cpp26
-rw-r--r--Userland/Libraries/LibFileSystemAccessClient/Client.h14
-rw-r--r--Userland/Libraries/LibGUI/AbstractThemePreview.cpp2
-rw-r--r--Userland/Libraries/LibGUI/AbstractThemePreview.h2
-rw-r--r--Userland/Libraries/LibGUI/CommonLocationsProvider.cpp3
-rw-r--r--Userland/Libraries/LibGUI/TextEditor.cpp4
-rw-r--r--Userland/Libraries/LibGUI/TextEditor.h2
-rw-r--r--Userland/Libraries/LibGfx/Font/BitmapFont.cpp3
-rw-r--r--Userland/Libraries/LibIDL/IDLParser.cpp3
-rw-r--r--Userland/Libraries/LibIPC/File.h3
-rw-r--r--Userland/Libraries/LibLine/Editor.cpp14
-rw-r--r--Userland/Libraries/LibLine/InternalFunctions.cpp9
-rw-r--r--Userland/Libraries/LibLine/XtermSuggestionDisplay.cpp5
-rw-r--r--Userland/Libraries/LibProtocol/Request.cpp2
-rw-r--r--Userland/Libraries/LibSQL/Heap.cpp4
-rw-r--r--Userland/Libraries/LibSQL/Heap.h3
-rw-r--r--Userland/Libraries/LibSQL/SQLClient.cpp4
-rw-r--r--Userland/Libraries/LibTLS/HandshakeClient.cpp2
-rw-r--r--Userland/Libraries/LibTest/JavaScriptTestRunner.h3
-rw-r--r--Userland/Libraries/LibVirtGPU/Device.cpp5
-rw-r--r--Userland/Libraries/LibVirtGPU/Device.h4
-rw-r--r--Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp2
-rw-r--r--Userland/Services/FileOperation/main.cpp9
-rw-r--r--Userland/Services/FileSystemAccessServer/ConnectionFromClient.cpp36
-rw-r--r--Userland/Services/FileSystemAccessServer/ConnectionFromClient.h12
-rw-r--r--Userland/Services/FileSystemAccessServer/FileSystemAccessServer.ipc6
-rw-r--r--Userland/Services/NetworkServer/main.cpp2
-rw-r--r--Userland/Services/RequestServer/GeminiProtocol.cpp2
-rw-r--r--Userland/Services/RequestServer/GeminiRequest.cpp4
-rw-r--r--Userland/Services/RequestServer/GeminiRequest.h4
-rw-r--r--Userland/Services/RequestServer/HttpCommon.h2
-rw-r--r--Userland/Services/RequestServer/HttpRequest.cpp4
-rw-r--r--Userland/Services/RequestServer/HttpRequest.h4
-rw-r--r--Userland/Services/RequestServer/HttpsRequest.cpp4
-rw-r--r--Userland/Services/RequestServer/HttpsRequest.h4
-rw-r--r--Userland/Services/RequestServer/Request.cpp2
-rw-r--r--Userland/Services/RequestServer/Request.h6
-rw-r--r--Userland/Services/WebServer/Client.cpp3
-rw-r--r--Userland/Utilities/arp.cpp3
-rw-r--r--Userland/Utilities/base64.cpp3
-rw-r--r--Userland/Utilities/cat.cpp5
-rw-r--r--Userland/Utilities/checksum.cpp5
-rw-r--r--Userland/Utilities/cksum.cpp3
-rw-r--r--Userland/Utilities/cmp.cpp11
-rw-r--r--Userland/Utilities/comm.cpp9
-rw-r--r--Userland/Utilities/copy.cpp3
-rw-r--r--Userland/Utilities/cpp-lexer.cpp3
-rw-r--r--Userland/Utilities/cpp-parser.cpp3
-rw-r--r--Userland/Utilities/cpp-preprocessor.cpp3
-rw-r--r--Userland/Utilities/df.cpp3
-rw-r--r--Userland/Utilities/diff.cpp5
-rw-r--r--Userland/Utilities/dmesg.cpp3
-rw-r--r--Userland/Utilities/du.cpp3
-rw-r--r--Userland/Utilities/file.cpp3
-rw-r--r--Userland/Utilities/fortune.cpp3
-rw-r--r--Userland/Utilities/gml-format.cpp5
-rw-r--r--Userland/Utilities/grep.cpp5
-rw-r--r--Userland/Utilities/gron.cpp3
-rw-r--r--Userland/Utilities/gunzip.cpp7
-rw-r--r--Userland/Utilities/gzip.cpp3
-rw-r--r--Userland/Utilities/headless-browser.cpp2
-rw-r--r--Userland/Utilities/hexdump.cpp3
-rw-r--r--Userland/Utilities/ifconfig.cpp3
-rw-r--r--Userland/Utilities/js.cpp10
-rw-r--r--Userland/Utilities/json.cpp3
-rw-r--r--Userland/Utilities/lsblk.cpp7
-rw-r--r--Userland/Utilities/lscpu.cpp3
-rw-r--r--Userland/Utilities/lsirq.cpp3
-rw-r--r--Userland/Utilities/lsjails.cpp3
-rw-r--r--Userland/Utilities/lsof.cpp3
-rw-r--r--Userland/Utilities/lspci.cpp13
-rw-r--r--Userland/Utilities/lsusb.cpp3
-rw-r--r--Userland/Utilities/man.cpp3
-rw-r--r--Userland/Utilities/markdown-check.cpp3
-rw-r--r--Userland/Utilities/md.cpp3
-rw-r--r--Userland/Utilities/mount.cpp7
-rw-r--r--Userland/Utilities/netstat.cpp5
-rw-r--r--Userland/Utilities/nologin.cpp3
-rw-r--r--Userland/Utilities/nproc.cpp3
-rw-r--r--Userland/Utilities/pmap.cpp3
-rw-r--r--Userland/Utilities/pro.cpp2
-rw-r--r--Userland/Utilities/reboot.cpp3
-rw-r--r--Userland/Utilities/route.cpp3
-rw-r--r--Userland/Utilities/sed.cpp9
-rw-r--r--Userland/Utilities/shot.cpp2
-rw-r--r--Userland/Utilities/shuf.cpp3
-rw-r--r--Userland/Utilities/shutdown.cpp3
-rw-r--r--Userland/Utilities/sort.cpp5
-rw-r--r--Userland/Utilities/sql.cpp6
-rw-r--r--Userland/Utilities/strace.cpp5
-rw-r--r--Userland/Utilities/strings.cpp3
-rw-r--r--Userland/Utilities/sysctl.cpp5
-rw-r--r--Userland/Utilities/tail.cpp7
-rw-r--r--Userland/Utilities/tar.cpp6
-rw-r--r--Userland/Utilities/test-fuzz.cpp3
-rw-r--r--Userland/Utilities/tsort.cpp3
-rw-r--r--Userland/Utilities/uniq.cpp7
-rw-r--r--Userland/Utilities/uptime.cpp3
-rw-r--r--Userland/Utilities/utmpupdate.cpp3
-rw-r--r--Userland/Utilities/w.cpp3
-rw-r--r--Userland/Utilities/wasm.cpp3
-rw-r--r--Userland/Utilities/xml.cpp9
-rw-r--r--Userland/Utilities/zip.cpp5
182 files changed, 562 insertions, 475 deletions
diff --git a/Userland/Applets/Network/main.cpp b/Userland/Applets/Network/main.cpp
index db637627ec..88d6646298 100644
--- a/Userland/Applets/Network/main.cpp
+++ b/Userland/Applets/Network/main.cpp
@@ -6,6 +6,7 @@
*/
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibGUI/Action.h>
@@ -107,7 +108,7 @@ private:
{
StringBuilder adapter_info;
- auto file_or_error = Core::Stream::File::open("/sys/kernel/net/adapters"sv, Core::Stream::OpenMode::Read);
+ auto file_or_error = Core::File::open("/sys/kernel/net/adapters"sv, Core::File::OpenMode::Read);
if (file_or_error.is_error()) {
dbgln("Error: Could not open /sys/kernel/net/adapters: {}", file_or_error.error());
return "";
diff --git a/Userland/Applets/ResourceGraph/main.cpp b/Userland/Applets/ResourceGraph/main.cpp
index 8ba289d937..2716c2ad96 100644
--- a/Userland/Applets/ResourceGraph/main.cpp
+++ b/Userland/Applets/ResourceGraph/main.cpp
@@ -144,13 +144,13 @@ private:
GUI::Process::spawn_or_show_error(window(), "/bin/SystemMonitor"sv, Array { "-t", m_graph_type == GraphType::Network ? "network" : "graphs" });
}
- ErrorOr<JsonValue> get_data_as_json(OwnPtr<Core::Stream::File>& file, StringView filename)
+ ErrorOr<JsonValue> get_data_as_json(OwnPtr<Core::File>& file, StringView filename)
{
if (file) {
// Seeking to the beginning causes a data refresh!
TRY(file->seek(0, SeekMode::SetPosition));
} else {
- file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Read));
+ file = TRY(Core::File::open(filename, Core::File::OpenMode::Read));
}
auto file_contents = TRY(file->read_until_eof());
@@ -231,9 +231,9 @@ private:
static constexpr u64 const scale_unit = 8000;
u64 m_current_scale { scale_unit };
DeprecatedString m_tooltip;
- OwnPtr<Core::Stream::File> m_proc_stat;
- OwnPtr<Core::Stream::File> m_proc_mem;
- OwnPtr<Core::Stream::File> m_proc_net;
+ OwnPtr<Core::File> m_proc_stat;
+ OwnPtr<Core::File> m_proc_mem;
+ OwnPtr<Core::File> m_proc_net;
};
ErrorOr<int> serenity_main(Main::Arguments arguments)
diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp
index 46931066ea..1f73a045e9 100644
--- a/Userland/Applications/Browser/BrowserWindow.cpp
+++ b/Userland/Applications/Browser/BrowserWindow.cpp
@@ -488,7 +488,7 @@ ErrorOr<void> BrowserWindow::load_search_engines(GUI::Menu& settings_menu)
m_search_engine_actions.add_action(*m_disable_search_engine_action);
m_disable_search_engine_action->set_checked(true);
- auto search_engines_file = TRY(Core::Stream::File::open(Browser::search_engines_file_path(), Core::Stream::OpenMode::Read));
+ auto search_engines_file = TRY(Core::File::open(Browser::search_engines_file_path(), Core::File::OpenMode::Read));
auto file_size = TRY(search_engines_file->size());
auto buffer = TRY(ByteBuffer::create_uninitialized(file_size));
if (!search_engines_file->read_entire_buffer(buffer).is_error()) {
@@ -775,7 +775,7 @@ ErrorOr<void> BrowserWindow::take_screenshot(ScreenshotType type)
auto encoded = TRY(Gfx::PNGWriter::encode(*bitmap.bitmap()));
- auto screenshot_file = TRY(Core::Stream::File::open(path.string(), Core::Stream::OpenMode::Write));
+ auto screenshot_file = TRY(Core::File::open(path.string(), Core::File::OpenMode::Write));
TRY(screenshot_file->write(encoded));
return {};
diff --git a/Userland/Applications/Browser/DownloadWidget.cpp b/Userland/Applications/Browser/DownloadWidget.cpp
index db3a1fab8d..ab6023cf71 100644
--- a/Userland/Applications/Browser/DownloadWidget.cpp
+++ b/Userland/Applications/Browser/DownloadWidget.cpp
@@ -47,7 +47,7 @@ DownloadWidget::DownloadWidget(const URL& url)
};
{
- auto file_or_error = Core::Stream::File::open(m_destination_path, Core::Stream::OpenMode::Write);
+ auto file_or_error = Core::File::open(m_destination_path, Core::File::OpenMode::Write);
if (file_or_error.is_error()) {
GUI::MessageBox::show(window(), DeprecatedString::formatted("Cannot open {} for writing", m_destination_path), "Download failed"sv, GUI::MessageBox::Type::Error);
window()->close();
diff --git a/Userland/Applications/Browser/DownloadWidget.h b/Userland/Applications/Browser/DownloadWidget.h
index 176d818d87..f60fc94108 100644
--- a/Userland/Applications/Browser/DownloadWidget.h
+++ b/Userland/Applications/Browser/DownloadWidget.h
@@ -38,7 +38,7 @@ private:
RefPtr<GUI::Button> m_close_button;
RefPtr<GUI::CheckBox> m_close_on_finish_checkbox;
RefPtr<GUI::ImageWidget> m_browser_image;
- OwnPtr<Core::Stream::File> m_output_file_stream;
+ OwnPtr<Core::File> m_output_file_stream;
Core::ElapsedTimer m_elapsed_timer;
};
diff --git a/Userland/Applications/Browser/main.cpp b/Userland/Applications/Browser/main.cpp
index b094e44e0f..049be3a54b 100644
--- a/Userland/Applications/Browser/main.cpp
+++ b/Userland/Applications/Browser/main.cpp
@@ -45,8 +45,8 @@ DeprecatedString g_webdriver_content_ipc_path;
static ErrorOr<void> load_content_filters()
{
- auto file = TRY(Core::Stream::File::open(DeprecatedString::formatted("{}/BrowserContentFilters.txt", Core::StandardPaths::config_directory()), Core::Stream::OpenMode::Read));
- auto ad_filter_list = TRY(Core::Stream::BufferedFile::create(move(file)));
+ auto file = TRY(Core::File::open(DeprecatedString::formatted("{}/BrowserContentFilters.txt", Core::StandardPaths::config_directory()), Core::File::OpenMode::Read));
+ auto ad_filter_list = TRY(Core::BufferedFile::create(move(file)));
auto buffer = TRY(ByteBuffer::create_uninitialized(4096));
while (TRY(ad_filter_list->can_read_line())) {
auto line = TRY(ad_filter_list->read_line(buffer));
diff --git a/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp b/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp
index da568273fa..17f44bf3a9 100644
--- a/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp
+++ b/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp
@@ -28,8 +28,8 @@ static DeprecatedString filter_list_file_path()
ErrorOr<void> DomainListModel::load()
{
// FIXME: This should be somewhat shared with Browser.
- auto file = TRY(Core::Stream::File::open(filter_list_file_path(), Core::Stream::OpenMode::Read));
- auto content_filter_list = TRY(Core::Stream::BufferedFile::create(move(file)));
+ auto file = TRY(Core::File::open(filter_list_file_path(), Core::File::OpenMode::Read));
+ auto content_filter_list = TRY(Core::BufferedFile::create(move(file)));
auto buffer = TRY(ByteBuffer::create_uninitialized(4096));
while (TRY(content_filter_list->can_read_line())) {
auto line = TRY(content_filter_list->read_line(buffer));
@@ -50,7 +50,7 @@ ErrorOr<void> DomainListModel::save()
for (auto const& domain : m_domain_list)
TRY(builder.try_appendff("{}\n", domain));
- auto file = TRY(Core::Stream::File::open(filter_list_file_path(), Core::Stream::OpenMode::Write));
+ auto file = TRY(Core::File::open(filter_list_file_path(), Core::File::OpenMode::Write));
TRY(file->write(builder.to_byte_buffer().bytes()));
return {};
}
diff --git a/Userland/Applications/DisplaySettings/ThemePreviewWidget.cpp b/Userland/Applications/DisplaySettings/ThemePreviewWidget.cpp
index 35abe94a03..7969cd7554 100644
--- a/Userland/Applications/DisplaySettings/ThemePreviewWidget.cpp
+++ b/Userland/Applications/DisplaySettings/ThemePreviewWidget.cpp
@@ -20,7 +20,7 @@ ThemePreviewWidget::ThemePreviewWidget(Gfx::Palette const& palette)
ErrorOr<void> ThemePreviewWidget::set_theme(DeprecatedString path)
{
- auto config_file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
+ auto config_file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
TRY(set_theme_from_file(path, move(config_file)));
return {};
}
diff --git a/Userland/Applications/FileManager/FileOperationProgressWidget.cpp b/Userland/Applications/FileManager/FileOperationProgressWidget.cpp
index a185c4e58e..90613a0be0 100644
--- a/Userland/Applications/FileManager/FileOperationProgressWidget.cpp
+++ b/Userland/Applications/FileManager/FileOperationProgressWidget.cpp
@@ -18,7 +18,7 @@
namespace FileManager {
-FileOperationProgressWidget::FileOperationProgressWidget(FileOperation operation, NonnullOwnPtr<Core::Stream::BufferedFile> helper_pipe, int helper_pipe_fd)
+FileOperationProgressWidget::FileOperationProgressWidget(FileOperation operation, NonnullOwnPtr<Core::BufferedFile> helper_pipe, int helper_pipe_fd)
: m_operation(operation)
, m_helper_pipe(move(helper_pipe))
{
diff --git a/Userland/Applications/FileManager/FileOperationProgressWidget.h b/Userland/Applications/FileManager/FileOperationProgressWidget.h
index 1fc7366f5e..907edd12f5 100644
--- a/Userland/Applications/FileManager/FileOperationProgressWidget.h
+++ b/Userland/Applications/FileManager/FileOperationProgressWidget.h
@@ -8,6 +8,7 @@
#include "FileUtils.h"
#include <LibCore/ElapsedTimer.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibGUI/Widget.h>
@@ -21,7 +22,7 @@ public:
private:
// FIXME: The helper_pipe_fd parameter is only needed because we can't get the fd from a Core::Stream.
- FileOperationProgressWidget(FileOperation, NonnullOwnPtr<Core::Stream::BufferedFile> helper_pipe, int helper_pipe_fd);
+ FileOperationProgressWidget(FileOperation, NonnullOwnPtr<Core::BufferedFile> helper_pipe, int helper_pipe_fd);
void did_finish();
void did_error(StringView message);
@@ -34,6 +35,6 @@ private:
FileOperation m_operation;
RefPtr<Core::Notifier> m_notifier;
- OwnPtr<Core::Stream::BufferedFile> m_helper_pipe;
+ OwnPtr<Core::BufferedFile> m_helper_pipe;
};
}
diff --git a/Userland/Applications/FileManager/FileUtils.cpp b/Userland/Applications/FileManager/FileUtils.cpp
index c25b0457a8..0f5c3c423f 100644
--- a/Userland/Applications/FileManager/FileUtils.cpp
+++ b/Userland/Applications/FileManager/FileUtils.cpp
@@ -99,8 +99,8 @@ ErrorOr<void> run_file_operation(FileOperation operation, Vector<DeprecatedStrin
VERIFY_NOT_REACHED();
}
- auto pipe_input_file = TRY(Core::Stream::File::adopt_fd(pipe_fds[0], Core::Stream::OpenMode::Read));
- auto buffered_pipe = TRY(Core::Stream::BufferedFile::create(move(pipe_input_file)));
+ auto pipe_input_file = TRY(Core::File::adopt_fd(pipe_fds[0], Core::File::OpenMode::Read));
+ auto buffered_pipe = TRY(Core::BufferedFile::create(move(pipe_input_file)));
(void)TRY(window->set_main_widget<FileOperationProgressWidget>(operation, move(buffered_pipe), pipe_fds[0]));
window->resize(320, 190);
diff --git a/Userland/Applications/HexEditor/HexDocument.cpp b/Userland/Applications/HexEditor/HexDocument.cpp
index e7e49c6c19..064ca93f91 100644
--- a/Userland/Applications/HexEditor/HexDocument.cpp
+++ b/Userland/Applications/HexEditor/HexDocument.cpp
@@ -5,6 +5,7 @@
*/
#include "HexDocument.h"
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
void HexDocument::set(size_t position, u8 value)
@@ -58,7 +59,7 @@ void HexDocumentMemory::clear_changes()
m_changes.clear();
}
-ErrorOr<void> HexDocumentMemory::write_to_file(Core::Stream::File& file)
+ErrorOr<void> HexDocumentMemory::write_to_file(Core::File& file)
{
TRY(file.seek(0, SeekMode::SetPosition));
TRY(file.write(m_buffer));
@@ -69,7 +70,7 @@ ErrorOr<void> HexDocumentMemory::write_to_file(Core::Stream::File& file)
return {};
}
-ErrorOr<NonnullOwnPtr<HexDocumentFile>> HexDocumentFile::create(NonnullOwnPtr<Core::Stream::File> file)
+ErrorOr<NonnullOwnPtr<HexDocumentFile>> HexDocumentFile::create(NonnullOwnPtr<Core::File> file)
{
auto document = TRY(adopt_nonnull_own_or_enomem(new HexDocumentFile(move(file))));
TRY(document->initialize_internal_state());
@@ -77,7 +78,7 @@ ErrorOr<NonnullOwnPtr<HexDocumentFile>> HexDocumentFile::create(NonnullOwnPtr<Co
return document;
}
-HexDocumentFile::HexDocumentFile(NonnullOwnPtr<Core::Stream::File> file)
+HexDocumentFile::HexDocumentFile(NonnullOwnPtr<Core::File> file)
: m_file(move(file))
{
}
@@ -94,7 +95,7 @@ ErrorOr<void> HexDocumentFile::write_to_file()
return {};
}
-ErrorOr<void> HexDocumentFile::write_to_file(Core::Stream::File& file)
+ErrorOr<void> HexDocumentFile::write_to_file(Core::File& file)
{
TRY(file.truncate(size()));
@@ -149,7 +150,7 @@ void HexDocumentFile::clear_changes()
m_changes.clear();
}
-ErrorOr<void> HexDocumentFile::set_file(NonnullOwnPtr<Core::Stream::File> file)
+ErrorOr<void> HexDocumentFile::set_file(NonnullOwnPtr<Core::File> file)
{
m_file = move(file);
TRY(initialize_internal_state());
@@ -171,7 +172,7 @@ ErrorOr<void> HexDocumentFile::initialize_internal_state()
return {};
}
-NonnullOwnPtr<Core::Stream::File> const& HexDocumentFile::file() const
+NonnullOwnPtr<Core::File> const& HexDocumentFile::file() const
{
return m_file;
}
diff --git a/Userland/Applications/HexEditor/HexDocument.h b/Userland/Applications/HexEditor/HexDocument.h
index d5e46a4f87..256f753f65 100644
--- a/Userland/Applications/HexEditor/HexDocument.h
+++ b/Userland/Applications/HexEditor/HexDocument.h
@@ -52,7 +52,7 @@ public:
size_t size() const override;
Type type() const override;
void clear_changes() override;
- ErrorOr<void> write_to_file(Core::Stream::File& file);
+ ErrorOr<void> write_to_file(Core::File& file);
private:
ByteBuffer m_buffer;
@@ -60,16 +60,16 @@ private:
class HexDocumentFile final : public HexDocument {
public:
- static ErrorOr<NonnullOwnPtr<HexDocumentFile>> create(NonnullOwnPtr<Core::Stream::File> file);
+ static ErrorOr<NonnullOwnPtr<HexDocumentFile>> create(NonnullOwnPtr<Core::File> file);
virtual ~HexDocumentFile() = default;
HexDocumentFile(HexDocumentFile&&) = default;
HexDocumentFile(HexDocumentFile const&) = delete;
- ErrorOr<void> set_file(NonnullOwnPtr<Core::Stream::File> file);
- NonnullOwnPtr<Core::Stream::File> const& file() const;
+ ErrorOr<void> set_file(NonnullOwnPtr<Core::File> file);
+ NonnullOwnPtr<Core::File> const& file() const;
ErrorOr<void> write_to_file();
- ErrorOr<void> write_to_file(Core::Stream::File& file);
+ ErrorOr<void> write_to_file(Core::File& file);
Cell get(size_t position) override;
u8 get_unchanged(size_t position) override;
size_t size() const override;
@@ -77,12 +77,12 @@ public:
void clear_changes() override;
private:
- explicit HexDocumentFile(NonnullOwnPtr<Core::Stream::File> file);
+ explicit HexDocumentFile(NonnullOwnPtr<Core::File> file);
ErrorOr<void> initialize_internal_state();
void ensure_position_in_buffer(size_t position);
- NonnullOwnPtr<Core::Stream::File> m_file;
+ NonnullOwnPtr<Core::File> m_file;
size_t m_file_size;
Array<u8, 2048> m_buffer;
diff --git a/Userland/Applications/HexEditor/HexEditor.cpp b/Userland/Applications/HexEditor/HexEditor.cpp
index e3c28811db..18922eeb76 100644
--- a/Userland/Applications/HexEditor/HexEditor.cpp
+++ b/Userland/Applications/HexEditor/HexEditor.cpp
@@ -63,7 +63,7 @@ ErrorOr<void> HexEditor::open_new_file(size_t size)
return {};
}
-void HexEditor::open_file(NonnullOwnPtr<Core::Stream::File> file)
+void HexEditor::open_file(NonnullOwnPtr<Core::File> file)
{
m_document = HexDocumentFile::create(move(file)).release_value_but_fixme_should_propagate_errors();
set_content_length(m_document->size());
@@ -136,7 +136,7 @@ void HexEditor::set_selection(size_t position, size_t length)
update_status();
}
-ErrorOr<void> HexEditor::save_as(NonnullOwnPtr<Core::Stream::File> new_file)
+ErrorOr<void> HexEditor::save_as(NonnullOwnPtr<Core::File> new_file)
{
if (m_document->type() == HexDocument::Type::File) {
auto& file_document = static_cast<HexDocumentFile&>(*m_document);
diff --git a/Userland/Applications/HexEditor/HexEditor.h b/Userland/Applications/HexEditor/HexEditor.h
index 4a27d486d5..89eeeb3b5b 100644
--- a/Userland/Applications/HexEditor/HexEditor.h
+++ b/Userland/Applications/HexEditor/HexEditor.h
@@ -35,10 +35,10 @@ public:
size_t buffer_size() const { return m_document->size(); }
ErrorOr<void> open_new_file(size_t size);
- void open_file(NonnullOwnPtr<Core::Stream::File> file);
+ void open_file(NonnullOwnPtr<Core::File> file);
ErrorOr<void> fill_selection(u8 fill_byte);
Optional<u8> get_byte(size_t position);
- ErrorOr<void> save_as(NonnullOwnPtr<Core::Stream::File>);
+ ErrorOr<void> save_as(NonnullOwnPtr<Core::File>);
ErrorOr<void> save();
bool undo();
diff --git a/Userland/Applications/HexEditor/HexEditorWidget.cpp b/Userland/Applications/HexEditor/HexEditorWidget.cpp
index 64a43c3e3e..9084e049b9 100644
--- a/Userland/Applications/HexEditor/HexEditorWidget.cpp
+++ b/Userland/Applications/HexEditor/HexEditorWidget.cpp
@@ -121,7 +121,7 @@ HexEditorWidget::HexEditorWidget()
if (!request_close())
return;
- auto response = FileSystemAccessClient::Client::the().open_file(window(), {}, Core::StandardPaths::home_directory(), Core::Stream::OpenMode::ReadWrite);
+ auto response = FileSystemAccessClient::Client::the().open_file(window(), {}, Core::StandardPaths::home_directory(), Core::File::OpenMode::ReadWrite);
if (response.is_error())
return;
@@ -142,7 +142,7 @@ HexEditorWidget::HexEditorWidget()
});
m_save_as_action = GUI::CommonActions::make_save_as_action([&](auto&) {
- auto response = FileSystemAccessClient::Client::the().save_file(window(), m_name, m_extension, Core::Stream::OpenMode::ReadWrite | Core::Stream::OpenMode::Truncate);
+ auto response = FileSystemAccessClient::Client::the().save_file(window(), m_name, m_extension, Core::File::OpenMode::ReadWrite | Core::File::OpenMode::Truncate);
if (response.is_error())
return;
auto file = response.release_value();
@@ -525,7 +525,7 @@ void HexEditorWidget::update_title()
window()->set_title(builder.to_deprecated_string());
}
-void HexEditorWidget::open_file(String const& filename, NonnullOwnPtr<Core::Stream::File> file)
+void HexEditorWidget::open_file(String const& filename, NonnullOwnPtr<Core::File> file)
{
window()->set_modified(false);
m_editor->open_file(move(file));
@@ -586,7 +586,7 @@ void HexEditorWidget::drop_event(GUI::DropEvent& event)
return;
// TODO: A drop event should be considered user consent for opening a file
- auto response = FileSystemAccessClient::Client::the().request_file(window(), urls.first().path(), Core::Stream::OpenMode::Read);
+ auto response = FileSystemAccessClient::Client::the().request_file(window(), urls.first().path(), Core::File::OpenMode::Read);
if (response.is_error())
return;
open_file(response.value().filename(), response.value().release_stream());
diff --git a/Userland/Applications/HexEditor/HexEditorWidget.h b/Userland/Applications/HexEditor/HexEditorWidget.h
index addddd246f..a919de7f36 100644
--- a/Userland/Applications/HexEditor/HexEditorWidget.h
+++ b/Userland/Applications/HexEditor/HexEditorWidget.h
@@ -25,7 +25,7 @@ class HexEditorWidget final : public GUI::Widget {
C_OBJECT(HexEditorWidget)
public:
virtual ~HexEditorWidget() override = default;
- void open_file(String const& filename, NonnullOwnPtr<Core::Stream::File>);
+ void open_file(String const& filename, NonnullOwnPtr<Core::File>);
void initialize_menubar(GUI::Window&);
bool request_close();
diff --git a/Userland/Applications/HexEditor/main.cpp b/Userland/Applications/HexEditor/main.cpp
index f3311bc0e6..185653455b 100644
--- a/Userland/Applications/HexEditor/main.cpp
+++ b/Userland/Applications/HexEditor/main.cpp
@@ -53,7 +53,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (arguments.argc > 1) {
// FIXME: Using `try_request_file_read_only_approved` doesn't work here since the file stored in the editor is only readable.
- auto response = FileSystemAccessClient::Client::the().request_file(window, arguments.strings[1], Core::Stream::OpenMode::ReadWrite);
+ auto response = FileSystemAccessClient::Client::the().request_file(window, arguments.strings[1], Core::File::OpenMode::ReadWrite);
if (response.is_error())
return 1;
hex_editor_widget->open_file(response.value().filename(), response.value().release_stream());
diff --git a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp
index a602dbaf10..678fd1a573 100644
--- a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp
+++ b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp
@@ -8,6 +8,7 @@
#include "KeyboardMapperWidget.h"
#include "KeyPositions.h"
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibGUI/BoxLayout.h>
#include <LibGUI/InputBox.h>
@@ -191,7 +192,7 @@ ErrorOr<void> KeyboardMapperWidget::save_to_file(StringView filename)
// Write to file.
DeprecatedString file_content = map_json.to_deprecated_string();
- auto file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Write));
+ auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Write));
TRY(file->write(file_content.bytes()));
file->close();
diff --git a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp
index a57685df36..e8698e2d06 100644
--- a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp
+++ b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp
@@ -62,7 +62,7 @@ NetworkSettingsWidget::NetworkSettingsWidget()
auto config_file = Core::ConfigFile::open_for_system("Network").release_value_but_fixme_should_propagate_errors();
- auto proc_net_adapters_file = Core::Stream::File::open("/sys/kernel/net/adapters"sv, Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
+ auto proc_net_adapters_file = Core::File::open("/sys/kernel/net/adapters"sv, Core::File::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
auto data = proc_net_adapters_file->read_until_eof().release_value_but_fixme_should_propagate_errors();
JsonParser parser(data);
JsonValue proc_net_adapters_json = parser.parse().release_value_but_fixme_should_propagate_errors();
diff --git a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp
index b98629302e..3d0210dee4 100644
--- a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp
+++ b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp
@@ -348,7 +348,7 @@ void PDFViewerWidget::initialize_toolbar(GUI::Toolbar& toolbar)
m_show_images->on_checked = [&](auto checked) { m_viewer->set_show_images(checked); };
}
-void PDFViewerWidget::open_file(StringView path, NonnullOwnPtr<Core::Stream::File> file)
+void PDFViewerWidget::open_file(StringView path, NonnullOwnPtr<Core::File> file)
{
auto maybe_error = try_open_file(path, move(file));
if (maybe_error.is_error()) {
@@ -359,7 +359,7 @@ void PDFViewerWidget::open_file(StringView path, NonnullOwnPtr<Core::Stream::Fil
}
}
-PDF::PDFErrorOr<void> PDFViewerWidget::try_open_file(StringView path, NonnullOwnPtr<Core::Stream::File> file)
+PDF::PDFErrorOr<void> PDFViewerWidget::try_open_file(StringView path, NonnullOwnPtr<Core::File> file)
{
window()->set_title(DeprecatedString::formatted("{} - PDF Viewer", path));
diff --git a/Userland/Applications/PDFViewer/PDFViewerWidget.h b/Userland/Applications/PDFViewer/PDFViewerWidget.h
index cd1171f259..822d55da88 100644
--- a/Userland/Applications/PDFViewer/PDFViewerWidget.h
+++ b/Userland/Applications/PDFViewer/PDFViewerWidget.h
@@ -26,13 +26,13 @@ public:
~PDFViewerWidget() override = default;
void initialize_menubar(GUI::Window&);
- void open_file(StringView path, NonnullOwnPtr<Core::Stream::File> file);
+ void open_file(StringView path, NonnullOwnPtr<Core::File> file);
private:
PDFViewerWidget();
void initialize_toolbar(GUI::Toolbar&);
- PDF::PDFErrorOr<void> try_open_file(StringView path, NonnullOwnPtr<Core::Stream::File> file);
+ PDF::PDFErrorOr<void> try_open_file(StringView path, NonnullOwnPtr<Core::File> file);
RefPtr<PDFViewer> m_viewer;
RefPtr<SidebarWidget> m_sidebar;
diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp
index 0e058e8515..0d7ce8f339 100644
--- a/Userland/Applications/PixelPaint/ImageEditor.cpp
+++ b/Userland/Applications/PixelPaint/ImageEditor.cpp
@@ -733,7 +733,7 @@ void ImageEditor::save_project()
save_project_as();
return;
}
- auto response = FileSystemAccessClient::Client::the().request_file(window(), path(), Core::Stream::OpenMode::Truncate | Core::Stream::OpenMode::Write);
+ auto response = FileSystemAccessClient::Client::the().request_file(window(), path(), Core::File::OpenMode::Truncate | Core::File::OpenMode::Write);
if (response.is_error())
return;
auto result = save_project_to_file(response.value().release_stream());
@@ -760,7 +760,7 @@ void ImageEditor::save_project_as()
set_unmodified();
}
-ErrorOr<void> ImageEditor::save_project_to_file(NonnullOwnPtr<Core::Stream::File> file) const
+ErrorOr<void> ImageEditor::save_project_to_file(NonnullOwnPtr<Core::File> file) const
{
StringBuilder builder;
auto json = TRY(JsonObjectSerializer<>::try_create(builder));
diff --git a/Userland/Applications/PixelPaint/ImageEditor.h b/Userland/Applications/PixelPaint/ImageEditor.h
index 727868247f..9142ca67ee 100644
--- a/Userland/Applications/PixelPaint/ImageEditor.h
+++ b/Userland/Applications/PixelPaint/ImageEditor.h
@@ -153,7 +153,7 @@ private:
GUI::MouseEvent event_adjusted_for_layer(GUI::MouseEvent const&, Layer const&) const;
GUI::MouseEvent event_with_pan_and_scale_applied(GUI::MouseEvent const&) const;
- ErrorOr<void> save_project_to_file(NonnullOwnPtr<Core::Stream::File>) const;
+ ErrorOr<void> save_project_to_file(NonnullOwnPtr<Core::File>) const;
int calculate_ruler_step_size() const;
Gfx::IntRect mouse_indicator_rect_x() const;
diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp
index 8138870e98..f54f99f264 100644
--- a/Userland/Applications/PixelPaint/MainWidget.cpp
+++ b/Userland/Applications/PixelPaint/MainWidget.cpp
@@ -1288,7 +1288,7 @@ void MainWidget::drop_event(GUI::DropEvent& event)
if (url.scheme() != "file")
continue;
- auto response = FileSystemAccessClient::Client::the().request_file(window(), url.path(), Core::Stream::OpenMode::Read);
+ auto response = FileSystemAccessClient::Client::the().request_file(window(), url.path(), Core::File::OpenMode::Read);
if (response.is_error())
return;
open_image(response.release_value());
diff --git a/Userland/Applications/PixelPaint/PaletteWidget.cpp b/Userland/Applications/PixelPaint/PaletteWidget.cpp
index 96fb38965a..aab595cb64 100644
--- a/Userland/Applications/PixelPaint/PaletteWidget.cpp
+++ b/Userland/Applications/PixelPaint/PaletteWidget.cpp
@@ -224,11 +224,11 @@ Vector<Color> PaletteWidget::colors()
return colors;
}
-ErrorOr<Vector<Color>> PaletteWidget::load_palette_file(NonnullOwnPtr<Core::Stream::File> file)
+ErrorOr<Vector<Color>> PaletteWidget::load_palette_file(NonnullOwnPtr<Core::File> file)
{
Vector<Color> palette;
Array<u8, PAGE_SIZE> buffer;
- auto buffered_file = TRY(Core::Stream::BufferedFile::create(move(file)));
+ auto buffered_file = TRY(Core::BufferedFile::create(move(file)));
while (TRY(buffered_file->can_read_line())) {
auto line = TRY(buffered_file->read_line(buffer));
@@ -252,11 +252,11 @@ ErrorOr<Vector<Color>> PaletteWidget::load_palette_file(NonnullOwnPtr<Core::Stre
ErrorOr<Vector<Color>> PaletteWidget::load_palette_path(DeprecatedString const& file_path)
{
- auto file = TRY(Core::Stream::File::open(file_path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(file_path, Core::File::OpenMode::Read));
return load_palette_file(move(file));
}
-ErrorOr<void> PaletteWidget::save_palette_file(Vector<Color> palette, NonnullOwnPtr<Core::Stream::File> file)
+ErrorOr<void> PaletteWidget::save_palette_file(Vector<Color> palette, NonnullOwnPtr<Core::File> file)
{
for (auto& color : palette) {
TRY(file->write_entire_buffer(color.to_deprecated_string_without_alpha().bytes()));
diff --git a/Userland/Applications/PixelPaint/PaletteWidget.h b/Userland/Applications/PixelPaint/PaletteWidget.h
index aedfce3438..362c29f518 100644
--- a/Userland/Applications/PixelPaint/PaletteWidget.h
+++ b/Userland/Applications/PixelPaint/PaletteWidget.h
@@ -31,9 +31,9 @@ public:
Vector<Color> colors();
- static ErrorOr<Vector<Color>> load_palette_file(NonnullOwnPtr<Core::Stream::File>);
+ static ErrorOr<Vector<Color>> load_palette_file(NonnullOwnPtr<Core::File>);
static ErrorOr<Vector<Color>> load_palette_path(DeprecatedString const&);
- static ErrorOr<void> save_palette_file(Vector<Color>, NonnullOwnPtr<Core::Stream::File>);
+ static ErrorOr<void> save_palette_file(Vector<Color>, NonnullOwnPtr<Core::File>);
static Vector<Color> fallback_colors();
diff --git a/Userland/Applications/PixelPaint/ProjectLoader.cpp b/Userland/Applications/PixelPaint/ProjectLoader.cpp
index 020beb5423..c5ff761986 100644
--- a/Userland/Applications/PixelPaint/ProjectLoader.cpp
+++ b/Userland/Applications/PixelPaint/ProjectLoader.cpp
@@ -15,7 +15,7 @@
namespace PixelPaint {
-ErrorOr<void> ProjectLoader::load_from_file(NonnullOwnPtr<Core::Stream::File> file)
+ErrorOr<void> ProjectLoader::load_from_file(NonnullOwnPtr<Core::File> file)
{
auto contents = TRY(file->read_until_eof());
diff --git a/Userland/Applications/PixelPaint/ProjectLoader.h b/Userland/Applications/PixelPaint/ProjectLoader.h
index d16c7fef1a..111964e11c 100644
--- a/Userland/Applications/PixelPaint/ProjectLoader.h
+++ b/Userland/Applications/PixelPaint/ProjectLoader.h
@@ -18,7 +18,7 @@ public:
ProjectLoader() = default;
~ProjectLoader() = default;
- ErrorOr<void> load_from_file(NonnullOwnPtr<Core::Stream::File>);
+ ErrorOr<void> load_from_file(NonnullOwnPtr<Core::File>);
bool is_raw_image() const { return m_is_raw_image; }
bool has_image() const { return !m_image.is_null(); }
diff --git a/Userland/Applications/Presenter/Presentation.cpp b/Userland/Applications/Presenter/Presentation.cpp
index 2959022f10..a90da1e9db 100644
--- a/Userland/Applications/Presenter/Presentation.cpp
+++ b/Userland/Applications/Presenter/Presentation.cpp
@@ -7,6 +7,7 @@
#include "Presentation.h"
#include <AK/JsonObject.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibGUI/Window.h>
#include <errno_codes.h>
@@ -79,7 +80,7 @@ ErrorOr<NonnullOwnPtr<Presentation>> Presentation::load_from_file(StringView fil
{
if (file_name.is_empty())
return ENOENT;
- auto file = TRY(Core::Stream::File::open_file_or_standard_stream(file_name, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open_file_or_standard_stream(file_name, Core::File::OpenMode::Read));
auto contents = TRY(file->read_until_eof());
auto content_string = StringView { contents };
auto json = TRY(JsonValue::from_string(content_string));
diff --git a/Userland/Applications/Run/RunWindow.cpp b/Userland/Applications/Run/RunWindow.cpp
index 4c86e9df8e..fc82de3cd6 100644
--- a/Userland/Applications/Run/RunWindow.cpp
+++ b/Userland/Applications/Run/RunWindow.cpp
@@ -170,8 +170,8 @@ DeprecatedString RunWindow::history_file_path()
ErrorOr<void> RunWindow::load_history()
{
m_path_history.clear();
- auto file = TRY(Core::Stream::File::open(history_file_path(), Core::Stream::OpenMode::Read));
- auto buffered_file = TRY(Core::Stream::BufferedFile::create(move(file)));
+ auto file = TRY(Core::File::open(history_file_path(), Core::File::OpenMode::Read));
+ auto buffered_file = TRY(Core::BufferedFile::create(move(file)));
Array<u8, PAGE_SIZE> line_buffer;
while (!buffered_file->is_eof()) {
@@ -184,7 +184,7 @@ ErrorOr<void> RunWindow::load_history()
ErrorOr<void> RunWindow::save_history()
{
- auto file = TRY(Core::Stream::File::open(history_file_path(), Core::Stream::OpenMode::Write));
+ auto file = TRY(Core::File::open(history_file_path(), Core::File::OpenMode::Write));
// Write the first 25 items of history
for (int i = 0; i < min(static_cast<int>(m_path_history.size()), 25); i++)
diff --git a/Userland/Applications/SoundPlayer/M3UParser.cpp b/Userland/Applications/SoundPlayer/M3UParser.cpp
index 5cd76a45cc..43353b202b 100644
--- a/Userland/Applications/SoundPlayer/M3UParser.cpp
+++ b/Userland/Applications/SoundPlayer/M3UParser.cpp
@@ -9,6 +9,7 @@
#include <AK/RefPtr.h>
#include <AK/ScopeGuard.h>
#include <AK/Utf8View.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
M3UParser::M3UParser()
@@ -17,7 +18,7 @@ M3UParser::M3UParser()
NonnullOwnPtr<M3UParser> M3UParser::from_file(StringView path)
{
- auto file_result = Core::Stream::File::open(path, Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
+ auto file_result = Core::File::open(path, Core::File::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
auto contents = file_result->read_until_eof().release_value_but_fixme_should_propagate_errors();
auto use_utf8 = path.ends_with(".m3u8"sv, CaseSensitivity::CaseInsensitive);
return from_memory(DeprecatedString { contents, NoChomp }, use_utf8);
diff --git a/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp b/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp
index 052bdae088..bd4f6927ef 100644
--- a/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp
+++ b/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp
@@ -375,7 +375,7 @@ void TreeMapWidget::recalculate_path_for_new_tree()
static ErrorOr<void> fill_mounts(Vector<MountInfo>& output)
{
// Output info about currently mounted filesystems.
- auto file = TRY(Core::Stream::File::open("/sys/kernel/df"sv, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open("/sys/kernel/df"sv, Core::File::OpenMode::Read));
auto content = TRY(file->read_until_eof());
auto json = TRY(JsonValue::from_string(content));
diff --git a/Userland/Applications/Spreadsheet/ExportDialog.cpp b/Userland/Applications/Spreadsheet/ExportDialog.cpp
index df225e4888..35b1ca676f 100644
--- a/Userland/Applications/Spreadsheet/ExportDialog.cpp
+++ b/Userland/Applications/Spreadsheet/ExportDialog.cpp
@@ -178,7 +178,7 @@ void CSVExportDialogPage::update_preview()
m_data_preview_text_editor->set_text(DeprecatedString::formatted("Cannot update preview: {}", maybe_error.error()));
}
-ErrorOr<void> ExportDialog::make_and_run_for(StringView mime, Core::Stream::File& file, DeprecatedString filename, Workbook& workbook)
+ErrorOr<void> ExportDialog::make_and_run_for(StringView mime, Core::File& file, DeprecatedString filename, Workbook& workbook)
{
auto wizard = GUI::WizardDialog::construct(GUI::Application::the()->active_window());
wizard->set_title("File Export Wizard");
diff --git a/Userland/Applications/Spreadsheet/ExportDialog.h b/Userland/Applications/Spreadsheet/ExportDialog.h
index 3579e135aa..c3e5fab677 100644
--- a/Userland/Applications/Spreadsheet/ExportDialog.h
+++ b/Userland/Applications/Spreadsheet/ExportDialog.h
@@ -58,7 +58,7 @@ private:
};
struct ExportDialog {
- static ErrorOr<void> make_and_run_for(StringView mime, Core::Stream::File&, DeprecatedString filename, Workbook&);
+ static ErrorOr<void> make_and_run_for(StringView mime, Core::File&, DeprecatedString filename, Workbook&);
};
}
diff --git a/Userland/Applications/Spreadsheet/ImportDialog.cpp b/Userland/Applications/Spreadsheet/ImportDialog.cpp
index f27cfdf8b2..2da65ae87d 100644
--- a/Userland/Applications/Spreadsheet/ImportDialog.cpp
+++ b/Userland/Applications/Spreadsheet/ImportDialog.cpp
@@ -174,7 +174,7 @@ void CSVImportDialogPage::update_preview()
m_data_preview_table_view->update();
}
-ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::Stream::File& file, Workbook& workbook)
+ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook& workbook)
{
auto wizard = GUI::WizardDialog::construct(&parent);
wizard->set_title("File Import Wizard");
diff --git a/Userland/Applications/Spreadsheet/ImportDialog.h b/Userland/Applications/Spreadsheet/ImportDialog.h
index 7e8b5b00f3..dba25312c6 100644
--- a/Userland/Applications/Spreadsheet/ImportDialog.h
+++ b/Userland/Applications/Spreadsheet/ImportDialog.h
@@ -55,7 +55,7 @@ private:
};
struct ImportDialog {
- static ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::Stream::File& file, Workbook&);
+ static ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook&);
};
}
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
index d297186662..5d8fcc72fa 100644
--- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
+++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
@@ -147,7 +147,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
return;
}
- auto response = FileSystemAccessClient::Client::the().request_file(window(), current_filename(), Core::Stream::OpenMode::Write);
+ auto response = FileSystemAccessClient::Client::the().request_file(window(), current_filename(), Core::File::OpenMode::Write);
if (response.is_error())
return;
save(response.value().filename(), response.value().stream());
@@ -493,7 +493,7 @@ void SpreadsheetWidget::change_cell_static_color_format(Spreadsheet::FormatType
}
}
-void SpreadsheetWidget::save(String const& filename, Core::Stream::File& file)
+void SpreadsheetWidget::save(String const& filename, Core::File& file)
{
auto result = m_workbook->write_to_file(filename, file);
if (result.is_error()) {
@@ -504,7 +504,7 @@ void SpreadsheetWidget::save(String const& filename, Core::Stream::File& file)
window()->set_modified(false);
}
-void SpreadsheetWidget::load_file(String const& filename, Core::Stream::File& file)
+void SpreadsheetWidget::load_file(String const& filename, Core::File& file)
{
auto result = m_workbook->open_file(filename, file);
if (result.is_error()) {
@@ -523,7 +523,7 @@ void SpreadsheetWidget::load_file(String const& filename, Core::Stream::File& fi
update_window_title();
}
-void SpreadsheetWidget::import_sheets(String const& filename, Core::Stream::File& file)
+void SpreadsheetWidget::import_sheets(String const& filename, Core::File& file)
{
auto result = m_workbook->import_file(filename, file);
if (result.is_error()) {
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.h b/Userland/Applications/Spreadsheet/SpreadsheetWidget.h
index 63fe723b89..31d21c7f5c 100644
--- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.h
+++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.h
@@ -24,9 +24,9 @@ class SpreadsheetWidget final
public:
virtual ~SpreadsheetWidget() override = default;
- void save(String const& filename, Core::Stream::File&);
- void load_file(String const& filename, Core::Stream::File&);
- void import_sheets(String const& filename, Core::Stream::File&);
+ void save(String const& filename, Core::File&);
+ void load_file(String const& filename, Core::File&);
+ void import_sheets(String const& filename, Core::File&);
bool request_close();
void add_sheet();
void add_sheet(NonnullRefPtr<Sheet>&&);
diff --git a/Userland/Applications/Spreadsheet/Workbook.cpp b/Userland/Applications/Spreadsheet/Workbook.cpp
index 16c0ba407c..3df8daa501 100644
--- a/Userland/Applications/Spreadsheet/Workbook.cpp
+++ b/Userland/Applications/Spreadsheet/Workbook.cpp
@@ -50,7 +50,7 @@ bool Workbook::set_filename(DeprecatedString const& filename)
return true;
}
-ErrorOr<void, DeprecatedString> Workbook::open_file(String const& filename, Core::Stream::File& file)
+ErrorOr<void, DeprecatedString> Workbook::open_file(String const& filename, Core::File& file)
{
auto mime = Core::guess_mime_type_based_on_filename(filename);
@@ -62,7 +62,7 @@ ErrorOr<void, DeprecatedString> Workbook::open_file(String const& filename, Core
return {};
}
-ErrorOr<void> Workbook::write_to_file(String const& filename, Core::Stream::File& stream)
+ErrorOr<void> Workbook::write_to_file(String const& filename, Core::File& stream)
{
auto mime = Core::guess_mime_type_based_on_filename(filename);
@@ -74,7 +74,7 @@ ErrorOr<void> Workbook::write_to_file(String const& filename, Core::Stream::File
return {};
}
-ErrorOr<bool, DeprecatedString> Workbook::import_file(String const& filename, Core::Stream::File& file)
+ErrorOr<bool, DeprecatedString> Workbook::import_file(String const& filename, Core::File& file)
{
auto mime = Core::guess_mime_type_based_on_filename(filename);
diff --git a/Userland/Applications/Spreadsheet/Workbook.h b/Userland/Applications/Spreadsheet/Workbook.h
index 2020a23943..84d394053d 100644
--- a/Userland/Applications/Spreadsheet/Workbook.h
+++ b/Userland/Applications/Spreadsheet/Workbook.h
@@ -16,10 +16,10 @@ class Workbook {
public:
Workbook(NonnullRefPtrVector<Sheet>&& sheets, GUI::Window& parent_window);
- ErrorOr<void, DeprecatedString> open_file(String const& filename, Core::Stream::File&);
- ErrorOr<void> write_to_file(String const& filename, Core::Stream::File&);
+ ErrorOr<void, DeprecatedString> open_file(String const& filename, Core::File&);
+ ErrorOr<void> write_to_file(String const& filename, Core::File&);
- ErrorOr<bool, DeprecatedString> import_file(String const& filename, Core::Stream::File&);
+ ErrorOr<bool, DeprecatedString> import_file(String const& filename, Core::File&);
DeprecatedString const& current_filename() const { return m_current_filename; }
bool set_filename(DeprecatedString const& filename);
diff --git a/Userland/Applications/SystemMonitor/ProcessModel.cpp b/Userland/Applications/SystemMonitor/ProcessModel.cpp
index f32d84ad25..04d031269c 100644
--- a/Userland/Applications/SystemMonitor/ProcessModel.cpp
+++ b/Userland/Applications/SystemMonitor/ProcessModel.cpp
@@ -410,7 +410,7 @@ Vector<GUI::ModelIndex> ProcessModel::matches(StringView searching, unsigned fla
static ErrorOr<DeprecatedString> try_read_command_line(pid_t pid)
{
- auto file = TRY(Core::Stream::File::open(DeprecatedString::formatted("/proc/{}/cmdline", pid), Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(DeprecatedString::formatted("/proc/{}/cmdline", pid), Core::File::OpenMode::Read));
auto data = TRY(file->read_until_eof());
auto json = TRY(JsonValue::from_string(StringView { data.bytes() }));
auto array = json.as_array().values();
diff --git a/Userland/Applications/TextEditor/MainWidget.cpp b/Userland/Applications/TextEditor/MainWidget.cpp
index 99a42a3178..a95a47bad6 100644
--- a/Userland/Applications/TextEditor/MainWidget.cpp
+++ b/Userland/Applications/TextEditor/MainWidget.cpp
@@ -303,7 +303,7 @@ MainWidget::MainWidget()
m_save_as_action->activate();
return;
}
- auto response = FileSystemAccessClient::Client::the().request_file(window(), m_path, Core::Stream::OpenMode::Truncate | Core::Stream::OpenMode::Write);
+ auto response = FileSystemAccessClient::Client::the().request_file(window(), m_path, Core::File::OpenMode::Truncate | Core::File::OpenMode::Write);
if (response.is_error())
return;
@@ -746,7 +746,7 @@ void MainWidget::update_title()
window()->set_title(builder.to_deprecated_string());
}
-ErrorOr<void> MainWidget::read_file(String const& filename, Core::Stream::File& file)
+ErrorOr<void> MainWidget::read_file(String const& filename, Core::File& file)
{
m_editor->set_text(TRY(file.read_until_eof()));
set_path(filename);
diff --git a/Userland/Applications/TextEditor/MainWidget.h b/Userland/Applications/TextEditor/MainWidget.h
index 04ff814e22..61c37fefe6 100644
--- a/Userland/Applications/TextEditor/MainWidget.h
+++ b/Userland/Applications/TextEditor/MainWidget.h
@@ -25,7 +25,7 @@ class MainWidget final : public GUI::Widget {
public:
virtual ~MainWidget() override = default;
- ErrorOr<void> read_file(String const& filename, Core::Stream::File&);
+ ErrorOr<void> read_file(String const& filename, Core::File&);
void open_nonexistent_file(DeprecatedString const& path);
bool request_close();
diff --git a/Userland/Applications/ThemeEditor/MainWidget.cpp b/Userland/Applications/ThemeEditor/MainWidget.cpp
index ff4e6453dd..b80dcb5ffe 100644
--- a/Userland/Applications/ThemeEditor/MainWidget.cpp
+++ b/Userland/Applications/ThemeEditor/MainWidget.cpp
@@ -250,12 +250,12 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
m_save_action = GUI::CommonActions::make_save_action([&](auto&) {
if (m_path.has_value()) {
- auto result = FileSystemAccessClient::Client::the().request_file(&window, *m_path, Core::Stream::OpenMode::ReadWrite | Core::Stream::OpenMode::Truncate);
+ auto result = FileSystemAccessClient::Client::the().request_file(&window, *m_path, Core::File::OpenMode::ReadWrite | Core::File::OpenMode::Truncate);
if (result.is_error())
return;
save_to_file(result.value().filename(), result.value().release_stream());
} else {
- auto result = FileSystemAccessClient::Client::the().save_file(&window, "Theme", "ini", Core::Stream::OpenMode::ReadWrite | Core::Stream::OpenMode::Truncate);
+ auto result = FileSystemAccessClient::Client::the().save_file(&window, "Theme", "ini", Core::File::OpenMode::ReadWrite | Core::File::OpenMode::Truncate);
if (result.is_error())
return;
save_to_file(result.value().filename(), result.value().release_stream());
@@ -264,7 +264,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
TRY(file_menu->try_add_action(*m_save_action));
TRY(file_menu->try_add_action(GUI::CommonActions::make_save_as_action([&](auto&) {
- auto result = FileSystemAccessClient::Client::the().save_file(&window, "Theme", "ini", Core::Stream::OpenMode::ReadWrite | Core::Stream::OpenMode::Truncate);
+ auto result = FileSystemAccessClient::Client::the().save_file(&window, "Theme", "ini", Core::File::OpenMode::ReadWrite | Core::File::OpenMode::Truncate);
if (result.is_error())
return;
save_to_file(result.value().filename(), result.value().release_stream());
@@ -315,7 +315,7 @@ void MainWidget::set_path(DeprecatedString path)
update_title();
}
-void MainWidget::save_to_file(String const& filename, NonnullOwnPtr<Core::Stream::File> file)
+void MainWidget::save_to_file(String const& filename, NonnullOwnPtr<Core::File> file)
{
auto theme = Core::ConfigFile::open(filename.to_deprecated_string(), move(file)).release_value_but_fixme_should_propagate_errors();
@@ -601,7 +601,7 @@ void MainWidget::show_path_picker_dialog(StringView property_display_name, GUI::
path_input.set_text(*result);
}
-ErrorOr<void> MainWidget::load_from_file(String const& filename, NonnullOwnPtr<Core::Stream::File> file)
+ErrorOr<void> MainWidget::load_from_file(String const& filename, NonnullOwnPtr<Core::File> file)
{
auto config_file = TRY(Core::ConfigFile::open(filename.to_deprecated_string(), move(file)));
auto theme = TRY(Gfx::load_system_theme(config_file));
@@ -669,7 +669,7 @@ void MainWidget::drop_event(GUI::DropEvent& event)
if (request_close() == GUI::Window::CloseRequestDecision::StayOpen)
return;
- auto response = FileSystemAccessClient::Client::the().request_file(window(), urls.first().path(), Core::Stream::OpenMode::Read);
+ auto response = FileSystemAccessClient::Client::the().request_file(window(), urls.first().path(), Core::File::OpenMode::Read);
if (response.is_error())
return;
diff --git a/Userland/Applications/ThemeEditor/MainWidget.h b/Userland/Applications/ThemeEditor/MainWidget.h
index d33155de80..287a165b04 100644
--- a/Userland/Applications/ThemeEditor/MainWidget.h
+++ b/Userland/Applications/ThemeEditor/MainWidget.h
@@ -86,7 +86,7 @@ public:
ErrorOr<void> initialize_menubar(GUI::Window&);
GUI::Window::CloseRequestDecision request_close();
void update_title();
- ErrorOr<void> load_from_file(String const& filename, NonnullOwnPtr<Core::Stream::File> file);
+ ErrorOr<void> load_from_file(String const& filename, NonnullOwnPtr<Core::File> file);
private:
explicit MainWidget(NonnullRefPtr<AlignmentModel>);
@@ -94,7 +94,7 @@ private:
virtual void drag_enter_event(GUI::DragEvent&) override;
virtual void drop_event(GUI::DropEvent&) override;
- void save_to_file(String const& filename, NonnullOwnPtr<Core::Stream::File> file);
+ void save_to_file(String const& filename, NonnullOwnPtr<Core::File> file);
ErrorOr<Core::AnonymousBuffer> encode();
void set_path(DeprecatedString);
diff --git a/Userland/Applications/Welcome/WelcomeWidget.cpp b/Userland/Applications/Welcome/WelcomeWidget.cpp
index 4fef76b034..776c37f84b 100644
--- a/Userland/Applications/Welcome/WelcomeWidget.cpp
+++ b/Userland/Applications/Welcome/WelcomeWidget.cpp
@@ -95,8 +95,8 @@ ErrorOr<void> WelcomeWidget::create_widgets()
ErrorOr<void> WelcomeWidget::open_and_parse_tips_file()
{
auto path = TRY(String::formatted("{}/tips.txt", Core::StandardPaths::documents_directory()));
- auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
- auto buffered_file = TRY(Core::Stream::BufferedFile::create(move(file)));
+ auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
+ auto buffered_file = TRY(Core::BufferedFile::create(move(file)));
Array<u8, PAGE_SIZE> buffer;
while (TRY(buffered_file->can_read_line())) {
diff --git a/Userland/Demos/CatDog/CatDog.cpp b/Userland/Demos/CatDog/CatDog.cpp
index c276704ffe..70c9dd3cf5 100644
--- a/Userland/Demos/CatDog/CatDog.cpp
+++ b/Userland/Demos/CatDog/CatDog.cpp
@@ -6,6 +6,7 @@
*/
#include "CatDog.h"
+#include <LibCore/File.h>
#include <LibCore/ProcessStatisticsReader.h>
#include <LibGUI/Painter.h>
#include <LibGUI/Window.h>
@@ -55,7 +56,7 @@ ErrorOr<NonnullRefPtr<CatDog>> CatDog::create()
}
CatDog::CatDog()
- : m_proc_all(MUST(Core::Stream::File::open("/sys/kernel/processes"sv, Core::Stream::OpenMode::Read)))
+ : m_proc_all(MUST(Core::File::open("/sys/kernel/processes"sv, Core::File::OpenMode::Read)))
{
m_idle_sleep_timer.start();
}
diff --git a/Userland/Demos/CatDog/CatDog.h b/Userland/Demos/CatDog/CatDog.h
index f5daca0e4d..0a86a013bf 100644
--- a/Userland/Demos/CatDog/CatDog.h
+++ b/Userland/Demos/CatDog/CatDog.h
@@ -74,7 +74,7 @@ private:
Gfx::IntPoint m_mouse_offset {};
Core::ElapsedTimer m_idle_sleep_timer;
- NonnullOwnPtr<Core::Stream::File> m_proc_all;
+ NonnullOwnPtr<Core::File> m_proc_all;
State m_state { State::Roaming };
State m_frame { State::Frame1 };
diff --git a/Userland/DevTools/GMLPlayground/main.cpp b/Userland/DevTools/GMLPlayground/main.cpp
index 4bb2bb2246..f1c9a7d5b0 100644
--- a/Userland/DevTools/GMLPlayground/main.cpp
+++ b/Userland/DevTools/GMLPlayground/main.cpp
@@ -157,7 +157,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
save_as_action->activate();
return;
}
- auto response = FileSystemAccessClient::Client::the().request_file(window, file_path, Core::Stream::OpenMode::Truncate | Core::Stream::OpenMode::Write);
+ auto response = FileSystemAccessClient::Client::the().request_file(window, file_path, Core::File::OpenMode::Truncate | Core::File::OpenMode::Write);
if (response.is_error())
return;
diff --git a/Userland/DevTools/HackStudio/Editor.cpp b/Userland/DevTools/HackStudio/Editor.cpp
index 4fe98a0b61..83bb54c955 100644
--- a/Userland/DevTools/HackStudio/Editor.cpp
+++ b/Userland/DevTools/HackStudio/Editor.cpp
@@ -232,7 +232,7 @@ void Editor::show_documentation_tooltip_if_available(DeprecatedString const& hov
}
dbgln_if(EDITOR_DEBUG, "opening {}", it->value);
- auto file_or_error = Core::Stream::File::open(it->value, Core::Stream::OpenMode::Read);
+ auto file_or_error = Core::File::open(it->value, Core::File::OpenMode::Read);
if (file_or_error.is_error()) {
dbgln("Failed to open {}, {}", it->value, file_or_error.error());
return;
diff --git a/Userland/DevTools/HackStudio/Git/GitWidget.cpp b/Userland/DevTools/HackStudio/Git/GitWidget.cpp
index e079a84dd5..2afe716263 100644
--- a/Userland/DevTools/HackStudio/Git/GitWidget.cpp
+++ b/Userland/DevTools/HackStudio/Git/GitWidget.cpp
@@ -155,7 +155,7 @@ void GitWidget::set_view_diff_callback(ViewDiffCallback callback)
void GitWidget::show_diff(DeprecatedString const& file_path)
{
if (!m_git_repo->is_tracked(file_path)) {
- auto file = Core::Stream::File::open(file_path, Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
+ auto file = Core::File::open(file_path, Core::File::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
auto content = file->read_until_eof().release_value_but_fixme_should_propagate_errors();
m_view_diff_callback("", Diff::generate_only_additions(content));
return;
diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp
index 464baebc50..deeda7935b 100644
--- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp
+++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp
@@ -550,7 +550,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_new_file_action(Dep
filepath = DeprecatedString::formatted("{}{}", filepath, filename);
- auto file_or_error = Core::Stream::File::open(filepath, Core::Stream::OpenMode::Write | Core::Stream::OpenMode::MustBeNew);
+ auto file_or_error = Core::File::open(filepath, Core::File::OpenMode::Write | Core::File::OpenMode::MustBeNew);
if (file_or_error.is_error()) {
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to create '{}': {}", filepath, file_or_error.error()));
return;
@@ -1791,7 +1791,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_open_project_config
if (maybe_error.is_error() && maybe_error.error().code() != EEXIST)
return maybe_error.release_error();
- auto file = TRY(Core::Stream::File::open(absolute_config_file_path, Core::Stream::OpenMode::Write));
+ auto file = TRY(Core::File::open(absolute_config_file_path, Core::File::OpenMode::Write));
TRY(file->write_entire_buffer(
"{\n"
" \"build_command\": \"your build command here\",\n"
diff --git a/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp b/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp
index 27c2091c2b..15673d56a5 100644
--- a/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp
+++ b/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp
@@ -9,6 +9,7 @@
#include <AK/Debug.h>
#include <AK/LexicalPath.h>
#include <AK/NonnullRefPtr.h>
+#include <LibCore/File.h>
namespace LanguageServers {
@@ -74,13 +75,13 @@ DeprecatedString FileDB::to_absolute_path(DeprecatedString const& filename) cons
ErrorOr<NonnullRefPtr<GUI::TextDocument>> FileDB::create_from_filesystem(DeprecatedString const& filename) const
{
- auto file = TRY(Core::Stream::File::open(to_absolute_path(filename), Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(to_absolute_path(filename), Core::File::OpenMode::Read));
return create_from_file(move(file));
}
ErrorOr<NonnullRefPtr<GUI::TextDocument>> FileDB::create_from_fd(int fd) const
{
- auto file = TRY(Core::Stream::File::adopt_fd(fd, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::adopt_fd(fd, Core::File::OpenMode::Read));
return create_from_file(move(file));
}
@@ -101,7 +102,7 @@ public:
};
static DefaultDocumentClient s_default_document_client;
-ErrorOr<NonnullRefPtr<GUI::TextDocument>> FileDB::create_from_file(NonnullOwnPtr<Core::Stream::File> file) const
+ErrorOr<NonnullRefPtr<GUI::TextDocument>> FileDB::create_from_file(NonnullOwnPtr<Core::File> file) const
{
auto content = TRY(file->read_until_eof());
auto document = GUI::TextDocument::create(&s_default_document_client);
diff --git a/Userland/DevTools/HackStudio/LanguageServers/FileDB.h b/Userland/DevTools/HackStudio/LanguageServers/FileDB.h
index 86cbaf4357..8cb3302c64 100644
--- a/Userland/DevTools/HackStudio/LanguageServers/FileDB.h
+++ b/Userland/DevTools/HackStudio/LanguageServers/FileDB.h
@@ -34,7 +34,7 @@ public:
private:
ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_filesystem(DeprecatedString const& filename) const;
ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_fd(int fd) const;
- ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_file(NonnullOwnPtr<Core::Stream::File>) const;
+ ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_file(NonnullOwnPtr<Core::File>) const;
static RefPtr<GUI::TextDocument> create_with_content(DeprecatedString const&);
private:
diff --git a/Userland/DevTools/HackStudio/ProjectBuilder.cpp b/Userland/DevTools/HackStudio/ProjectBuilder.cpp
index 8fc1c05812..5c714c9753 100644
--- a/Userland/DevTools/HackStudio/ProjectBuilder.cpp
+++ b/Userland/DevTools/HackStudio/ProjectBuilder.cpp
@@ -112,7 +112,7 @@ ErrorOr<void> ProjectBuilder::build_serenity_component()
ErrorOr<DeprecatedString> ProjectBuilder::component_name(StringView cmake_file_path)
{
- auto file = TRY(Core::Stream::File::open(cmake_file_path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(cmake_file_path, Core::File::OpenMode::Read));
auto content = TRY(file->read_until_eof());
static Regex<ECMA262> const component_name(R"~~~(serenity_component\([\s]*(\w+)[\s\S]*\))~~~");
@@ -135,7 +135,7 @@ ErrorOr<void> ProjectBuilder::initialize_build_directory()
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));
+ auto cmake_file = TRY(Core::File::open(cmake_file_path, Core::File::OpenMode::Write));
TRY(cmake_file->write_entire_buffer(generate_cmake_file_content().bytes()));
TRY(m_terminal->run_command(DeprecatedString::formatted("cmake -S {} -DHACKSTUDIO_BUILD=ON -DHACKSTUDIO_BUILD_CMAKE_FILE={}"
diff --git a/Userland/DevTools/HackStudio/ProjectConfig.cpp b/Userland/DevTools/HackStudio/ProjectConfig.cpp
index 2171c03b21..5eacf415ae 100644
--- a/Userland/DevTools/HackStudio/ProjectConfig.cpp
+++ b/Userland/DevTools/HackStudio/ProjectConfig.cpp
@@ -6,6 +6,7 @@
#include "ProjectConfig.h"
#include <AK/NonnullOwnPtr.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
namespace HackStudio {
@@ -17,7 +18,7 @@ ProjectConfig::ProjectConfig(JsonObject config)
ErrorOr<NonnullOwnPtr<ProjectConfig>> ProjectConfig::try_load_project_config(DeprecatedString path)
{
- auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
auto file_contents = TRY(file->read_until_eof());
auto json = TRY(JsonValue::from_string(file_contents));
diff --git a/Userland/DevTools/HackStudio/ProjectFile.cpp b/Userland/DevTools/HackStudio/ProjectFile.cpp
index a7c5129347..768085b08c 100644
--- a/Userland/DevTools/HackStudio/ProjectFile.cpp
+++ b/Userland/DevTools/HackStudio/ProjectFile.cpp
@@ -5,6 +5,7 @@
*/
#include "ProjectFile.h"
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
namespace HackStudio {
@@ -54,7 +55,7 @@ void ProjectFile::create_document_if_needed() const
return;
m_document = CodeDocument::create(m_name);
- auto file_or_error = Core::Stream::File::open(m_name, Core::Stream::OpenMode::Read);
+ auto file_or_error = Core::File::open(m_name, Core::File::OpenMode::Read);
if (file_or_error.is_error()) {
warnln("Couldn't open '{}': {}", m_name, file_or_error.error());
// This is okay though, we'll just go with an empty document and create the file when saving.
diff --git a/Userland/DevTools/Profiler/Profile.cpp b/Userland/DevTools/Profiler/Profile.cpp
index 2247fbf1b7..9d512f029c 100644
--- a/Userland/DevTools/Profiler/Profile.cpp
+++ b/Userland/DevTools/Profiler/Profile.cpp
@@ -236,7 +236,7 @@ OwnPtr<Debug::DebugInfo> g_kernel_debug_info;
ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path)
{
- auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
auto json = JsonValue::from_string(TRY(file->read_until_eof()));
if (json.is_error() || !json.value().is_object())
diff --git a/Userland/DevTools/Profiler/SourceModel.cpp b/Userland/DevTools/Profiler/SourceModel.cpp
index ca478adc24..87d60dc373 100644
--- a/Userland/DevTools/Profiler/SourceModel.cpp
+++ b/Userland/DevTools/Profiler/SourceModel.cpp
@@ -29,8 +29,8 @@ public:
DeprecatedString source_file_name = filename.replace("../../"sv, source_root_path, ReplaceMode::FirstOnly);
auto try_read_lines = [&]() -> ErrorOr<void> {
- auto unbuffered_file = TRY(Core::Stream::File::open(source_file_name, Core::Stream::OpenMode::Read));
- auto file = TRY(Core::Stream::BufferedFile::create(move(unbuffered_file)));
+ auto unbuffered_file = TRY(Core::File::open(source_file_name, Core::File::OpenMode::Read));
+ auto file = TRY(Core::BufferedFile::create(move(unbuffered_file)));
Array<u8, 1024> buffer;
while (!file->is_eof())
diff --git a/Userland/DevTools/SQLStudio/ScriptEditor.cpp b/Userland/DevTools/SQLStudio/ScriptEditor.cpp
index 0ad9807301..3c8261b901 100644
--- a/Userland/DevTools/SQLStudio/ScriptEditor.cpp
+++ b/Userland/DevTools/SQLStudio/ScriptEditor.cpp
@@ -29,7 +29,7 @@ void ScriptEditor::new_script_with_temp_name(DeprecatedString name)
ErrorOr<void> ScriptEditor::open_script_from_file(LexicalPath const& file_path)
{
- auto file = TRY(Core::Stream::File::open(file_path.string(), Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(file_path.string(), Core::File::OpenMode::Read));
auto buffer = TRY(file->read_until_eof());
set_text({ buffer.bytes() });
@@ -40,7 +40,7 @@ ErrorOr<void> ScriptEditor::open_script_from_file(LexicalPath const& file_path)
static ErrorOr<void> save_text_to_file(StringView filename, DeprecatedString text)
{
- auto file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Write));
+ auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Write));
if (!text.is_empty())
TRY(file->write_entire_buffer(text.bytes()));
diff --git a/Userland/DevTools/UserspaceEmulator/main.cpp b/Userland/DevTools/UserspaceEmulator/main.cpp
index eda37b6d7e..52e497f69d 100644
--- a/Userland/DevTools/UserspaceEmulator/main.cpp
+++ b/Userland/DevTools/UserspaceEmulator/main.cpp
@@ -61,7 +61,7 @@ int main(int argc, char** argv, char** env)
OwnPtr<Vector<int>> profile_string_id_map;
if (dump_profile) {
- auto profile_stream_or_error = Core::Stream::File::open(profile_dump_path, Core::Stream::OpenMode::Write);
+ auto profile_stream_or_error = Core::File::open(profile_dump_path, Core::File::OpenMode::Write);
if (profile_stream_or_error.is_error()) {
warnln("Failed to open '{}' for writing: {}", profile_dump_path, profile_stream_or_error.error());
return 1;
diff --git a/Userland/Games/Chess/ChessWidget.cpp b/Userland/Games/Chess/ChessWidget.cpp
index 4c34b056b8..65e0006a60 100644
--- a/Userland/Games/Chess/ChessWidget.cpp
+++ b/Userland/Games/Chess/ChessWidget.cpp
@@ -10,6 +10,7 @@
#include <AK/Random.h>
#include <AK/String.h>
#include <LibCore/DateTime.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibGUI/MessageBox.h>
#include <LibGUI/Painter.h>
@@ -532,7 +533,7 @@ DeprecatedString ChessWidget::get_fen() const
return m_playback ? m_board_playback.to_fen() : m_board.to_fen();
}
-ErrorOr<void> ChessWidget::import_pgn(Core::Stream::File& file)
+ErrorOr<void> ChessWidget::import_pgn(Core::File& file)
{
m_board = Chess::Board();
@@ -629,7 +630,7 @@ ErrorOr<void> ChessWidget::import_pgn(Core::Stream::File& file)
return {};
}
-ErrorOr<void> ChessWidget::export_pgn(Core::Stream::File& file) const
+ErrorOr<void> ChessWidget::export_pgn(Core::File& file) const
{
// Tag Pair Section
TRY(file.write("[Event \"Casual Game\"]\n"sv.bytes()));
diff --git a/Userland/Games/Chess/ChessWidget.h b/Userland/Games/Chess/ChessWidget.h
index ef048ec7ae..3e35f2706f 100644
--- a/Userland/Games/Chess/ChessWidget.h
+++ b/Userland/Games/Chess/ChessWidget.h
@@ -54,8 +54,8 @@ public:
void set_show_available_moves(bool e) { m_show_available_moves = e; }
DeprecatedString get_fen() const;
- ErrorOr<void> import_pgn(Core::Stream::File&);
- ErrorOr<void> export_pgn(Core::Stream::File&) const;
+ ErrorOr<void> import_pgn(Core::File&);
+ ErrorOr<void> export_pgn(Core::File&) const;
int resign();
void flip_board();
diff --git a/Userland/Games/MasterWord/WordGame.cpp b/Userland/Games/MasterWord/WordGame.cpp
index a7665458a2..9a3d1ddfed 100644
--- a/Userland/Games/MasterWord/WordGame.cpp
+++ b/Userland/Games/MasterWord/WordGame.cpp
@@ -177,8 +177,8 @@ void WordGame::read_words()
m_words.clear();
auto try_load_words = [&]() -> ErrorOr<void> {
- auto response = TRY(Core::Stream::File::open("/res/words.txt"sv, Core::Stream::OpenMode::Read));
- auto words_file = TRY(Core::Stream::BufferedFile::create(move(response)));
+ auto response = TRY(Core::File::open("/res/words.txt"sv, Core::File::OpenMode::Read));
+ auto words_file = TRY(Core::BufferedFile::create(move(response)));
Array<u8, 128> buffer;
while (!words_file->is_eof()) {
diff --git a/Userland/Libraries/LibAudio/FlacLoader.cpp b/Userland/Libraries/LibAudio/FlacLoader.cpp
index 26036610d4..2eaa331ed7 100644
--- a/Userland/Libraries/LibAudio/FlacLoader.cpp
+++ b/Userland/Libraries/LibAudio/FlacLoader.cpp
@@ -21,6 +21,7 @@
#include <LibAudio/FlacTypes.h>
#include <LibAudio/LoaderError.h>
#include <LibAudio/Resampler.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
namespace Audio {
@@ -32,7 +33,7 @@ FlacLoaderPlugin::FlacLoaderPlugin(NonnullOwnPtr<SeekableStream> stream)
Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> FlacLoaderPlugin::create(StringView path)
{
- auto stream = LOADER_TRY(Core::Stream::BufferedFile::create(LOADER_TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read))));
+ auto stream = LOADER_TRY(Core::BufferedFile::create(LOADER_TRY(Core::File::open(path, Core::File::OpenMode::Read))));
auto loader = make<FlacLoaderPlugin>(move(stream));
LOADER_TRY(loader->initialize());
diff --git a/Userland/Libraries/LibAudio/MP3Loader.cpp b/Userland/Libraries/LibAudio/MP3Loader.cpp
index c36287112f..0bb9a5873a 100644
--- a/Userland/Libraries/LibAudio/MP3Loader.cpp
+++ b/Userland/Libraries/LibAudio/MP3Loader.cpp
@@ -8,6 +8,7 @@
#include "MP3HuffmanTables.h"
#include "MP3Tables.h"
#include <AK/FixedArray.h>
+#include <LibCore/File.h>
namespace Audio {
@@ -21,7 +22,7 @@ MP3LoaderPlugin::MP3LoaderPlugin(NonnullOwnPtr<SeekableStream> stream)
Result<NonnullOwnPtr<MP3LoaderPlugin>, LoaderError> MP3LoaderPlugin::create(StringView path)
{
- auto stream = LOADER_TRY(Core::Stream::BufferedFile::create(LOADER_TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read))));
+ auto stream = LOADER_TRY(Core::BufferedFile::create(LOADER_TRY(Core::File::open(path, Core::File::OpenMode::Read))));
auto loader = make<MP3LoaderPlugin>(move(stream));
LOADER_TRY(loader->initialize());
diff --git a/Userland/Libraries/LibAudio/WavLoader.cpp b/Userland/Libraries/LibAudio/WavLoader.cpp
index f222cd4cfc..3a9723883b 100644
--- a/Userland/Libraries/LibAudio/WavLoader.cpp
+++ b/Userland/Libraries/LibAudio/WavLoader.cpp
@@ -13,6 +13,7 @@
#include <AK/MemoryStream.h>
#include <AK/NumericLimits.h>
#include <AK/Try.h>
+#include <LibCore/File.h>
namespace Audio {
@@ -25,7 +26,7 @@ WavLoaderPlugin::WavLoaderPlugin(NonnullOwnPtr<SeekableStream> stream)
Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> WavLoaderPlugin::create(StringView path)
{
- auto stream = LOADER_TRY(Core::Stream::BufferedFile::create(LOADER_TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read))));
+ auto stream = LOADER_TRY(Core::BufferedFile::create(LOADER_TRY(Core::File::open(path, Core::File::OpenMode::Read))));
auto loader = make<WavLoaderPlugin>(move(stream));
LOADER_TRY(loader->initialize());
diff --git a/Userland/Libraries/LibCore/CMakeLists.txt b/Userland/Libraries/LibCore/CMakeLists.txt
index 1c0e3577f5..f75c9a2068 100644
--- a/Userland/Libraries/LibCore/CMakeLists.txt
+++ b/Userland/Libraries/LibCore/CMakeLists.txt
@@ -10,6 +10,7 @@ set(SOURCES
ElapsedTimer.cpp
Event.cpp
EventLoop.cpp
+ File.cpp
IODevice.cpp
LockFile.cpp
MappedFile.cpp
@@ -25,7 +26,6 @@ set(SOURCES
Socket.cpp
SOCKSProxyClient.cpp
StandardPaths.cpp
- Stream.cpp
System.cpp
SystemServerTakeover.cpp
TCPServer.cpp
diff --git a/Userland/Libraries/LibCore/ConfigFile.cpp b/Userland/Libraries/LibCore/ConfigFile.cpp
index f26f0a0722..7da3e9bc9e 100644
--- a/Userland/Libraries/LibCore/ConfigFile.cpp
+++ b/Userland/Libraries/LibCore/ConfigFile.cpp
@@ -40,8 +40,8 @@ ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open_for_system(DeprecatedString
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& filename, AllowWriting allow_altering)
{
- auto maybe_file = Stream::File::open(filename, allow_altering == AllowWriting::Yes ? Stream::OpenMode::ReadWrite : Stream::OpenMode::Read);
- OwnPtr<Stream::BufferedFile> buffered_file;
+ auto maybe_file = File::open(filename, allow_altering == AllowWriting::Yes ? File::OpenMode::ReadWrite : File::OpenMode::Read);
+ OwnPtr<BufferedFile> buffered_file;
if (maybe_file.is_error()) {
// If we attempted to open a read-only file that does not exist, we ignore the error, making it appear
// the same as if we had opened an empty file. This behavior is a little weird, but is required by
@@ -49,7 +49,7 @@ ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& file
if (!(allow_altering == AllowWriting::No && maybe_file.error().code() == ENOENT))
return maybe_file.release_error();
} else {
- buffered_file = TRY(Stream::BufferedFile::create(maybe_file.release_value()));
+ buffered_file = TRY(BufferedFile::create(maybe_file.release_value()));
}
auto config_file = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ConfigFile(filename, move(buffered_file))));
@@ -59,20 +59,20 @@ ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& file
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& filename, int fd)
{
- auto file = TRY(Stream::File::adopt_fd(fd, Stream::OpenMode::ReadWrite));
+ auto file = TRY(File::adopt_fd(fd, File::OpenMode::ReadWrite));
return open(filename, move(file));
}
-ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& filename, NonnullOwnPtr<Core::Stream::File> file)
+ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& filename, NonnullOwnPtr<Core::File> file)
{
- auto buffered_file = TRY(Stream::BufferedFile::create(move(file)));
+ auto buffered_file = TRY(BufferedFile::create(move(file)));
auto config_file = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ConfigFile(filename, move(buffered_file))));
TRY(config_file->reparse());
return config_file;
}
-ConfigFile::ConfigFile(DeprecatedString const& filename, OwnPtr<Stream::BufferedFile> open_file)
+ConfigFile::ConfigFile(DeprecatedString const& filename, OwnPtr<BufferedFile> open_file)
: m_filename(filename)
, m_file(move(open_file))
{
diff --git a/Userland/Libraries/LibCore/ConfigFile.h b/Userland/Libraries/LibCore/ConfigFile.h
index 04a81790a2..29bfc99e2e 100644
--- a/Userland/Libraries/LibCore/ConfigFile.h
+++ b/Userland/Libraries/LibCore/ConfigFile.h
@@ -14,6 +14,7 @@
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <AK/Vector.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
namespace Core {
@@ -30,7 +31,7 @@ public:
static ErrorOr<NonnullRefPtr<ConfigFile>> open_for_system(DeprecatedString const& app_name, AllowWriting = AllowWriting::No);
static ErrorOr<NonnullRefPtr<ConfigFile>> open(DeprecatedString const& filename, AllowWriting = AllowWriting::No);
static ErrorOr<NonnullRefPtr<ConfigFile>> open(DeprecatedString const& filename, int fd);
- static ErrorOr<NonnullRefPtr<ConfigFile>> open(DeprecatedString const& filename, NonnullOwnPtr<Core::Stream::File>);
+ static ErrorOr<NonnullRefPtr<ConfigFile>> open(DeprecatedString const& filename, NonnullOwnPtr<Core::File>);
~ConfigFile();
bool has_group(DeprecatedString const&) const;
@@ -78,12 +79,12 @@ public:
DeprecatedString const& filename() const { return m_filename; }
private:
- ConfigFile(DeprecatedString const& filename, OwnPtr<Stream::BufferedFile> open_file);
+ ConfigFile(DeprecatedString const& filename, OwnPtr<BufferedFile> open_file);
ErrorOr<void> reparse();
DeprecatedString m_filename;
- OwnPtr<Stream::BufferedFile> m_file;
+ OwnPtr<BufferedFile> m_file;
HashMap<DeprecatedString, HashMap<DeprecatedString, DeprecatedString>> m_groups;
bool m_dirty { false };
};
diff --git a/Userland/Libraries/LibCore/DeprecatedFile.h b/Userland/Libraries/LibCore/DeprecatedFile.h
index 7f9c1b7082..64c1b19fe9 100644
--- a/Userland/Libraries/LibCore/DeprecatedFile.h
+++ b/Userland/Libraries/LibCore/DeprecatedFile.h
@@ -19,7 +19,7 @@ namespace Core {
///
/// Use of Core::File for reading/writing data is deprecated.
-/// Please use Core::Stream::File and Core::Stream::BufferedFile instead.
+/// Please use Core::File and Core::BufferedFile instead.
///
class DeprecatedFile final : public IODevice {
C_OBJECT(DeprecatedFile)
diff --git a/Userland/Libraries/LibCore/Directory.cpp b/Userland/Libraries/LibCore/Directory.cpp
index 6881bb60b4..5e821d16fc 100644
--- a/Userland/Libraries/LibCore/Directory.cpp
+++ b/Userland/Libraries/LibCore/Directory.cpp
@@ -89,10 +89,10 @@ ErrorOr<LexicalPath> Directory::path() const
return m_path.value();
}
-ErrorOr<NonnullOwnPtr<Stream::File>> Directory::open(StringView filename, Stream::OpenMode mode) const
+ErrorOr<NonnullOwnPtr<File>> Directory::open(StringView filename, File::OpenMode mode) const
{
- auto fd = TRY(System::openat(m_directory_fd, filename, Stream::File::open_mode_to_options(mode)));
- return Stream::File::adopt_fd(fd, mode);
+ auto fd = TRY(System::openat(m_directory_fd, filename, File::open_mode_to_options(mode)));
+ return File::adopt_fd(fd, mode);
}
ErrorOr<struct stat> Directory::stat() const
diff --git a/Userland/Libraries/LibCore/Directory.h b/Userland/Libraries/LibCore/Directory.h
index 8518c991e3..c5ef10caf6 100644
--- a/Userland/Libraries/LibCore/Directory.h
+++ b/Userland/Libraries/LibCore/Directory.h
@@ -11,6 +11,7 @@
#include <AK/LexicalPath.h>
#include <AK/Noncopyable.h>
#include <AK/Optional.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <dirent.h>
#include <sys/stat.h>
@@ -37,7 +38,7 @@ public:
static ErrorOr<Directory> create(DeprecatedString path, CreateDirectories, mode_t creation_mode = 0755);
static ErrorOr<Directory> adopt_fd(int fd, Optional<LexicalPath> path = {});
- ErrorOr<NonnullOwnPtr<Stream::File>> open(StringView filename, Stream::OpenMode mode) const;
+ ErrorOr<NonnullOwnPtr<File>> open(StringView filename, File::OpenMode mode) const;
ErrorOr<struct stat> stat() const;
ErrorOr<DirIterator> create_iterator() const;
diff --git a/Userland/Libraries/LibCore/Stream.cpp b/Userland/Libraries/LibCore/File.cpp
index bb929ed911..d9eba43da0 100644
--- a/Userland/Libraries/LibCore/Stream.cpp
+++ b/Userland/Libraries/LibCore/File.cpp
@@ -5,22 +5,12 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include "Stream.h"
+#include <LibCore/File.h>
#include <LibCore/System.h>
#include <fcntl.h>
-#include <netdb.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/types.h>
#include <unistd.h>
-#ifdef AK_OS_SERENITY
-# include <serenity.h>
-#endif
-#ifdef AK_OS_FREEBSD
-# include <sys/ucred.h>
-#endif
-namespace Core::Stream {
+namespace Core {
ErrorOr<NonnullOwnPtr<File>> File::open(StringView filename, OpenMode mode, mode_t permissions)
{
@@ -36,7 +26,7 @@ ErrorOr<NonnullOwnPtr<File>> File::adopt_fd(int fd, OpenMode mode, ShouldCloseFi
}
if (!has_any_flag(mode, OpenMode::ReadWrite)) {
- dbgln("Core::DeprecatedFile::adopt_fd: Attempting to adopt a file with neither Read nor Write specified in mode");
+ dbgln("Core::File::adopt_fd: Attempting to adopt a file with neither Read nor Write specified in mode");
return Error::from_errno(EINVAL);
}
diff --git a/Userland/Libraries/LibCore/File.h b/Userland/Libraries/LibCore/File.h
new file mode 100644
index 0000000000..dce8fd78e9
--- /dev/null
+++ b/Userland/Libraries/LibCore/File.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2021, sin-ack <sin-ack@protonmail.com>
+ * Copyright (c) 2022, the SerenityOS developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/Badge.h>
+#include <AK/BufferedStream.h>
+#include <AK/Noncopyable.h>
+#include <AK/NonnullOwnPtr.h>
+#include <AK/Stream.h>
+#include <LibIPC/Forward.h>
+
+namespace Core {
+
+class File final : public SeekableStream {
+ AK_MAKE_NONCOPYABLE(File);
+
+public:
+ enum class OpenMode : unsigned {
+ NotOpen = 0,
+ Read = 1,
+ Write = 2,
+ ReadWrite = 3,
+ Append = 4,
+ Truncate = 8,
+ MustBeNew = 16,
+ KeepOnExec = 32,
+ Nonblocking = 64,
+ };
+
+ enum class ShouldCloseFileDescriptor {
+ Yes,
+ No,
+ };
+
+ static ErrorOr<NonnullOwnPtr<File>> open(StringView filename, OpenMode, mode_t = 0644);
+ static ErrorOr<NonnullOwnPtr<File>> adopt_fd(int fd, OpenMode, ShouldCloseFileDescriptor = ShouldCloseFileDescriptor::Yes);
+
+ static ErrorOr<NonnullOwnPtr<File>> standard_input();
+ static ErrorOr<NonnullOwnPtr<File>> standard_output();
+ static ErrorOr<NonnullOwnPtr<File>> standard_error();
+ static ErrorOr<NonnullOwnPtr<File>> open_file_or_standard_stream(StringView filename, OpenMode mode);
+
+ File(File&& other) { operator=(move(other)); }
+
+ File& operator=(File&& other)
+ {
+ if (&other == this)
+ return *this;
+
+ m_mode = exchange(other.m_mode, OpenMode::NotOpen);
+ m_fd = exchange(other.m_fd, -1);
+ m_last_read_was_eof = exchange(other.m_last_read_was_eof, false);
+ return *this;
+ }
+
+ virtual ErrorOr<Bytes> read(Bytes) override;
+ virtual ErrorOr<ByteBuffer> read_until_eof(size_t block_size = 4096) override;
+ virtual ErrorOr<size_t> write(ReadonlyBytes) override;
+ virtual bool is_eof() const override;
+ virtual bool is_open() const override;
+ virtual void close() override;
+ virtual ErrorOr<size_t> seek(i64 offset, SeekMode) override;
+ virtual ErrorOr<void> truncate(size_t length) override;
+
+ int leak_fd(Badge<::IPC::File>)
+ {
+ m_should_close_file_descriptor = ShouldCloseFileDescriptor::No;
+ return m_fd;
+ }
+
+ int fd() const
+ {
+ return m_fd;
+ }
+
+ virtual ~File() override
+ {
+ if (m_should_close_file_descriptor == ShouldCloseFileDescriptor::Yes)
+ close();
+ }
+
+ static int open_mode_to_options(OpenMode mode);
+
+private:
+ File(OpenMode mode, ShouldCloseFileDescriptor should_close = ShouldCloseFileDescriptor::Yes)
+ : m_mode(mode)
+ , m_should_close_file_descriptor(should_close)
+ {
+ }
+
+ ErrorOr<void> open_path(StringView filename, mode_t);
+
+ OpenMode m_mode { OpenMode::NotOpen };
+ int m_fd { -1 };
+ bool m_last_read_was_eof { false };
+ ShouldCloseFileDescriptor m_should_close_file_descriptor { ShouldCloseFileDescriptor::Yes };
+};
+
+AK_ENUM_BITWISE_OPERATORS(File::OpenMode)
+
+using BufferedFile = BufferedSeekable<File>;
+
+}
diff --git a/Userland/Libraries/LibCore/Forward.h b/Userland/Libraries/LibCore/Forward.h
index dff8a2aad3..a0e81ec885 100644
--- a/Userland/Libraries/LibCore/Forward.h
+++ b/Userland/Libraries/LibCore/Forward.h
@@ -21,6 +21,7 @@ class DeferredInvocationContext;
class ElapsedTimer;
class Event;
class EventLoop;
+class File;
class IODevice;
class LocalServer;
class LocalSocket;
@@ -42,8 +43,4 @@ class UDPSocket;
enum class TimerShouldFireWhenNotVisible;
-namespace Stream {
-class File;
-}
-
}
diff --git a/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp b/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp
index cb6726cc44..ccb423e7c7 100644
--- a/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp
+++ b/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp
@@ -8,6 +8,7 @@
#include <AK/JsonArray.h>
#include <AK/JsonObject.h>
#include <AK/JsonValue.h>
+#include <LibCore/File.h>
#include <LibCore/ProcessStatisticsReader.h>
#include <pwd.h>
@@ -90,7 +91,7 @@ ErrorOr<AllProcessesStatistics> ProcessStatisticsReader::get_all(SeekableStream&
ErrorOr<AllProcessesStatistics> ProcessStatisticsReader::get_all(bool include_usernames)
{
- auto proc_all_file = TRY(Core::Stream::File::open("/sys/kernel/processes"sv, Core::Stream::OpenMode::Read));
+ auto proc_all_file = TRY(Core::File::open("/sys/kernel/processes"sv, Core::File::OpenMode::Read));
return get_all(*proc_all_file, include_usernames);
}
diff --git a/Userland/Libraries/LibCore/Stream.h b/Userland/Libraries/LibCore/Stream.h
index 791257c127..93f5cd6d67 100644
--- a/Userland/Libraries/LibCore/Stream.h
+++ b/Userland/Libraries/LibCore/Stream.h
@@ -25,98 +25,3 @@
#include <LibIPC/Forward.h>
#include <errno.h>
#include <netdb.h>
-
-namespace Core::Stream {
-
-// Concrete classes.
-
-enum class OpenMode : unsigned {
- NotOpen = 0,
- Read = 1,
- Write = 2,
- ReadWrite = 3,
- Append = 4,
- Truncate = 8,
- MustBeNew = 16,
- KeepOnExec = 32,
- Nonblocking = 64,
-};
-
-enum class ShouldCloseFileDescriptor {
- Yes,
- No,
-};
-
-AK_ENUM_BITWISE_OPERATORS(OpenMode)
-
-class File final : public SeekableStream {
- AK_MAKE_NONCOPYABLE(File);
-
-public:
- static ErrorOr<NonnullOwnPtr<File>> open(StringView filename, OpenMode, mode_t = 0644);
- static ErrorOr<NonnullOwnPtr<File>> adopt_fd(int fd, OpenMode, ShouldCloseFileDescriptor = ShouldCloseFileDescriptor::Yes);
-
- static ErrorOr<NonnullOwnPtr<File>> standard_input();
- static ErrorOr<NonnullOwnPtr<File>> standard_output();
- static ErrorOr<NonnullOwnPtr<File>> standard_error();
- static ErrorOr<NonnullOwnPtr<File>> open_file_or_standard_stream(StringView filename, OpenMode mode);
-
- File(File&& other) { operator=(move(other)); }
-
- File& operator=(File&& other)
- {
- if (&other == this)
- return *this;
-
- m_mode = exchange(other.m_mode, OpenMode::NotOpen);
- m_fd = exchange(other.m_fd, -1);
- m_last_read_was_eof = exchange(other.m_last_read_was_eof, false);
- return *this;
- }
-
- virtual ErrorOr<Bytes> read(Bytes) override;
- virtual ErrorOr<ByteBuffer> read_until_eof(size_t block_size = 4096) override;
- virtual ErrorOr<size_t> write(ReadonlyBytes) override;
- virtual bool is_eof() const override;
- virtual bool is_open() const override;
- virtual void close() override;
- virtual ErrorOr<size_t> seek(i64 offset, SeekMode) override;
- virtual ErrorOr<void> truncate(size_t length) override;
-
- int leak_fd(Badge<::IPC::File>)
- {
- m_should_close_file_descriptor = ShouldCloseFileDescriptor::No;
- return m_fd;
- }
-
- int fd() const
- {
- return m_fd;
- }
-
- virtual ~File() override
- {
- if (m_should_close_file_descriptor == ShouldCloseFileDescriptor::Yes)
- close();
- }
-
- static int open_mode_to_options(OpenMode mode);
-
-private:
- File(OpenMode mode, ShouldCloseFileDescriptor should_close = ShouldCloseFileDescriptor::Yes)
- : m_mode(mode)
- , m_should_close_file_descriptor(should_close)
- {
- }
-
- ErrorOr<void> open_path(StringView filename, mode_t);
-
- OpenMode m_mode { OpenMode::NotOpen };
- int m_fd { -1 };
- bool m_last_read_was_eof { false };
- ShouldCloseFileDescriptor m_should_close_file_descriptor { ShouldCloseFileDescriptor::Yes };
-};
-
-using BufferedFile = BufferedSeekable<File>;
-
-}
diff --git a/Userland/Libraries/LibFileSystemAccessClient/Client.cpp b/Userland/Libraries/LibFileSystemAccessClient/Client.cpp
index ea57978b0b..05cdd029d2 100644
--- a/Userland/Libraries/LibFileSystemAccessClient/Client.cpp
+++ b/Userland/Libraries/LibFileSystemAccessClient/Client.cpp
@@ -72,23 +72,23 @@ Result Client::request_file_read_only_approved(GUI::Window* parent_window, Depre
return handle_promise<Result>(id);
}
-static Core::Stream::OpenMode to_stream_open_mode(Core::OpenMode open_mode)
+static Core::File::OpenMode to_stream_open_mode(Core::OpenMode open_mode)
{
- Core::Stream::OpenMode result {};
+ Core::File::OpenMode result {};
if ((open_mode & Core::OpenMode::ReadOnly) == Core::OpenMode::ReadOnly)
- result |= Core::Stream::OpenMode::Read;
+ result |= Core::File::OpenMode::Read;
if ((open_mode & Core::OpenMode::WriteOnly) == Core::OpenMode::WriteOnly)
- result |= Core::Stream::OpenMode::Write;
+ result |= Core::File::OpenMode::Write;
if ((open_mode & Core::OpenMode::ReadWrite) == Core::OpenMode::ReadWrite)
- result |= Core::Stream::OpenMode::ReadWrite;
+ result |= Core::File::OpenMode::ReadWrite;
if ((open_mode & Core::OpenMode::Append) == Core::OpenMode::Append)
- result |= Core::Stream::OpenMode::Append;
+ result |= Core::File::OpenMode::Append;
if ((open_mode & Core::OpenMode::Truncate) == Core::OpenMode::Truncate)
- result |= Core::Stream::OpenMode::Truncate;
+ result |= Core::File::OpenMode::Truncate;
if ((open_mode & Core::OpenMode::MustBeNew) == Core::OpenMode::MustBeNew)
- result |= Core::Stream::OpenMode::MustBeNew;
+ result |= Core::File::OpenMode::MustBeNew;
if ((open_mode & Core::OpenMode::KeepOnExec) == Core::OpenMode::KeepOnExec)
- result |= Core::Stream::OpenMode::KeepOnExec;
+ result |= Core::File::OpenMode::KeepOnExec;
return result;
}
@@ -120,7 +120,7 @@ DeprecatedResult Client::try_request_file_deprecated(GUI::Window* parent_window,
return handle_promise<DeprecatedResult>(id);
}
-Result Client::request_file(GUI::Window* parent_window, DeprecatedString const& path, Core::Stream::OpenMode mode)
+Result Client::request_file(GUI::Window* parent_window, DeprecatedString const& path, Core::File::OpenMode mode)
{
auto const id = get_new_id();
m_promises.set(id, PromiseAndWindow { { Core::Promise<Result>::construct() }, parent_window });
@@ -167,7 +167,7 @@ DeprecatedResult Client::try_open_file_deprecated(GUI::Window* parent_window, De
return handle_promise<DeprecatedResult>(id);
}
-Result Client::open_file(GUI::Window* parent_window, DeprecatedString const& window_title, StringView path, Core::Stream::OpenMode requested_access)
+Result Client::open_file(GUI::Window* parent_window, DeprecatedString const& window_title, StringView path, Core::File::OpenMode requested_access)
{
auto const id = get_new_id();
m_promises.set(id, PromiseAndWindow { { Core::Promise<Result>::construct() }, parent_window });
@@ -209,7 +209,7 @@ DeprecatedResult Client::try_save_file_deprecated(GUI::Window* parent_window, De
return handle_promise<DeprecatedResult>(id);
}
-Result Client::save_file(GUI::Window* parent_window, DeprecatedString const& name, DeprecatedString const ext, Core::Stream::OpenMode requested_access)
+Result Client::save_file(GUI::Window* parent_window, DeprecatedString const& name, DeprecatedString const ext, Core::File::OpenMode requested_access)
{
auto const id = get_new_id();
m_promises.set(id, PromiseAndWindow { { Core::Promise<Result>::construct() }, parent_window });
@@ -275,7 +275,7 @@ void Client::handle_prompt_end(i32 request_id, i32 error, Optional<IPC::File> co
}
auto file_or_error = [&]() -> ErrorOr<File> {
- auto stream = TRY(Core::Stream::File::adopt_fd(ipc_file->take_fd(), Core::Stream::OpenMode::ReadWrite));
+ auto stream = TRY(Core::File::adopt_fd(ipc_file->take_fd(), Core::File::OpenMode::ReadWrite));
auto filename = TRY(String::from_deprecated_string(*chosen_file));
return File({}, move(stream), filename);
}();
diff --git a/Userland/Libraries/LibFileSystemAccessClient/Client.h b/Userland/Libraries/LibFileSystemAccessClient/Client.h
index d44d136d59..c5e5f18418 100644
--- a/Userland/Libraries/LibFileSystemAccessClient/Client.h
+++ b/Userland/Libraries/LibFileSystemAccessClient/Client.h
@@ -22,18 +22,18 @@ namespace FileSystemAccessClient {
class Client;
class File {
public:
- File(Badge<Client>, NonnullOwnPtr<Core::Stream::File> stream, String filename)
+ File(Badge<Client>, NonnullOwnPtr<Core::File> stream, String filename)
: m_stream(move(stream))
, m_filename(filename)
{
}
- Core::Stream::File& stream() const { return *m_stream; }
- NonnullOwnPtr<Core::Stream::File> release_stream() { return move(m_stream); }
+ Core::File& stream() const { return *m_stream; }
+ NonnullOwnPtr<Core::File> release_stream() { return move(m_stream); }
String filename() const { return m_filename; }
private:
- NonnullOwnPtr<Core::Stream::File> m_stream;
+ NonnullOwnPtr<Core::File> m_stream;
String m_filename;
};
@@ -52,9 +52,9 @@ public:
DeprecatedResult try_save_file_deprecated(GUI::Window* parent_window, DeprecatedString const& name, DeprecatedString const ext, Core::OpenMode requested_access = Core::OpenMode::WriteOnly | Core::OpenMode::Truncate);
Result request_file_read_only_approved(GUI::Window* parent_window, DeprecatedString const& path);
- Result request_file(GUI::Window* parent_window, DeprecatedString const& path, Core::Stream::OpenMode requested_access);
- Result open_file(GUI::Window* parent_window, DeprecatedString const& window_title = {}, StringView path = Core::StandardPaths::home_directory(), Core::Stream::OpenMode requested_access = Core::Stream::OpenMode::Read);
- Result save_file(GUI::Window* parent_window, DeprecatedString const& name, DeprecatedString const ext, Core::Stream::OpenMode requested_access = Core::Stream::OpenMode::Write | Core::Stream::OpenMode::Truncate);
+ Result request_file(GUI::Window* parent_window, DeprecatedString const& path, Core::File::OpenMode requested_access);
+ Result open_file(GUI::Window* parent_window, DeprecatedString const& window_title = {}, StringView path = Core::StandardPaths::home_directory(), Core::File::OpenMode requested_access = Core::File::OpenMode::Read);
+ Result save_file(GUI::Window* parent_window, DeprecatedString const& name, DeprecatedString const ext, Core::File::OpenMode requested_access = Core::File::OpenMode::Write | Core::File::OpenMode::Truncate);
static Client& the();
diff --git a/Userland/Libraries/LibGUI/AbstractThemePreview.cpp b/Userland/Libraries/LibGUI/AbstractThemePreview.cpp
index df70abeb01..e3c6523048 100644
--- a/Userland/Libraries/LibGUI/AbstractThemePreview.cpp
+++ b/Userland/Libraries/LibGUI/AbstractThemePreview.cpp
@@ -84,7 +84,7 @@ void AbstractThemePreview::set_theme(Core::AnonymousBuffer const& theme_buffer)
set_preview_palette(m_preview_palette);
}
-ErrorOr<void> AbstractThemePreview::set_theme_from_file(StringView path, NonnullOwnPtr<Core::Stream::File> file)
+ErrorOr<void> AbstractThemePreview::set_theme_from_file(StringView path, NonnullOwnPtr<Core::File> file)
{
auto config_file = TRY(Core::ConfigFile::open(path, move(file)));
auto theme = TRY(Gfx::load_system_theme(config_file));
diff --git a/Userland/Libraries/LibGUI/AbstractThemePreview.h b/Userland/Libraries/LibGUI/AbstractThemePreview.h
index 5800262133..203c408406 100644
--- a/Userland/Libraries/LibGUI/AbstractThemePreview.h
+++ b/Userland/Libraries/LibGUI/AbstractThemePreview.h
@@ -24,7 +24,7 @@ public:
Gfx::Palette const& preview_palette() const { return m_preview_palette; }
void set_preview_palette(Gfx::Palette const&);
- ErrorOr<void> set_theme_from_file(StringView path, NonnullOwnPtr<Core::Stream::File>);
+ ErrorOr<void> set_theme_from_file(StringView path, NonnullOwnPtr<Core::File>);
void set_theme(Core::AnonymousBuffer const&);
void paint_window(StringView title, Gfx::IntRect const& rect, Gfx::WindowTheme::WindowState, Gfx::Bitmap const& icon, int button_count = 3);
diff --git a/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp b/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp
index 9beebbf005..99186d1d15 100644
--- a/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp
+++ b/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp
@@ -9,6 +9,7 @@
#include <AK/JsonObject.h>
#include <AK/Vector.h>
#include <LibCore/DeprecatedFile.h>
+#include <LibCore/File.h>
#include <LibCore/StandardPaths.h>
#include <LibCore/Stream.h>
#include <LibGUI/CommonLocationsProvider.h>
@@ -42,7 +43,7 @@ static void initialize_if_needed()
ErrorOr<void> CommonLocationsProvider::load_from_json(StringView json_path)
{
- auto file = TRY(Core::Stream::File::open(json_path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(json_path, Core::File::OpenMode::Read));
auto json = JsonValue::from_string(TRY(file->read_until_eof()));
if (json.is_error())
return Error::from_string_literal("File is not a valid JSON");
diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp
index 622a8902ee..4edf154662 100644
--- a/Userland/Libraries/LibGUI/TextEditor.cpp
+++ b/Userland/Libraries/LibGUI/TextEditor.cpp
@@ -1460,12 +1460,12 @@ void TextEditor::timer_event(Core::TimerEvent&)
ErrorOr<void> TextEditor::write_to_file(StringView path)
{
- auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Write | Core::Stream::OpenMode::Truncate));
+ auto file = TRY(Core::File::open(path, Core::File::OpenMode::Write | Core::File::OpenMode::Truncate));
TRY(write_to_file(*file));
return {};
}
-ErrorOr<void> TextEditor::write_to_file(Core::Stream::File& file)
+ErrorOr<void> TextEditor::write_to_file(Core::File& file)
{
off_t file_size = 0;
if (line_count() == 1 && line(0).is_empty()) {
diff --git a/Userland/Libraries/LibGUI/TextEditor.h b/Userland/Libraries/LibGUI/TextEditor.h
index 34435a0a0e..b5bce27807 100644
--- a/Userland/Libraries/LibGUI/TextEditor.h
+++ b/Userland/Libraries/LibGUI/TextEditor.h
@@ -130,7 +130,7 @@ public:
void insert_at_cursor_or_replace_selection(StringView);
void replace_all_text_without_resetting_undo_stack(StringView text);
ErrorOr<void> write_to_file(StringView path);
- ErrorOr<void> write_to_file(Core::Stream::File&);
+ ErrorOr<void> write_to_file(Core::File&);
bool has_selection() const { return m_selection.is_valid(); }
DeprecatedString selected_text() const;
size_t number_of_words() const;
diff --git a/Userland/Libraries/LibGfx/Font/BitmapFont.cpp b/Userland/Libraries/LibGfx/Font/BitmapFont.cpp
index 6aabeefebb..5db821d27b 100644
--- a/Userland/Libraries/LibGfx/Font/BitmapFont.cpp
+++ b/Userland/Libraries/LibGfx/Font/BitmapFont.cpp
@@ -9,6 +9,7 @@
#include <AK/BuiltinWrappers.h>
#include <AK/Utf32View.h>
#include <AK/Utf8View.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibGfx/Font/FontDatabase.h>
#include <LibGfx/Font/FontStyleMapping.h>
@@ -257,7 +258,7 @@ ErrorOr<void> BitmapFont::write_to_file(DeprecatedString const& path)
memcpy(header.name, m_name.characters(), min(m_name.length(), sizeof(header.name) - 1));
memcpy(header.family, m_family.characters(), min(m_family.length(), sizeof(header.family) - 1));
- auto stream = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Write));
+ auto stream = TRY(Core::File::open(path, Core::File::OpenMode::Write));
size_t bytes_per_glyph = sizeof(u32) * m_glyph_height;
TRY(stream->write_entire_buffer({ &header, sizeof(header) }));
TRY(stream->write_entire_buffer({ m_range_mask, m_range_mask_size }));
diff --git a/Userland/Libraries/LibIDL/IDLParser.cpp b/Userland/Libraries/LibIDL/IDLParser.cpp
index 2fe98cdd21..1e2dabb01e 100644
--- a/Userland/Libraries/LibIDL/IDLParser.cpp
+++ b/Userland/Libraries/LibIDL/IDLParser.cpp
@@ -12,6 +12,7 @@
#include <AK/LexicalPath.h>
#include <AK/QuickSort.h>
#include <LibCore/DeprecatedFile.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
[[noreturn]] static void report_parsing_error(StringView message, StringView filename, StringView input, size_t offset)
@@ -149,7 +150,7 @@ Optional<Interface&> Parser::resolve_import(auto path)
report_parsing_error(DeprecatedString::formatted("Circular import detected: {}", include_path), filename, input, lexer.tell());
import_stack.set(real_path);
- auto file_or_error = Core::Stream::File::open(real_path, Core::Stream::OpenMode::Read);
+ auto file_or_error = Core::File::open(real_path, Core::File::OpenMode::Read);
if (file_or_error.is_error())
report_parsing_error(DeprecatedString::formatted("Failed to open {}: {}", real_path, file_or_error.error()), filename, input, lexer.tell());
diff --git a/Userland/Libraries/LibIPC/File.h b/Userland/Libraries/LibIPC/File.h
index 09453b8149..d19156709e 100644
--- a/Userland/Libraries/LibIPC/File.h
+++ b/Userland/Libraries/LibIPC/File.h
@@ -9,6 +9,7 @@
#include <AK/Noncopyable.h>
#include <AK/StdLibExtras.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <unistd.h>
@@ -41,7 +42,7 @@ public:
}
template<typename... Args>
- File(Core::Stream::File& file, Args... args)
+ File(Core::File& file, Args... args)
: File(file.leak_fd(Badge<File> {}), args...)
{
}
diff --git a/Userland/Libraries/LibLine/Editor.cpp b/Userland/Libraries/LibLine/Editor.cpp
index ad165c79c3..722df187b5 100644
--- a/Userland/Libraries/LibLine/Editor.cpp
+++ b/Userland/Libraries/LibLine/Editor.cpp
@@ -602,7 +602,7 @@ ErrorOr<void> Editor::interrupted()
m_finish = false;
{
- auto stderr_stream = TRY(Core::Stream::File::standard_error());
+ auto stderr_stream = TRY(Core::File::standard_error());
TRY(reposition_cursor(*stderr_stream, true));
if (TRY(m_suggestion_display->cleanup()))
TRY(reposition_cursor(*stderr_stream, true));
@@ -648,7 +648,7 @@ ErrorOr<void> Editor::handle_resize_event(bool reset_origin)
set_origin(m_origin_row, 1);
- auto stderr_stream = TRY(Core::Stream::File::standard_error());
+ auto stderr_stream = TRY(Core::File::standard_error());
TRY(reposition_cursor(*stderr_stream, true));
TRY(m_suggestion_display->redisplay(m_suggestion_manager, m_num_lines, m_num_columns));
@@ -665,7 +665,7 @@ ErrorOr<void> Editor::really_quit_event_loop()
{
m_finish = false;
{
- auto stderr_stream = TRY(Core::Stream::File::standard_error());
+ auto stderr_stream = TRY(Core::File::standard_error());
TRY(reposition_cursor(*stderr_stream, true));
TRY(stderr_stream->write_entire_buffer("\n"sv.bytes()));
}
@@ -731,7 +731,7 @@ auto Editor::get_line(DeprecatedString const& prompt) -> Result<DeprecatedString
strip_styles(true);
{
- auto stderr_stream = Core::Stream::File::standard_error().release_value_but_fixme_should_propagate_errors();
+ auto stderr_stream = Core::File::standard_error().release_value_but_fixme_should_propagate_errors();
auto prompt_lines = max(current_prompt_metrics().line_metrics.size(), 1ul) - 1;
for (size_t i = 0; i < prompt_lines; ++i)
stderr_stream->write_entire_buffer("\n"sv.bytes()).release_value_but_fixme_should_propagate_errors();
@@ -1173,7 +1173,7 @@ ErrorOr<void> Editor::handle_read_event()
for (auto& view : completion_result.insert)
insert(view);
- auto stderr_stream = TRY(Core::Stream::File::standard_error());
+ auto stderr_stream = TRY(Core::File::standard_error());
TRY(reposition_cursor(*stderr_stream));
if (completion_result.style_to_apply.has_value()) {
@@ -1252,7 +1252,7 @@ ErrorOr<void> Editor::cleanup_suggestions()
// We probably have some suggestions drawn,
// let's clean them up.
if (TRY(m_suggestion_display->cleanup())) {
- auto stderr_stream = TRY(Core::Stream::File::standard_error());
+ auto stderr_stream = TRY(Core::File::standard_error());
TRY(reposition_cursor(*stderr_stream));
m_refresh_needed = true;
}
@@ -1326,7 +1326,7 @@ ErrorOr<void> Editor::cleanup()
if (new_lines < m_shown_lines)
m_extra_forward_lines = max(m_shown_lines - new_lines, m_extra_forward_lines);
- auto stderr_stream = TRY(Core::Stream::File::standard_error());
+ auto stderr_stream = TRY(Core::File::standard_error());
TRY(reposition_cursor(*stderr_stream, true));
auto current_line = num_lines() - 1;
TRY(VT::clear_lines(current_line, m_extra_forward_lines, *stderr_stream));
diff --git a/Userland/Libraries/LibLine/InternalFunctions.cpp b/Userland/Libraries/LibLine/InternalFunctions.cpp
index 32e520baf5..5b137debd7 100644
--- a/Userland/Libraries/LibLine/InternalFunctions.cpp
+++ b/Userland/Libraries/LibLine/InternalFunctions.cpp
@@ -9,6 +9,7 @@
#include <AK/ScopedValueRollback.h>
#include <AK/StringBuilder.h>
#include <AK/TemporaryChange.h>
+#include <LibCore/File.h>
#include <LibLine/Editor.h>
#include <stdio.h>
#include <sys/wait.h>
@@ -341,7 +342,7 @@ void Editor::enter_search()
auto& search_string = search_string_result.value();
// Manually cleanup the search line.
- auto stderr_stream = Core::Stream::File::standard_error().release_value_but_fixme_should_propagate_errors();
+ auto stderr_stream = Core::File::standard_error().release_value_but_fixme_should_propagate_errors();
reposition_cursor(*stderr_stream).release_value_but_fixme_should_propagate_errors();
auto search_metrics = actual_rendered_string_metrics(search_string, {});
auto metrics = actual_rendered_string_metrics(search_prompt, {});
@@ -433,7 +434,7 @@ void Editor::go_end()
void Editor::clear_screen()
{
warn("\033[3J\033[H\033[2J");
- auto stream = Core::Stream::File::standard_error().release_value_but_fixme_should_propagate_errors();
+ auto stream = Core::File::standard_error().release_value_but_fixme_should_propagate_errors();
VT::move_absolute(1, 1, *stream).release_value_but_fixme_should_propagate_errors();
set_origin(1, 1);
m_refresh_needed = true;
@@ -528,7 +529,7 @@ void Editor::edit_in_external_editor()
{
auto write_fd = dup(fd);
- auto stream = Core::Stream::File::adopt_fd(write_fd, Core::Stream::OpenMode::Write).release_value_but_fixme_should_propagate_errors();
+ auto stream = Core::File::adopt_fd(write_fd, Core::File::OpenMode::Write).release_value_but_fixme_should_propagate_errors();
StringBuilder builder;
builder.append(Utf32View { m_buffer.data(), m_buffer.size() });
auto bytes = builder.string_view().bytes();
@@ -569,7 +570,7 @@ void Editor::edit_in_external_editor()
}
{
- auto file = Core::Stream::File::open({ file_path, strlen(file_path) }, Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
+ auto file = Core::File::open({ file_path, strlen(file_path) }, Core::File::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
auto contents = file->read_until_eof().release_value_but_fixme_should_propagate_errors();
StringView data { contents };
while (data.ends_with('\n'))
diff --git a/Userland/Libraries/LibLine/XtermSuggestionDisplay.cpp b/Userland/Libraries/LibLine/XtermSuggestionDisplay.cpp
index ace6d42f07..5a51e95183 100644
--- a/Userland/Libraries/LibLine/XtermSuggestionDisplay.cpp
+++ b/Userland/Libraries/LibLine/XtermSuggestionDisplay.cpp
@@ -7,6 +7,7 @@
#include <AK/BinarySearch.h>
#include <AK/Function.h>
#include <AK/StringBuilder.h>
+#include <LibCore/File.h>
#include <LibLine/SuggestionDisplay.h>
#include <LibLine/VT.h>
#include <stdio.h>
@@ -17,7 +18,7 @@ ErrorOr<void> XtermSuggestionDisplay::display(SuggestionManager const& manager)
{
did_display();
- auto stderr_stream = TRY(Core::Stream::File::standard_error());
+ auto stderr_stream = TRY(Core::File::standard_error());
size_t longest_suggestion_length = 0;
size_t longest_suggestion_byte_length = 0;
@@ -161,7 +162,7 @@ ErrorOr<bool> XtermSuggestionDisplay::cleanup()
did_cleanup();
if (m_lines_used_for_last_suggestions) {
- auto stderr_stream = TRY(Core::Stream::File::standard_error());
+ auto stderr_stream = TRY(Core::File::standard_error());
TRY(VT::clear_lines(0, m_lines_used_for_last_suggestions, *stderr_stream));
m_lines_used_for_last_suggestions = 0;
return true;
diff --git a/Userland/Libraries/LibProtocol/Request.cpp b/Userland/Libraries/LibProtocol/Request.cpp
index 882372217d..d533c33ec8 100644
--- a/Userland/Libraries/LibProtocol/Request.cpp
+++ b/Userland/Libraries/LibProtocol/Request.cpp
@@ -24,7 +24,7 @@ void Request::stream_into(AK::Stream& stream)
{
VERIFY(!m_internal_stream_data);
- m_internal_stream_data = make<InternalStreamData>(MUST(Core::Stream::File::adopt_fd(fd(), Core::Stream::OpenMode::Read)));
+ m_internal_stream_data = make<InternalStreamData>(MUST(Core::File::adopt_fd(fd(), Core::File::OpenMode::Read)));
m_internal_stream_data->read_notifier = Core::Notifier::construct(fd(), Core::Notifier::Read);
auto user_on_finish = move(on_finish);
diff --git a/Userland/Libraries/LibSQL/Heap.cpp b/Userland/Libraries/LibSQL/Heap.cpp
index 6ad28a51d0..3dff07f800 100644
--- a/Userland/Libraries/LibSQL/Heap.cpp
+++ b/Userland/Libraries/LibSQL/Heap.cpp
@@ -47,8 +47,8 @@ ErrorOr<void> Heap::open()
if (file_size > 0)
m_next_block = m_end_of_file = file_size / BLOCKSIZE;
- auto file = TRY(Core::Stream::File::open(name(), Core::Stream::OpenMode::ReadWrite));
- m_file = TRY(Core::Stream::BufferedFile::create(move(file)));
+ auto file = TRY(Core::File::open(name(), Core::File::OpenMode::ReadWrite));
+ m_file = TRY(Core::BufferedFile::create(move(file)));
if (file_size > 0) {
if (auto error_maybe = read_zero_block(); error_maybe.is_error()) {
diff --git a/Userland/Libraries/LibSQL/Heap.h b/Userland/Libraries/LibSQL/Heap.h
index 492141fa08..fa1a2cc9fe 100644
--- a/Userland/Libraries/LibSQL/Heap.h
+++ b/Userland/Libraries/LibSQL/Heap.h
@@ -11,6 +11,7 @@
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/Vector.h>
+#include <LibCore/File.h>
#include <LibCore/Object.h>
#include <LibCore/Stream.h>
@@ -99,7 +100,7 @@ private:
void initialize_zero_block();
void update_zero_block();
- OwnPtr<Core::Stream::BufferedFile> m_file;
+ OwnPtr<Core::BufferedFile> m_file;
u32 m_free_list { 0 };
u32 m_next_block { 1 };
u32 m_end_of_file { 1 };
diff --git a/Userland/Libraries/LibSQL/SQLClient.cpp b/Userland/Libraries/LibSQL/SQLClient.cpp
index 36236487ed..08c9ec8c2d 100644
--- a/Userland/Libraries/LibSQL/SQLClient.cpp
+++ b/Userland/Libraries/LibSQL/SQLClient.cpp
@@ -67,7 +67,7 @@ static ErrorOr<void> launch_server(DeprecatedString const& socket_path, Deprecat
server_pid = TRY(Core::System::fork());
if (server_pid != 0) {
- auto server_pid_file = TRY(Core::Stream::File::open(pid_path, Core::Stream::OpenMode::Write));
+ auto server_pid_file = TRY(Core::File::open(pid_path, Core::File::OpenMode::Write));
TRY(server_pid_file->write(DeprecatedString::number(server_pid).bytes()));
TRY(Core::System::kill(getpid(), SIGTERM));
@@ -108,7 +108,7 @@ static ErrorOr<bool> should_launch_server(DeprecatedString const& pid_path)
Optional<pid_t> pid;
{
- auto server_pid_file = Core::Stream::File::open(pid_path, Core::Stream::OpenMode::Read);
+ auto server_pid_file = Core::File::open(pid_path, Core::File::OpenMode::Read);
if (server_pid_file.is_error()) {
warnln("Could not open SQLServer PID file '{}': {}", pid_path, server_pid_file.error());
return server_pid_file.release_error();
diff --git a/Userland/Libraries/LibTLS/HandshakeClient.cpp b/Userland/Libraries/LibTLS/HandshakeClient.cpp
index 55287b7df7..7055531892 100644
--- a/Userland/Libraries/LibTLS/HandshakeClient.cpp
+++ b/Userland/Libraries/LibTLS/HandshakeClient.cpp
@@ -140,7 +140,7 @@ bool TLSv12::compute_master_secret_from_pre_master_secret(size_t length)
}
if constexpr (TLS_SSL_KEYLOG_DEBUG) {
- auto file = MUST(Core::Stream::File::open("/home/anon/ssl_keylog"sv, Core::Stream::OpenMode::Append | Core::Stream::OpenMode::Write));
+ auto file = MUST(Core::File::open("/home/anon/ssl_keylog"sv, Core::File::OpenMode::Append | Core::File::OpenMode::Write));
MUST(file->write_entire_buffer("CLIENT_RANDOM "sv.bytes()));
MUST(file->write_entire_buffer(encode_hex({ m_context.local_random, 32 }).bytes()));
MUST(file->write_entire_buffer(" "sv.bytes()));
diff --git a/Userland/Libraries/LibTest/JavaScriptTestRunner.h b/Userland/Libraries/LibTest/JavaScriptTestRunner.h
index 997802532a..7263612604 100644
--- a/Userland/Libraries/LibTest/JavaScriptTestRunner.h
+++ b/Userland/Libraries/LibTest/JavaScriptTestRunner.h
@@ -17,6 +17,7 @@
#include <AK/Result.h>
#include <AK/Tuple.h>
#include <LibCore/DirIterator.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibJS/Bytecode/Interpreter.h>
#include <LibJS/Interpreter.h>
@@ -217,7 +218,7 @@ inline JS::ThrowCompletionOr<void> TestRunnerGlobalObject::initialize(JS::Realm&
inline ByteBuffer load_entire_file(StringView path)
{
auto try_load_entire_file = [](StringView const& path) -> ErrorOr<ByteBuffer> {
- auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
auto file_size = TRY(file->size());
auto content = TRY(ByteBuffer::create_uninitialized(file_size));
TRY(file->read(content.bytes()));
diff --git a/Userland/Libraries/LibVirtGPU/Device.cpp b/Userland/Libraries/LibVirtGPU/Device.cpp
index f1ad713580..34c2bf9de8 100644
--- a/Userland/Libraries/LibVirtGPU/Device.cpp
+++ b/Userland/Libraries/LibVirtGPU/Device.cpp
@@ -8,6 +8,7 @@
#include <AK/NonnullOwnPtr.h>
#include <Kernel/API/VirGL.h>
+#include <LibCore/File.h>
#include <LibCore/System.h>
#include <LibVirtGPU/CommandBufferBuilder.h>
#include <LibVirtGPU/Device.h>
@@ -38,14 +39,14 @@ static constexpr auto vert_shader = "VERT\n"
" 4: MOV_SAT OUT[1], IN[1]\n"
" 5: END\n"sv;
-Device::Device(NonnullOwnPtr<Core::Stream::File> gpu_file)
+Device::Device(NonnullOwnPtr<Core::File> gpu_file)
: m_gpu_file { move(gpu_file) }
{
}
ErrorOr<NonnullOwnPtr<Device>> Device::create(Gfx::IntSize min_size)
{
- auto file = TRY(Core::Stream::File::open("/dev/gpu/render0"sv, Core::Stream::OpenMode::ReadWrite));
+ auto file = TRY(Core::File::open("/dev/gpu/render0"sv, Core::File::OpenMode::ReadWrite));
auto device = make<Device>(move(file));
TRY(device->initialize_context(min_size));
return device;
diff --git a/Userland/Libraries/LibVirtGPU/Device.h b/Userland/Libraries/LibVirtGPU/Device.h
index 8f5d130871..ee7c31db18 100644
--- a/Userland/Libraries/LibVirtGPU/Device.h
+++ b/Userland/Libraries/LibVirtGPU/Device.h
@@ -18,7 +18,7 @@ namespace VirtGPU {
class Device final : public GPU::Device {
public:
- Device(NonnullOwnPtr<Core::Stream::File>);
+ Device(NonnullOwnPtr<Core::File>);
static ErrorOr<NonnullOwnPtr<Device>> create(Gfx::IntSize min_size);
@@ -66,7 +66,7 @@ private:
ErrorOr<Protocol::ResourceID> create_virgl_resource(VirGL3DResourceSpec&);
ErrorOr<void> upload_command_buffer(Vector<u32> const&);
- NonnullOwnPtr<Core::Stream::File> m_gpu_file;
+ NonnullOwnPtr<Core::File> m_gpu_file;
Protocol::ResourceID m_vbo_resource_id { 0 };
Protocol::ResourceID m_drawtarget { 0 };
diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp
index ac104ff744..0e2b4876da 100644
--- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp
+++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp
@@ -250,7 +250,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has
auto const fd = file_or_error.value();
- auto maybe_file = Core::Stream::File::adopt_fd(fd, Core::Stream::OpenMode::Read);
+ auto maybe_file = Core::File::adopt_fd(fd, Core::File::OpenMode::Read);
if (maybe_file.is_error()) {
log_failure(request, maybe_file.error());
if (error_callback)
diff --git a/Userland/Services/FileOperation/main.cpp b/Userland/Services/FileOperation/main.cpp
index 37e11d0ffd..c34ec35a96 100644
--- a/Userland/Services/FileOperation/main.cpp
+++ b/Userland/Services/FileOperation/main.cpp
@@ -11,6 +11,7 @@
#include <AK/StringView.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/DirIterator.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -38,7 +39,7 @@ static ErrorOr<int> perform_copy(Vector<StringView> const& sources, DeprecatedSt
static ErrorOr<int> perform_move(Vector<StringView> const& sources, DeprecatedString const& destination);
static ErrorOr<int> perform_delete(Vector<StringView> const& sources);
static ErrorOr<int> execute_work_items(Vector<WorkItem> const& items);
-static ErrorOr<NonnullOwnPtr<Core::Stream::File>> open_destination_file(DeprecatedString const& destination);
+static ErrorOr<NonnullOwnPtr<Core::File>> open_destination_file(DeprecatedString const& destination);
static DeprecatedString deduplicate_destination_file_name(DeprecatedString const& destination);
ErrorOr<int> serenity_main(Main::Arguments arguments)
@@ -230,7 +231,7 @@ ErrorOr<int> execute_work_items(Vector<WorkItem> const& items)
};
auto copy_file = [&](DeprecatedString const& source, DeprecatedString const& destination) -> ErrorOr<int> {
- auto source_file = TRY(Core::Stream::File::open(source, Core::Stream::OpenMode::Read));
+ auto source_file = TRY(Core::File::open(source, Core::File::OpenMode::Read));
// FIXME: When the file already exists, let the user choose the next action instead of renaming it by default.
auto destination_file = TRY(open_destination_file(destination));
auto buffer = TRY(ByteBuffer::create_zeroed(64 * KiB));
@@ -327,9 +328,9 @@ ErrorOr<int> execute_work_items(Vector<WorkItem> const& items)
return 0;
}
-ErrorOr<NonnullOwnPtr<Core::Stream::File>> open_destination_file(DeprecatedString const& destination)
+ErrorOr<NonnullOwnPtr<Core::File>> open_destination_file(DeprecatedString const& destination)
{
- auto destination_file_or_error = Core::Stream::File::open(destination, (Core::Stream::OpenMode)(Core::Stream::OpenMode::Write | Core::Stream::OpenMode::Truncate | Core::Stream::OpenMode::MustBeNew));
+ auto destination_file_or_error = Core::File::open(destination, (Core::File::OpenMode)(Core::File::OpenMode::Write | Core::File::OpenMode::Truncate | Core::File::OpenMode::MustBeNew));
if (destination_file_or_error.is_error() && destination_file_or_error.error().code() == EEXIST) {
return open_destination_file(deduplicate_destination_file_name(destination));
}
diff --git a/Userland/Services/FileSystemAccessServer/ConnectionFromClient.cpp b/Userland/Services/FileSystemAccessServer/ConnectionFromClient.cpp
index 255a7caf9e..33b37ece8e 100644
--- a/Userland/Services/FileSystemAccessServer/ConnectionFromClient.cpp
+++ b/Userland/Services/FileSystemAccessServer/ConnectionFromClient.cpp
@@ -42,15 +42,15 @@ RefPtr<GUI::Window> ConnectionFromClient::create_dummy_child_window(i32 window_s
return window;
}
-void ConnectionFromClient::request_file_handler(i32 request_id, i32 window_server_client_id, i32 parent_window_id, DeprecatedString const& path, Core::Stream::OpenMode requested_access, ShouldPrompt prompt)
+void ConnectionFromClient::request_file_handler(i32 request_id, i32 window_server_client_id, i32 parent_window_id, DeprecatedString const& path, Core::File::OpenMode requested_access, ShouldPrompt prompt)
{
VERIFY(path.starts_with("/"sv));
bool approved = false;
auto maybe_permissions = m_approved_files.get(path);
- auto relevant_permissions = requested_access & (Core::Stream::OpenMode::Read | Core::Stream::OpenMode::Write);
- VERIFY(relevant_permissions != Core::Stream::OpenMode::NotOpen);
+ auto relevant_permissions = requested_access & (Core::File::OpenMode::Read | Core::File::OpenMode::Write);
+ VERIFY(relevant_permissions != Core::File::OpenMode::NotOpen);
if (maybe_permissions.has_value())
approved = has_flag(maybe_permissions.value(), relevant_permissions);
@@ -58,11 +58,11 @@ void ConnectionFromClient::request_file_handler(i32 request_id, i32 window_serve
if (!approved) {
DeprecatedString access_string;
- if (has_flag(requested_access, Core::Stream::OpenMode::ReadWrite))
+ if (has_flag(requested_access, Core::File::OpenMode::ReadWrite))
access_string = "read and write";
- else if (has_flag(requested_access, Core::Stream::OpenMode::Read))
+ else if (has_flag(requested_access, Core::File::OpenMode::Read))
access_string = "read from";
- else if (has_flag(requested_access, Core::Stream::OpenMode::Write))
+ else if (has_flag(requested_access, Core::File::OpenMode::Write))
access_string = "write to";
auto pid = this->socket().peer_pid().release_value_but_fixme_should_propagate_errors();
@@ -90,7 +90,7 @@ void ConnectionFromClient::request_file_handler(i32 request_id, i32 window_serve
}
if (approved) {
- auto file = Core::Stream::File::open(path, requested_access);
+ auto file = Core::File::open(path, requested_access);
if (file.is_error()) {
dbgln("FileSystemAccessServer: Couldn't open {}, error {}", path, file.error());
@@ -105,18 +105,18 @@ void ConnectionFromClient::request_file_handler(i32 request_id, i32 window_serve
void ConnectionFromClient::request_file_read_only_approved(i32 request_id, i32 window_server_client_id, i32 parent_window_id, DeprecatedString const& path)
{
- request_file_handler(request_id, window_server_client_id, parent_window_id, path, Core::Stream::OpenMode::Read, ShouldPrompt::No);
+ request_file_handler(request_id, window_server_client_id, parent_window_id, path, Core::File::OpenMode::Read, ShouldPrompt::No);
}
-void ConnectionFromClient::request_file(i32 request_id, i32 window_server_client_id, i32 parent_window_id, DeprecatedString const& path, Core::Stream::OpenMode requested_access)
+void ConnectionFromClient::request_file(i32 request_id, i32 window_server_client_id, i32 parent_window_id, DeprecatedString const& path, Core::File::OpenMode requested_access)
{
request_file_handler(request_id, window_server_client_id, parent_window_id, path, requested_access, ShouldPrompt::Yes);
}
-void ConnectionFromClient::prompt_open_file(i32 request_id, i32 window_server_client_id, i32 parent_window_id, DeprecatedString const& window_title, DeprecatedString const& path_to_view, Core::Stream::OpenMode requested_access)
+void ConnectionFromClient::prompt_open_file(i32 request_id, i32 window_server_client_id, i32 parent_window_id, DeprecatedString const& window_title, DeprecatedString const& path_to_view, Core::File::OpenMode requested_access)
{
- auto relevant_permissions = requested_access & (Core::Stream::OpenMode::Read | Core::Stream::OpenMode::Write);
- VERIFY(relevant_permissions != Core::Stream::OpenMode::NotOpen);
+ auto relevant_permissions = requested_access & (Core::File::OpenMode::Read | Core::File::OpenMode::Write);
+ VERIFY(relevant_permissions != Core::File::OpenMode::NotOpen);
auto main_window = create_dummy_child_window(window_server_client_id, parent_window_id);
@@ -125,10 +125,10 @@ void ConnectionFromClient::prompt_open_file(i32 request_id, i32 window_server_cl
prompt_helper(request_id, user_picked_file, requested_access);
}
-void ConnectionFromClient::prompt_save_file(i32 request_id, i32 window_server_client_id, i32 parent_window_id, DeprecatedString const& name, DeprecatedString const& ext, DeprecatedString const& path_to_view, Core::Stream::OpenMode requested_access)
+void ConnectionFromClient::prompt_save_file(i32 request_id, i32 window_server_client_id, i32 parent_window_id, DeprecatedString const& name, DeprecatedString const& ext, DeprecatedString const& path_to_view, Core::File::OpenMode requested_access)
{
- auto relevant_permissions = requested_access & (Core::Stream::OpenMode::Read | Core::Stream::OpenMode::Write);
- VERIFY(relevant_permissions != Core::Stream::OpenMode::NotOpen);
+ auto relevant_permissions = requested_access & (Core::File::OpenMode::Read | Core::File::OpenMode::Write);
+ VERIFY(relevant_permissions != Core::File::OpenMode::NotOpen);
auto main_window = create_dummy_child_window(window_server_client_id, parent_window_id);
@@ -137,18 +137,18 @@ void ConnectionFromClient::prompt_save_file(i32 request_id, i32 window_server_cl
prompt_helper(request_id, user_picked_file, requested_access);
}
-void ConnectionFromClient::prompt_helper(i32 request_id, Optional<DeprecatedString> const& user_picked_file, Core::Stream::OpenMode requested_access)
+void ConnectionFromClient::prompt_helper(i32 request_id, Optional<DeprecatedString> const& user_picked_file, Core::File::OpenMode requested_access)
{
if (user_picked_file.has_value()) {
VERIFY(user_picked_file->starts_with("/"sv));
- auto file = Core::Stream::File::open(user_picked_file.value(), requested_access);
+ auto file = Core::File::open(user_picked_file.value(), requested_access);
if (file.is_error()) {
dbgln("FileSystemAccessServer: Couldn't open {}, error {}", user_picked_file.value(), file.error());
async_handle_prompt_end(request_id, file.error().code(), Optional<IPC::File> {}, user_picked_file);
} else {
auto maybe_permissions = m_approved_files.get(user_picked_file.value());
- auto new_permissions = requested_access & (Core::Stream::OpenMode::Read | Core::Stream::OpenMode::Write);
+ auto new_permissions = requested_access & (Core::File::OpenMode::Read | Core::File::OpenMode::Write);
if (maybe_permissions.has_value())
new_permissions |= maybe_permissions.value();
diff --git a/Userland/Services/FileSystemAccessServer/ConnectionFromClient.h b/Userland/Services/FileSystemAccessServer/ConnectionFromClient.h
index 584291ae30..0ad767a359 100644
--- a/Userland/Services/FileSystemAccessServer/ConnectionFromClient.h
+++ b/Userland/Services/FileSystemAccessServer/ConnectionFromClient.h
@@ -28,22 +28,22 @@ private:
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>);
virtual void request_file_read_only_approved(i32, i32, i32, DeprecatedString const&) override;
- virtual void request_file(i32, i32, i32, DeprecatedString const&, Core::Stream::OpenMode) override;
- virtual void prompt_open_file(i32, i32, i32, DeprecatedString const&, DeprecatedString const&, Core::Stream::OpenMode) override;
- virtual void prompt_save_file(i32, i32, i32, DeprecatedString const&, DeprecatedString const&, DeprecatedString const&, Core::Stream::OpenMode) override;
+ virtual void request_file(i32, i32, i32, DeprecatedString const&, Core::File::OpenMode) override;
+ virtual void prompt_open_file(i32, i32, i32, DeprecatedString const&, DeprecatedString const&, Core::File::OpenMode) override;
+ virtual void prompt_save_file(i32, i32, i32, DeprecatedString const&, DeprecatedString const&, DeprecatedString const&, Core::File::OpenMode) override;
- void prompt_helper(i32, Optional<DeprecatedString> const&, Core::Stream::OpenMode);
+ void prompt_helper(i32, Optional<DeprecatedString> const&, Core::File::OpenMode);
RefPtr<GUI::Window> create_dummy_child_window(i32, i32);
enum class ShouldPrompt {
No,
Yes
};
- void request_file_handler(i32, i32, i32, DeprecatedString const&, Core::Stream::OpenMode, ShouldPrompt);
+ void request_file_handler(i32, i32, i32, DeprecatedString const&, Core::File::OpenMode, ShouldPrompt);
virtual Messages::FileSystemAccessServer::ExposeWindowServerClientIdResponse expose_window_server_client_id() override;
- HashMap<DeprecatedString, Core::Stream::OpenMode> m_approved_files;
+ HashMap<DeprecatedString, Core::File::OpenMode> m_approved_files;
};
}
diff --git a/Userland/Services/FileSystemAccessServer/FileSystemAccessServer.ipc b/Userland/Services/FileSystemAccessServer/FileSystemAccessServer.ipc
index a42379acd1..a1970b9972 100644
--- a/Userland/Services/FileSystemAccessServer/FileSystemAccessServer.ipc
+++ b/Userland/Services/FileSystemAccessServer/FileSystemAccessServer.ipc
@@ -4,9 +4,9 @@
endpoint FileSystemAccessServer
{
request_file_read_only_approved(i32 request_id, i32 window_server_client_id, i32 window_id, DeprecatedString path) =|
- request_file(i32 request_id, i32 window_server_client_id, i32 window_id, DeprecatedString path, Core::Stream::OpenMode requested_access) =|
- prompt_open_file(i32 request_id, i32 window_server_client_id, i32 window_id, DeprecatedString window_title, DeprecatedString path_to_view, Core::Stream::OpenMode requested_access) =|
- prompt_save_file(i32 request_id, i32 window_server_client_id, i32 window_id, DeprecatedString title, DeprecatedString ext, DeprecatedString path_to_view, Core::Stream::OpenMode requested_access) =|
+ request_file(i32 request_id, i32 window_server_client_id, i32 window_id, DeprecatedString path, Core::File::OpenMode requested_access) =|
+ prompt_open_file(i32 request_id, i32 window_server_client_id, i32 window_id, DeprecatedString window_title, DeprecatedString path_to_view, Core::File::OpenMode requested_access) =|
+ prompt_save_file(i32 request_id, i32 window_server_client_id, i32 window_id, DeprecatedString title, DeprecatedString ext, DeprecatedString path_to_view, Core::File::OpenMode requested_access) =|
expose_window_server_client_id() => (i32 client_id)
}
diff --git a/Userland/Services/NetworkServer/main.cpp b/Userland/Services/NetworkServer/main.cpp
index 6e4ba5d7a1..915ff8ea6b 100644
--- a/Userland/Services/NetworkServer/main.cpp
+++ b/Userland/Services/NetworkServer/main.cpp
@@ -27,7 +27,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
auto config_file = TRY(Core::ConfigFile::open_for_system("Network"));
- auto proc_net_adapters_file = TRY(Core::Stream::File::open("/sys/kernel/net/adapters"sv, Core::Stream::OpenMode::Read));
+ auto proc_net_adapters_file = TRY(Core::File::open("/sys/kernel/net/adapters"sv, Core::File::OpenMode::Read));
auto data = TRY(proc_net_adapters_file->read_until_eof());
JsonParser parser(data);
JsonValue proc_net_adapters_json = TRY(parser.parse());
diff --git a/Userland/Services/RequestServer/GeminiProtocol.cpp b/Userland/Services/RequestServer/GeminiProtocol.cpp
index 9412476a9b..642f24d613 100644
--- a/Userland/Services/RequestServer/GeminiProtocol.cpp
+++ b/Userland/Services/RequestServer/GeminiProtocol.cpp
@@ -26,7 +26,7 @@ OwnPtr<Request> GeminiProtocol::start_request(ConnectionFromClient& client, Depr
if (pipe_result.is_error())
return {};
- auto output_stream = MUST(Core::Stream::File::adopt_fd(pipe_result.value().write_fd, Core::Stream::OpenMode::Write));
+ auto output_stream = MUST(Core::File::adopt_fd(pipe_result.value().write_fd, Core::File::OpenMode::Write));
auto job = Gemini::Job::construct(request, *output_stream);
auto protocol_request = GeminiRequest::create_with_job({}, client, *job, move(output_stream));
protocol_request->set_request_fd(pipe_result.value().read_fd);
diff --git a/Userland/Services/RequestServer/GeminiRequest.cpp b/Userland/Services/RequestServer/GeminiRequest.cpp
index 048338f30e..962480f13b 100644
--- a/Userland/Services/RequestServer/GeminiRequest.cpp
+++ b/Userland/Services/RequestServer/GeminiRequest.cpp
@@ -12,7 +12,7 @@
namespace RequestServer {
-GeminiRequest::GeminiRequest(ConnectionFromClient& client, NonnullRefPtr<Gemini::Job> job, NonnullOwnPtr<Core::Stream::File>&& output_stream)
+GeminiRequest::GeminiRequest(ConnectionFromClient& client, NonnullRefPtr<Gemini::Job> job, NonnullOwnPtr<Core::File>&& output_stream)
: Request(client, move(output_stream))
, m_job(move(job))
{
@@ -57,7 +57,7 @@ GeminiRequest::~GeminiRequest()
m_job->cancel();
}
-NonnullOwnPtr<GeminiRequest> GeminiRequest::create_with_job(Badge<GeminiProtocol>, ConnectionFromClient& client, NonnullRefPtr<Gemini::Job> job, NonnullOwnPtr<Core::Stream::File>&& output_stream)
+NonnullOwnPtr<GeminiRequest> GeminiRequest::create_with_job(Badge<GeminiProtocol>, ConnectionFromClient& client, NonnullRefPtr<Gemini::Job> job, NonnullOwnPtr<Core::File>&& output_stream)
{
return adopt_own(*new GeminiRequest(client, move(job), move(output_stream)));
}
diff --git a/Userland/Services/RequestServer/GeminiRequest.h b/Userland/Services/RequestServer/GeminiRequest.h
index 9039b83980..5943f62c8b 100644
--- a/Userland/Services/RequestServer/GeminiRequest.h
+++ b/Userland/Services/RequestServer/GeminiRequest.h
@@ -16,14 +16,14 @@ namespace RequestServer {
class GeminiRequest final : public Request {
public:
virtual ~GeminiRequest() override;
- static NonnullOwnPtr<GeminiRequest> create_with_job(Badge<GeminiProtocol>, ConnectionFromClient&, NonnullRefPtr<Gemini::Job>, NonnullOwnPtr<Core::Stream::File>&&);
+ static NonnullOwnPtr<GeminiRequest> create_with_job(Badge<GeminiProtocol>, ConnectionFromClient&, NonnullRefPtr<Gemini::Job>, NonnullOwnPtr<Core::File>&&);
Gemini::Job const& job() const { return *m_job; }
virtual URL url() const override { return m_job->url(); }
private:
- explicit GeminiRequest(ConnectionFromClient&, NonnullRefPtr<Gemini::Job>, NonnullOwnPtr<Core::Stream::File>&&);
+ explicit GeminiRequest(ConnectionFromClient&, NonnullRefPtr<Gemini::Job>, NonnullOwnPtr<Core::File>&&);
virtual void set_certificate(DeprecatedString certificate, DeprecatedString key) override;
diff --git a/Userland/Services/RequestServer/HttpCommon.h b/Userland/Services/RequestServer/HttpCommon.h
index d54d48ca23..3cc50c7d33 100644
--- a/Userland/Services/RequestServer/HttpCommon.h
+++ b/Userland/Services/RequestServer/HttpCommon.h
@@ -97,7 +97,7 @@ OwnPtr<Request> start_request(TBadgedProtocol&& protocol, ConnectionFromClient&
return {};
request.set_body(allocated_body_result.release_value());
- auto output_stream = MUST(Core::Stream::File::adopt_fd(pipe_result.value().write_fd, Core::Stream::OpenMode::Write));
+ auto output_stream = MUST(Core::File::adopt_fd(pipe_result.value().write_fd, Core::File::OpenMode::Write));
auto job = TJob::construct(move(request), *output_stream);
auto protocol_request = TRequest::create_with_job(forward<TBadgedProtocol>(protocol), client, (TJob&)*job, move(output_stream));
protocol_request->set_request_fd(pipe_result.value().read_fd);
diff --git a/Userland/Services/RequestServer/HttpRequest.cpp b/Userland/Services/RequestServer/HttpRequest.cpp
index 861c7a93b3..0249650c3d 100644
--- a/Userland/Services/RequestServer/HttpRequest.cpp
+++ b/Userland/Services/RequestServer/HttpRequest.cpp
@@ -11,7 +11,7 @@
namespace RequestServer {
-HttpRequest::HttpRequest(ConnectionFromClient& client, NonnullRefPtr<HTTP::Job> job, NonnullOwnPtr<Core::Stream::File>&& output_stream)
+HttpRequest::HttpRequest(ConnectionFromClient& client, NonnullRefPtr<HTTP::Job> job, NonnullOwnPtr<Core::File>&& output_stream)
: Request(client, move(output_stream))
, m_job(job)
{
@@ -25,7 +25,7 @@ HttpRequest::~HttpRequest()
m_job->cancel();
}
-NonnullOwnPtr<HttpRequest> HttpRequest::create_with_job(Badge<HttpProtocol>&&, ConnectionFromClient& client, NonnullRefPtr<HTTP::Job> job, NonnullOwnPtr<Core::Stream::File>&& output_stream)
+NonnullOwnPtr<HttpRequest> HttpRequest::create_with_job(Badge<HttpProtocol>&&, ConnectionFromClient& client, NonnullRefPtr<HTTP::Job> job, NonnullOwnPtr<Core::File>&& output_stream)
{
return adopt_own(*new HttpRequest(client, move(job), move(output_stream)));
}
diff --git a/Userland/Services/RequestServer/HttpRequest.h b/Userland/Services/RequestServer/HttpRequest.h
index 624cccf4dc..6833e74d6c 100644
--- a/Userland/Services/RequestServer/HttpRequest.h
+++ b/Userland/Services/RequestServer/HttpRequest.h
@@ -17,7 +17,7 @@ namespace RequestServer {
class HttpRequest final : public Request {
public:
virtual ~HttpRequest() override;
- static NonnullOwnPtr<HttpRequest> create_with_job(Badge<HttpProtocol>&&, ConnectionFromClient&, NonnullRefPtr<HTTP::Job>, NonnullOwnPtr<Core::Stream::File>&&);
+ static NonnullOwnPtr<HttpRequest> create_with_job(Badge<HttpProtocol>&&, ConnectionFromClient&, NonnullRefPtr<HTTP::Job>, NonnullOwnPtr<Core::File>&&);
HTTP::Job& job() { return m_job; }
HTTP::Job const& job() const { return m_job; }
@@ -25,7 +25,7 @@ public:
virtual URL url() const override { return m_job->url(); }
private:
- explicit HttpRequest(ConnectionFromClient&, NonnullRefPtr<HTTP::Job>, NonnullOwnPtr<Core::Stream::File>&&);
+ explicit HttpRequest(ConnectionFromClient&, NonnullRefPtr<HTTP::Job>, NonnullOwnPtr<Core::File>&&);
NonnullRefPtr<HTTP::Job> m_job;
};
diff --git a/Userland/Services/RequestServer/HttpsRequest.cpp b/Userland/Services/RequestServer/HttpsRequest.cpp
index dcf2c4da71..f9c9ba0272 100644
--- a/Userland/Services/RequestServer/HttpsRequest.cpp
+++ b/Userland/Services/RequestServer/HttpsRequest.cpp
@@ -11,7 +11,7 @@
namespace RequestServer {
-HttpsRequest::HttpsRequest(ConnectionFromClient& client, NonnullRefPtr<HTTP::HttpsJob> job, NonnullOwnPtr<Core::Stream::File>&& output_stream)
+HttpsRequest::HttpsRequest(ConnectionFromClient& client, NonnullRefPtr<HTTP::HttpsJob> job, NonnullOwnPtr<Core::File>&& output_stream)
: Request(client, move(output_stream))
, m_job(job)
{
@@ -30,7 +30,7 @@ HttpsRequest::~HttpsRequest()
m_job->cancel();
}
-NonnullOwnPtr<HttpsRequest> HttpsRequest::create_with_job(Badge<HttpsProtocol>&&, ConnectionFromClient& client, NonnullRefPtr<HTTP::HttpsJob> job, NonnullOwnPtr<Core::Stream::File>&& output_stream)
+NonnullOwnPtr<HttpsRequest> HttpsRequest::create_with_job(Badge<HttpsProtocol>&&, ConnectionFromClient& client, NonnullRefPtr<HTTP::HttpsJob> job, NonnullOwnPtr<Core::File>&& output_stream)
{
return adopt_own(*new HttpsRequest(client, move(job), move(output_stream)));
}
diff --git a/Userland/Services/RequestServer/HttpsRequest.h b/Userland/Services/RequestServer/HttpsRequest.h
index 1add0e1cee..01eb3870cd 100644
--- a/Userland/Services/RequestServer/HttpsRequest.h
+++ b/Userland/Services/RequestServer/HttpsRequest.h
@@ -16,7 +16,7 @@ namespace RequestServer {
class HttpsRequest final : public Request {
public:
virtual ~HttpsRequest() override;
- static NonnullOwnPtr<HttpsRequest> create_with_job(Badge<HttpsProtocol>&&, ConnectionFromClient&, NonnullRefPtr<HTTP::HttpsJob>, NonnullOwnPtr<Core::Stream::File>&&);
+ static NonnullOwnPtr<HttpsRequest> create_with_job(Badge<HttpsProtocol>&&, ConnectionFromClient&, NonnullRefPtr<HTTP::HttpsJob>, NonnullOwnPtr<Core::File>&&);
HTTP::HttpsJob& job() { return m_job; }
HTTP::HttpsJob const& job() const { return m_job; }
@@ -24,7 +24,7 @@ public:
virtual URL url() const override { return m_job->url(); }
private:
- explicit HttpsRequest(ConnectionFromClient&, NonnullRefPtr<HTTP::HttpsJob>, NonnullOwnPtr<Core::Stream::File>&&);
+ explicit HttpsRequest(ConnectionFromClient&, NonnullRefPtr<HTTP::HttpsJob>, NonnullOwnPtr<Core::File>&&);
virtual void set_certificate(DeprecatedString certificate, DeprecatedString key) override;
diff --git a/Userland/Services/RequestServer/Request.cpp b/Userland/Services/RequestServer/Request.cpp
index b1d00d8e03..d766bd8508 100644
--- a/Userland/Services/RequestServer/Request.cpp
+++ b/Userland/Services/RequestServer/Request.cpp
@@ -12,7 +12,7 @@ namespace RequestServer {
// FIXME: What about rollover?
static i32 s_next_id = 1;
-Request::Request(ConnectionFromClient& client, NonnullOwnPtr<Core::Stream::File>&& output_stream)
+Request::Request(ConnectionFromClient& client, NonnullOwnPtr<Core::File>&& output_stream)
: m_client(client)
, m_id(s_next_id++)
, m_output_stream(move(output_stream))
diff --git a/Userland/Services/RequestServer/Request.h b/Userland/Services/RequestServer/Request.h
index 6b4a9a107a..7633032e07 100644
--- a/Userland/Services/RequestServer/Request.h
+++ b/Userland/Services/RequestServer/Request.h
@@ -40,10 +40,10 @@ public:
void did_request_certificates();
void set_response_headers(HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const&);
void set_downloaded_size(size_t size) { m_downloaded_size = size; }
- Core::Stream::File const& output_stream() const { return *m_output_stream; }
+ Core::File const& output_stream() const { return *m_output_stream; }
protected:
- explicit Request(ConnectionFromClient&, NonnullOwnPtr<Core::Stream::File>&&);
+ explicit Request(ConnectionFromClient&, NonnullOwnPtr<Core::File>&&);
private:
ConnectionFromClient& m_client;
@@ -52,7 +52,7 @@ private:
Optional<u32> m_status_code;
Optional<u32> m_total_size {};
size_t m_downloaded_size { 0 };
- NonnullOwnPtr<Core::Stream::File> m_output_stream;
+ NonnullOwnPtr<Core::File> m_output_stream;
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> m_response_headers;
};
diff --git a/Userland/Services/WebServer/Client.cpp b/Userland/Services/WebServer/Client.cpp
index ce90bdff07..ae65737e3f 100644
--- a/Userland/Services/WebServer/Client.cpp
+++ b/Userland/Services/WebServer/Client.cpp
@@ -16,6 +16,7 @@
#include <LibCore/DateTime.h>
#include <LibCore/DeprecatedFile.h>
#include <LibCore/DirIterator.h>
+#include <LibCore/File.h>
#include <LibCore/MappedFile.h>
#include <LibCore/MimeData.h>
#include <LibHTTP/HttpRequest.h>
@@ -165,7 +166,7 @@ ErrorOr<bool> Client::handle_request(ReadonlyBytes raw_request)
return false;
}
- auto stream = TRY(Core::Stream::File::open(real_path.bytes_as_string_view(), Core::Stream::OpenMode::Read));
+ auto stream = TRY(Core::File::open(real_path.bytes_as_string_view(), Core::File::OpenMode::Read));
auto const info = ContentInfo {
.type = TRY(String::from_deprecated_string(Core::guess_mime_type_based_on_filename(real_path.bytes_as_string_view()))),
diff --git a/Userland/Utilities/arp.cpp b/Userland/Utilities/arp.cpp
index 066474b46b..89324c8f7a 100644
--- a/Userland/Utilities/arp.cpp
+++ b/Userland/Utilities/arp.cpp
@@ -12,6 +12,7 @@
#include <AK/QuickSort.h>
#include <AK/Types.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -92,7 +93,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
outln();
if (!flag_set && !flag_delete) {
- auto file = TRY(Core::Stream::File::open("/sys/kernel/net/arp"sv, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open("/sys/kernel/net/arp"sv, Core::File::OpenMode::Read));
auto file_contents = TRY(file->read_until_eof());
auto json = TRY(JsonValue::from_string(file_contents));
diff --git a/Userland/Utilities/base64.cpp b/Userland/Utilities/base64.cpp
index a622ea8ca6..9aa05d3197 100644
--- a/Userland/Utilities/base64.cpp
+++ b/Userland/Utilities/base64.cpp
@@ -6,6 +6,7 @@
#include <AK/Base64.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -22,7 +23,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_positional_argument(filepath, "", "file", Core::ArgsParser::Required::No);
args_parser.parse(arguments);
- auto file = TRY(Core::Stream::File::open_file_or_standard_stream(filepath, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open_file_or_standard_stream(filepath, Core::File::OpenMode::Read));
ByteBuffer buffer = TRY(file->read_until_eof());
TRY(Core::System::pledge("stdio"));
diff --git a/Userland/Utilities/cat.cpp b/Userland/Utilities/cat.cpp
index 000b26d739..ea5e558f0e 100644
--- a/Userland/Utilities/cat.cpp
+++ b/Userland/Utilities/cat.cpp
@@ -7,6 +7,7 @@
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -25,11 +26,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (paths.is_empty())
paths.append("-"sv);
- Vector<NonnullOwnPtr<Core::Stream::File>> files;
+ Vector<NonnullOwnPtr<Core::File>> files;
TRY(files.try_ensure_capacity(paths.size()));
for (auto const& path : paths) {
- if (auto result = Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read); result.is_error())
+ if (auto result = Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read); result.is_error())
warnln("Failed to open {}: {}", path, result.release_error());
else
files.unchecked_append(result.release_value());
diff --git a/Userland/Utilities/checksum.cpp b/Userland/Utilities/checksum.cpp
index 5ac56e8cb4..abb566ab04 100644
--- a/Userland/Utilities/checksum.cpp
+++ b/Userland/Utilities/checksum.cpp
@@ -6,6 +6,7 @@
#include <AK/LexicalPath.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibCrypto/Hash/HashManager.h>
@@ -55,7 +56,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
int failed_verification_count = 0;
for (auto const& path : paths) {
- auto file_or_error = Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read);
+ auto file_or_error = Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read);
if (file_or_error.is_error()) {
++read_fail_count;
has_error = true;
@@ -87,7 +88,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
// line[0] = checksum
// line[1] = filename
StringView const filename = line[1];
- auto file_from_filename_or_error = Core::Stream::File::open_file_or_standard_stream(filename, Core::Stream::OpenMode::Read);
+ auto file_from_filename_or_error = Core::File::open_file_or_standard_stream(filename, Core::File::OpenMode::Read);
if (file_from_filename_or_error.is_error()) {
++read_fail_count;
warnln("{}: {}", filename, file_from_filename_or_error.release_error());
diff --git a/Userland/Utilities/cksum.cpp b/Userland/Utilities/cksum.cpp
index 08c7cb0be3..ba1b102801 100644
--- a/Userland/Utilities/cksum.cpp
+++ b/Userland/Utilities/cksum.cpp
@@ -5,6 +5,7 @@
*/
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibCrypto/Checksum/Adler32.h>
@@ -46,7 +47,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Array<u8, PAGE_SIZE> buffer;
for (auto& path : paths) {
- auto file_or_error = Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read);
+ auto file_or_error = Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read);
auto filepath = (path == "-") ? "/dev/stdin" : path;
if (file_or_error.is_error()) {
warnln("{}: {}: {}", arguments.strings[0], filepath, file_or_error.error());
diff --git a/Userland/Utilities/cmp.cpp b/Userland/Utilities/cmp.cpp
index 8837098992..ac213cb88b 100644
--- a/Userland/Utilities/cmp.cpp
+++ b/Userland/Utilities/cmp.cpp
@@ -5,20 +5,21 @@
*/
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
#include <unistd.h>
-static ErrorOr<NonnullOwnPtr<Core::Stream::BufferedFile>> open_file_or_stdin(DeprecatedString const& filename)
+static ErrorOr<NonnullOwnPtr<Core::BufferedFile>> open_file_or_stdin(DeprecatedString const& filename)
{
- OwnPtr<Core::Stream::File> file;
+ OwnPtr<Core::File> file;
if (filename == "-") {
- file = TRY(Core::Stream::File::adopt_fd(STDIN_FILENO, Core::Stream::OpenMode::Read));
+ file = TRY(Core::File::adopt_fd(STDIN_FILENO, Core::File::OpenMode::Read));
} else {
- file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Read));
+ file = TRY(Core::File::open(filename, Core::File::OpenMode::Read));
}
- return TRY(Core::Stream::BufferedFile::create(file.release_nonnull()));
+ return TRY(Core::BufferedFile::create(file.release_nonnull()));
}
ErrorOr<int> serenity_main(Main::Arguments arguments)
diff --git a/Userland/Utilities/comm.cpp b/Userland/Utilities/comm.cpp
index 370bdc4ea1..0040c94ce4 100644
--- a/Userland/Utilities/comm.cpp
+++ b/Userland/Utilities/comm.cpp
@@ -7,6 +7,7 @@
#include <LibCore/ArgsParser.h>
#include <LibCore/DeprecatedFile.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -62,7 +63,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
auto open_file = [](DeprecatedString const& path, auto& file, int file_number) {
- auto file_or_error = Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read);
+ auto file_or_error = Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read);
if (file_or_error.is_error()) {
warnln("Failed to open file{} '{}': {}", file_number, path, file_or_error.error());
return false;
@@ -73,7 +74,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return false;
}
- auto buffered_file_or_error = Core::Stream::BufferedFile::create(file_or_error.release_value());
+ auto buffered_file_or_error = Core::BufferedFile::create(file_or_error.release_value());
if (buffered_file_or_error.is_error()) {
warnln("Failed to create buffer for file{} '{}': {}", file_number, path, buffered_file_or_error.error());
return false;
@@ -83,8 +84,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return true;
};
- OwnPtr<Core::Stream::BufferedFile> file1;
- OwnPtr<Core::Stream::BufferedFile> file2;
+ OwnPtr<Core::BufferedFile> file1;
+ OwnPtr<Core::BufferedFile> file2;
if (!(open_file(file1_path, file1, 1) && open_file(file2_path, file2, 2)))
return 1;
diff --git a/Userland/Utilities/copy.cpp b/Userland/Utilities/copy.cpp
index b3103c7146..c9122d46f3 100644
--- a/Userland/Utilities/copy.cpp
+++ b/Userland/Utilities/copy.cpp
@@ -9,6 +9,7 @@
#include <AK/DeprecatedString.h>
#include <AK/StringBuilder.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibGUI/Application.h>
#include <LibGUI/Clipboard.h>
@@ -42,7 +43,7 @@ static ErrorOr<Options> parse_options(Main::Arguments arguments)
// We're not copying anything.
} else if (text.is_empty()) {
// Copy our stdin.
- auto c_stdin = TRY(Core::Stream::File::standard_input());
+ auto c_stdin = TRY(Core::File::standard_input());
auto buffer = TRY(c_stdin->read_until_eof());
dbgln("Read size {}", buffer.size());
dbgln("Read data: `{}`", StringView(buffer.bytes()));
diff --git a/Userland/Utilities/cpp-lexer.cpp b/Userland/Utilities/cpp-lexer.cpp
index fdbe49c5e8..aa0fdafe20 100644
--- a/Userland/Utilities/cpp-lexer.cpp
+++ b/Userland/Utilities/cpp-lexer.cpp
@@ -6,6 +6,7 @@
#include <AK/Try.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCpp/Lexer.h>
#include <LibMain/Main.h>
@@ -17,7 +18,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_positional_argument(path, "Cpp File", "cpp-file", Core::ArgsParser::Required::Yes);
args_parser.parse(arguments);
- auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
auto content = TRY(file->read_until_eof());
StringView content_view(content);
diff --git a/Userland/Utilities/cpp-parser.cpp b/Userland/Utilities/cpp-parser.cpp
index 91e6f5a4de..683b9ed241 100644
--- a/Userland/Utilities/cpp-parser.cpp
+++ b/Userland/Utilities/cpp-parser.cpp
@@ -5,6 +5,7 @@
*/
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCpp/Parser.h>
#include <LibMain/Main.h>
@@ -20,7 +21,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (path.is_empty())
path = "Source/little/main.cpp"sv;
- auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
auto content = TRY(file->read_until_eof());
StringView content_view(content);
diff --git a/Userland/Utilities/cpp-preprocessor.cpp b/Userland/Utilities/cpp-preprocessor.cpp
index 34e6148471..4414e53752 100644
--- a/Userland/Utilities/cpp-preprocessor.cpp
+++ b/Userland/Utilities/cpp-preprocessor.cpp
@@ -6,6 +6,7 @@
#include <AK/LexicalPath.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCpp/Preprocessor.h>
#include <LibMain/Main.h>
@@ -19,7 +20,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_option(print_definitions, "Print preprocessor definitions", "definitions", 'D');
args_parser.parse(arguments);
- auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
auto content = TRY(file->read_until_eof());
DeprecatedString name = LexicalPath::basename(path);
Cpp::Preprocessor cpp(name, StringView { content });
diff --git a/Userland/Utilities/df.cpp b/Userland/Utilities/df.cpp
index a80945aa81..56bef8ed89 100644
--- a/Userland/Utilities/df.cpp
+++ b/Userland/Utilities/df.cpp
@@ -8,6 +8,7 @@
#include <AK/JsonObject.h>
#include <AK/NumberFormat.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibMain/Main.h>
#include <inttypes.h>
@@ -36,7 +37,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_option(flag_inode_info, "Show inode information as well", "inodes", 'i');
args_parser.parse(arguments);
- auto file = TRY(Core::Stream::File::open("/sys/kernel/df"sv, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open("/sys/kernel/df"sv, Core::File::OpenMode::Read));
Vector<StringView> headers;
TRY(headers.try_append(flag_human_readable ? "Size"sv : "Blocks"sv));
diff --git a/Userland/Utilities/diff.cpp b/Userland/Utilities/diff.cpp
index 9ec39cabe1..c26318ac40 100644
--- a/Userland/Utilities/diff.cpp
+++ b/Userland/Utilities/diff.cpp
@@ -5,6 +5,7 @@
*/
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibDiff/Generator.h>
@@ -23,8 +24,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
parser.add_positional_argument(filename2, "Second file to compare", "file2", Core::ArgsParser::Required::Yes);
parser.parse(arguments);
- auto file1 = TRY(Core::Stream::File::open(filename1, Core::Stream::OpenMode::Read));
- auto file2 = TRY(Core::Stream::File::open(filename2, Core::Stream::OpenMode::Read));
+ auto file1 = TRY(Core::File::open(filename1, Core::File::OpenMode::Read));
+ auto file2 = TRY(Core::File::open(filename2, Core::File::OpenMode::Read));
bool color_output = TRY(Core::System::isatty(STDOUT_FILENO));
diff --git a/Userland/Utilities/dmesg.cpp b/Userland/Utilities/dmesg.cpp
index cb5e94baf4..459b06e425 100644
--- a/Userland/Utilities/dmesg.cpp
+++ b/Userland/Utilities/dmesg.cpp
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -14,7 +15,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
TRY(Core::System::unveil("/sys/kernel/dmesg", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
- auto file = TRY(Core::Stream::File::open("/sys/kernel/dmesg"sv, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open("/sys/kernel/dmesg"sv, Core::File::OpenMode::Read));
auto buffer = TRY(file->read_until_eof());
out("{}", StringView { buffer });
return 0;
diff --git a/Userland/Utilities/du.cpp b/Userland/Utilities/du.cpp
index 5de11b6db4..041ef2b4d5 100644
--- a/Userland/Utilities/du.cpp
+++ b/Userland/Utilities/du.cpp
@@ -11,6 +11,7 @@
#include <LibCore/ArgsParser.h>
#include <LibCore/DateTime.h>
#include <LibCore/DirIterator.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -116,7 +117,7 @@ ErrorOr<void> parse_args(Main::Arguments arguments, Vector<DeprecatedString>& fi
if (!pattern.is_empty())
du_option.excluded_patterns.append(pattern);
if (!exclude_from.is_empty()) {
- auto file = TRY(Core::Stream::File::open(exclude_from, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(exclude_from, Core::File::OpenMode::Read));
auto const buff = TRY(file->read_until_eof());
if (!buff.is_empty()) {
DeprecatedString patterns = DeprecatedString::copy(buff, Chomp);
diff --git a/Userland/Utilities/file.cpp b/Userland/Utilities/file.cpp
index da25e832ab..ecf71bb532 100644
--- a/Userland/Utilities/file.cpp
+++ b/Userland/Utilities/file.cpp
@@ -7,6 +7,7 @@
#include <AK/Vector.h>
#include <LibCompress/Gzip.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/MappedFile.h>
#include <LibCore/MimeData.h>
#include <LibCore/Stream.h>
@@ -158,7 +159,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto buffer = TRY(ByteBuffer::create_uninitialized(0x9006));
for (auto const& path : paths) {
- auto file_or_error = Core::Stream::File::open(path, Core::Stream::OpenMode::Read);
+ auto file_or_error = Core::File::open(path, Core::File::OpenMode::Read);
if (file_or_error.is_error()) {
perror(path.characters());
all_ok = false;
diff --git a/Userland/Utilities/fortune.cpp b/Userland/Utilities/fortune.cpp
index c641d3e4a0..f6da0e9631 100644
--- a/Userland/Utilities/fortune.cpp
+++ b/Userland/Utilities/fortune.cpp
@@ -12,6 +12,7 @@
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/DateTime.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -81,7 +82,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_positional_argument(path, "Path to JSON file with quotes (/res/fortunes.json by default)", "path", Core::ArgsParser::Required::No);
args_parser.parse(arguments);
- auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
TRY(Core::System::unveil("/etc/timezone", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
diff --git a/Userland/Utilities/gml-format.cpp b/Userland/Utilities/gml-format.cpp
index a332fb3051..ac4a7cbcbb 100644
--- a/Userland/Utilities/gml-format.cpp
+++ b/Userland/Utilities/gml-format.cpp
@@ -5,6 +5,7 @@
*/
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibGUI/GML/Formatter.h>
@@ -13,8 +14,8 @@
static ErrorOr<bool> format_file(StringView path, bool inplace)
{
auto read_from_stdin = path == "-";
- auto open_mode = (inplace && !read_from_stdin) ? Core::Stream::OpenMode::ReadWrite : Core::Stream::OpenMode::Read;
- auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, open_mode));
+ auto open_mode = (inplace && !read_from_stdin) ? Core::File::OpenMode::ReadWrite : Core::File::OpenMode::Read;
+ auto file = TRY(Core::File::open_file_or_standard_stream(path, open_mode));
auto contents = TRY(file->read_until_eof());
auto formatted_gml_or_error = GUI::GML::format_gml(contents);
diff --git a/Userland/Utilities/grep.cpp b/Userland/Utilities/grep.cpp
index 9004e841f6..31d8e00794 100644
--- a/Userland/Utilities/grep.cpp
+++ b/Userland/Utilities/grep.cpp
@@ -13,6 +13,7 @@
#include <LibCore/ArgsParser.h>
#include <LibCore/DeprecatedFile.h>
#include <LibCore/DirIterator.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -215,8 +216,8 @@ ErrorOr<int> serenity_main(Main::Arguments args)
auto handle_file = [&matches, binary_mode, count_lines, quiet_mode,
user_specified_multiple_files, &matched_line_count, &did_match_something](StringView filename, bool print_filename) -> ErrorOr<void> {
- auto file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Read));
- auto buffered_file = TRY(Core::Stream::BufferedFile::create(move(file)));
+ auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Read));
+ auto buffered_file = TRY(Core::BufferedFile::create(move(file)));
for (size_t line_number = 1; TRY(buffered_file->can_read_line()); ++line_number) {
Array<u8, PAGE_SIZE> buffer;
diff --git a/Userland/Utilities/gron.cpp b/Userland/Utilities/gron.cpp
index 925cc70fea..34721bec35 100644
--- a/Userland/Utilities/gron.cpp
+++ b/Userland/Utilities/gron.cpp
@@ -9,6 +9,7 @@
#include <AK/JsonValue.h>
#include <AK/StringBuilder.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -54,7 +55,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_positional_argument(path, "Input", "input", Core::ArgsParser::Required::No);
args_parser.parse(arguments);
- auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read));
TRY(Core::System::pledge("stdio"));
diff --git a/Userland/Utilities/gunzip.cpp b/Userland/Utilities/gunzip.cpp
index 1c5b395b0f..531c753e3f 100644
--- a/Userland/Utilities/gunzip.cpp
+++ b/Userland/Utilities/gunzip.cpp
@@ -6,11 +6,12 @@
#include <LibCompress/Gzip.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
#include <unistd.h>
-static ErrorOr<void> decompress_file(NonnullOwnPtr<Core::Stream::File> input_stream, AK::Stream& output_stream)
+static ErrorOr<void> decompress_file(NonnullOwnPtr<Core::File> input_stream, AK::Stream& output_stream)
{
auto gzip_stream = Compress::GzipDecompressor { move(input_stream) };
@@ -50,8 +51,8 @@ ErrorOr<int> serenity_main(Main::Arguments args)
output_filename = filename;
}
- auto input_stream_result = TRY(Core::Stream::File::open(input_filename, Core::Stream::OpenMode::Read));
- auto output_stream = write_to_stdout ? TRY(Core::Stream::File::standard_output()) : TRY(Core::Stream::File::open(output_filename, Core::Stream::OpenMode::Write));
+ auto input_stream_result = TRY(Core::File::open(input_filename, Core::File::OpenMode::Read));
+ auto output_stream = write_to_stdout ? TRY(Core::File::standard_output()) : TRY(Core::File::open(output_filename, Core::File::OpenMode::Write));
TRY(decompress_file(move(input_stream_result), *output_stream));
diff --git a/Userland/Utilities/gzip.cpp b/Userland/Utilities/gzip.cpp
index 6f5aa5e230..28fbdc38c2 100644
--- a/Userland/Utilities/gzip.cpp
+++ b/Userland/Utilities/gzip.cpp
@@ -6,6 +6,7 @@
#include <LibCompress/Gzip.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/MappedFile.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -55,7 +56,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
else
output_bytes = TRY(Compress::GzipCompressor::compress_all(input_bytes));
- auto output_stream = write_to_stdout ? TRY(Core::Stream::File::standard_output()) : TRY(Core::Stream::File::open(output_filename, Core::Stream::OpenMode::Write));
+ auto output_stream = write_to_stdout ? TRY(Core::File::standard_output()) : TRY(Core::File::open(output_filename, Core::File::OpenMode::Write));
TRY(output_stream->write_entire_buffer(output_bytes));
if (!keep_input_files) {
diff --git a/Userland/Utilities/headless-browser.cpp b/Userland/Utilities/headless-browser.cpp
index c24754b3d8..43e2394e5e 100644
--- a/Userland/Utilities/headless-browser.cpp
+++ b/Userland/Utilities/headless-browser.cpp
@@ -694,7 +694,7 @@ static void load_page_for_screenshot_and_exit(HeadlessBrowserPageClient& page_cl
if (Core::DeprecatedFile::exists(output_file_path))
MUST(Core::DeprecatedFile::remove(output_file_path, Core::DeprecatedFile::RecursionMode::Disallowed));
- auto output_file = MUST(Core::Stream::File::open(output_file_path, Core::Stream::OpenMode::Write));
+ auto output_file = MUST(Core::File::open(output_file_path, Core::File::OpenMode::Write));
auto output_rect = page_client.screen_rect();
auto output_bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, output_rect.size().to_type<int>()));
diff --git a/Userland/Utilities/hexdump.cpp b/Userland/Utilities/hexdump.cpp
index 00fe33f4e1..008c46e2dc 100644
--- a/Userland/Utilities/hexdump.cpp
+++ b/Userland/Utilities/hexdump.cpp
@@ -7,6 +7,7 @@
#include <AK/Array.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -37,7 +38,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
args_parser.add_option(seek_to, "Seek to a byte offset", "seek", 's', "offset");
args_parser.parse(args);
- auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read));
if (seek_to.has_value())
TRY(file->seek(seek_to.value(), SeekMode::SetPosition));
diff --git a/Userland/Utilities/ifconfig.cpp b/Userland/Utilities/ifconfig.cpp
index 5b8dc637a3..ad25907944 100644
--- a/Userland/Utilities/ifconfig.cpp
+++ b/Userland/Utilities/ifconfig.cpp
@@ -11,6 +11,7 @@
#include <AK/JsonObject.h>
#include <AK/NumberFormat.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -31,7 +32,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.parse(arguments);
if (value_ipv4.is_empty() && value_adapter.is_empty() && value_mask.is_empty()) {
- auto file = TRY(Core::Stream::File::open("/sys/kernel/net/adapters"sv, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open("/sys/kernel/net/adapters"sv, Core::File::OpenMode::Read));
auto file_contents = TRY(file->read_until_eof());
auto json = TRY(JsonValue::from_string(file_contents));
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp
index 3ca9af8d67..2528eb7b78 100644
--- a/Userland/Utilities/js.cpp
+++ b/Userland/Utilities/js.cpp
@@ -95,7 +95,7 @@ enum class PrintTarget {
static ErrorOr<void> print(JS::Value value, PrintTarget target = PrintTarget::StandardOutput)
{
- auto stream = TRY(target == PrintTarget::StandardError ? Core::Stream::File::standard_error() : Core::Stream::File::standard_output());
+ auto stream = TRY(target == PrintTarget::StandardError ? Core::File::standard_error() : Core::File::standard_output());
return print(value, *stream);
}
@@ -185,7 +185,7 @@ static ErrorOr<String> read_next_piece()
static ErrorOr<void> write_to_file(String const& path)
{
- auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Write, 0666));
+ auto file = TRY(Core::File::open(path, Core::File::OpenMode::Write, 0666));
for (size_t i = 0; i < g_repl_statements.size(); i++) {
auto line = g_repl_statements[i].bytes();
if (line.size() > 0 && i != g_repl_statements.size() - 1) {
@@ -334,7 +334,7 @@ static JS::ThrowCompletionOr<JS::Value> load_ini_impl(JS::VM& vm)
auto& realm = *vm.current_realm();
auto filename = TRY(vm.argument(0).to_deprecated_string(vm));
- auto file_or_error = Core::Stream::File::open(filename, Core::Stream::OpenMode::Read);
+ auto file_or_error = Core::File::open(filename, Core::File::OpenMode::Read);
if (file_or_error.is_error())
return vm.throw_completion<JS::Error>(DeprecatedString::formatted("Failed to open '{}': {}", filename, file_or_error.error()));
@@ -354,7 +354,7 @@ static JS::ThrowCompletionOr<JS::Value> load_ini_impl(JS::VM& vm)
static JS::ThrowCompletionOr<JS::Value> load_json_impl(JS::VM& vm)
{
auto filename = TRY(vm.argument(0).to_string(vm));
- auto file_or_error = Core::Stream::File::open(filename, Core::Stream::OpenMode::Read);
+ auto file_or_error = Core::File::open(filename, Core::File::OpenMode::Read);
if (file_or_error.is_error())
return vm.throw_completion<JS::Error>(DeprecatedString::formatted("Failed to open '{}': {}", filename, file_or_error.error()));
@@ -871,7 +871,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
warnln("Warning: Multiple files supplied, this will concatenate the sources and resolve modules as if it was the first file");
for (auto& path : script_paths) {
- auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
auto file_contents = TRY(file->read_until_eof());
auto source = StringView { file_contents };
diff --git a/Userland/Utilities/json.cpp b/Userland/Utilities/json.cpp
index d0653dc453..f8ce64e7bf 100644
--- a/Userland/Utilities/json.cpp
+++ b/Userland/Utilities/json.cpp
@@ -14,6 +14,7 @@
#include <AK/Types.h>
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -43,7 +44,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
VERIFY(spaces_in_indent >= 0);
args_parser.parse(arguments);
- auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read));
TRY(Core::System::pledge("stdio"));
diff --git a/Userland/Utilities/lsblk.cpp b/Userland/Utilities/lsblk.cpp
index e6d611ff45..443624b420 100644
--- a/Userland/Utilities/lsblk.cpp
+++ b/Userland/Utilities/lsblk.cpp
@@ -9,6 +9,7 @@
#include <AK/StringView.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/DirIterator.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -38,19 +39,19 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
while (di.has_next()) {
auto dir = di.next_path();
auto command_set_filename = DeprecatedString::formatted("/sys/devices/storage/{}/command_set", dir);
- auto command_set_file = Core::Stream::File::open(command_set_filename, Core::Stream::OpenMode::Read);
+ auto command_set_file = Core::File::open(command_set_filename, Core::File::OpenMode::Read);
if (command_set_file.is_error()) {
dbgln("Error: Could not open {}: {}", command_set_filename, command_set_file.error());
continue;
}
auto last_lba_filename = DeprecatedString::formatted("/sys/devices/storage/{}/last_lba", dir);
- auto last_lba_file = Core::Stream::File::open(last_lba_filename, Core::Stream::OpenMode::Read);
+ auto last_lba_file = Core::File::open(last_lba_filename, Core::File::OpenMode::Read);
if (last_lba_file.is_error()) {
dbgln("Error: Could not open {}: {}", last_lba_filename, last_lba_file.error());
continue;
}
auto sector_size_filename = DeprecatedString::formatted("/sys/devices/storage/{}/sector_size", dir);
- auto sector_size_file = Core::Stream::File::open(sector_size_filename, Core::Stream::OpenMode::Read);
+ auto sector_size_file = Core::File::open(sector_size_filename, Core::File::OpenMode::Read);
if (sector_size_file.is_error()) {
dbgln("Error: Could not open {}: {}", sector_size_filename, sector_size_file.error());
continue;
diff --git a/Userland/Utilities/lscpu.cpp b/Userland/Utilities/lscpu.cpp
index 4a9f143c78..21b00cc492 100644
--- a/Userland/Utilities/lscpu.cpp
+++ b/Userland/Utilities/lscpu.cpp
@@ -9,6 +9,7 @@
#include <AK/JsonArray.h>
#include <AK/JsonObject.h>
#include <AK/NumberFormat.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -59,7 +60,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
TRY(Core::System::unveil("/sys/kernel/cpuinfo", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
- auto file = TRY(Core::Stream::File::open("/sys/kernel/cpuinfo"sv, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open("/sys/kernel/cpuinfo"sv, Core::File::OpenMode::Read));
auto file_contents = TRY(file->read_until_eof());
auto json = TRY(JsonValue::from_string(file_contents));
auto const& array = json.as_array();
diff --git a/Userland/Utilities/lsirq.cpp b/Userland/Utilities/lsirq.cpp
index b572563905..55dc1c34b0 100644
--- a/Userland/Utilities/lsirq.cpp
+++ b/Userland/Utilities/lsirq.cpp
@@ -7,6 +7,7 @@
#include <AK/JsonArray.h>
#include <AK/JsonObject.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -17,7 +18,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
TRY(Core::System::unveil("/sys/kernel/interrupts", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
- auto proc_interrupts = TRY(Core::Stream::File::open("/sys/kernel/interrupts"sv, Core::Stream::OpenMode::Read));
+ auto proc_interrupts = TRY(Core::File::open("/sys/kernel/interrupts"sv, Core::File::OpenMode::Read));
TRY(Core::System::pledge("stdio"));
diff --git a/Userland/Utilities/lsjails.cpp b/Userland/Utilities/lsjails.cpp
index 7f0fb392cb..06b6d02fd3 100644
--- a/Userland/Utilities/lsjails.cpp
+++ b/Userland/Utilities/lsjails.cpp
@@ -6,6 +6,7 @@
#include <AK/JsonArray.h>
#include <AK/JsonObject.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -16,7 +17,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
TRY(Core::System::unveil("/sys/kernel/jails", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
- auto jails_data = TRY(Core::Stream::File::open("/sys/kernel/jails"sv, Core::Stream::OpenMode::Read));
+ auto jails_data = TRY(Core::File::open("/sys/kernel/jails"sv, Core::File::OpenMode::Read));
TRY(Core::System::pledge("stdio"));
diff --git a/Userland/Utilities/lsof.cpp b/Userland/Utilities/lsof.cpp
index c59d5922cb..cc7901fab8 100644
--- a/Userland/Utilities/lsof.cpp
+++ b/Userland/Utilities/lsof.cpp
@@ -11,6 +11,7 @@
#include <AK/JsonValue.h>
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/ProcessStatisticsReader.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
@@ -65,7 +66,7 @@ static bool parse_name(StringView name, OpenFile& file)
static Vector<OpenFile> get_open_files_by_pid(pid_t pid)
{
- auto file = Core::Stream::File::open(DeprecatedString::formatted("/proc/{}/fds", pid), Core::Stream::OpenMode::Read);
+ auto file = Core::File::open(DeprecatedString::formatted("/proc/{}/fds", pid), Core::File::OpenMode::Read);
if (file.is_error()) {
outln("lsof: PID {}: {}", pid, file.error());
return Vector<OpenFile>();
diff --git a/Userland/Utilities/lspci.cpp b/Userland/Utilities/lspci.cpp
index feac6a4ae6..6f97cf5414 100644
--- a/Userland/Utilities/lspci.cpp
+++ b/Userland/Utilities/lspci.cpp
@@ -13,6 +13,7 @@
#include <AK/StringView.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/DirIterator.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -89,31 +90,31 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto function = convert_sysfs_value_to_uint(function_parts[1]);
auto vendor_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/vendor", dir);
- auto vendor_id_file = Core::Stream::File::open(vendor_id_filename, Core::Stream::OpenMode::Read);
+ auto vendor_id_file = Core::File::open(vendor_id_filename, Core::File::OpenMode::Read);
if (vendor_id_file.is_error()) {
dbgln("Error: Could not open {}: {}", vendor_id_filename, vendor_id_file.error());
continue;
}
auto device_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/device_id", dir);
- auto device_id_file = Core::Stream::File::open(device_id_filename, Core::Stream::OpenMode::Read);
+ auto device_id_file = Core::File::open(device_id_filename, Core::File::OpenMode::Read);
if (device_id_file.is_error()) {
dbgln("Error: Could not open {}: {}", device_id_filename, device_id_file.error());
continue;
}
auto class_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/class", dir);
- auto class_id_file = Core::Stream::File::open(class_id_filename, Core::Stream::OpenMode::Read);
+ auto class_id_file = Core::File::open(class_id_filename, Core::File::OpenMode::Read);
if (class_id_file.is_error()) {
dbgln("Error: Could not open {}: {}", class_id_filename, class_id_file.error());
continue;
}
auto subclass_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/subclass", dir);
- auto subclass_id_file = Core::Stream::File::open(subclass_id_filename, Core::Stream::OpenMode::Read);
+ auto subclass_id_file = Core::File::open(subclass_id_filename, Core::File::OpenMode::Read);
if (subclass_id_file.is_error()) {
dbgln("Error: Could not open {}: {}", subclass_id_filename, subclass_id_file.error());
continue;
}
auto revision_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/revision", dir);
- auto revision_id_file = Core::Stream::File::open(revision_id_filename, Core::Stream::OpenMode::Read);
+ auto revision_id_file = Core::File::open(revision_id_filename, Core::File::OpenMode::Read);
if (revision_id_file.is_error()) {
dbgln("Error: Could not open {}: {}", revision_id_filename, revision_id_file.error());
continue;
@@ -177,7 +178,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
continue;
for (size_t bar_index = 0; bar_index <= 5; bar_index++) {
auto bar_value_filename = DeprecatedString::formatted("/sys/bus/pci/{}/bar{}", dir, bar_index);
- auto bar_value_file = Core::Stream::File::open(bar_value_filename, Core::Stream::OpenMode::Read);
+ auto bar_value_file = Core::File::open(bar_value_filename, Core::File::OpenMode::Read);
if (bar_value_file.is_error()) {
dbgln("Error: Could not open {}: {}", bar_value_filename, bar_value_file.error());
continue;
diff --git a/Userland/Utilities/lsusb.cpp b/Userland/Utilities/lsusb.cpp
index 5f4806b96c..a3eeeb8796 100644
--- a/Userland/Utilities/lsusb.cpp
+++ b/Userland/Utilities/lsusb.cpp
@@ -12,6 +12,7 @@
#include <AK/LexicalPath.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/DirIterator.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -48,7 +49,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
while (usb_devices.has_next()) {
auto full_path = LexicalPath(usb_devices.next_full_path());
- auto proc_usb_device = Core::Stream::File::open(full_path.string(), Core::Stream::OpenMode::Read);
+ auto proc_usb_device = Core::File::open(full_path.string(), Core::File::OpenMode::Read);
if (proc_usb_device.is_error()) {
warnln("Failed to open {}: {}", full_path.string(), proc_usb_device.error());
continue;
diff --git a/Userland/Utilities/man.cpp b/Userland/Utilities/man.cpp
index 80546b0e6b..95d365019c 100644
--- a/Userland/Utilities/man.cpp
+++ b/Userland/Utilities/man.cpp
@@ -9,6 +9,7 @@
#include <AK/DeprecatedString.h>
#include <AK/Utf8View.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -84,7 +85,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
.to_deprecated_string();
pid_t pager_pid = TRY(pipe_to_pager(pager));
- auto file = TRY(Core::Stream::File::open(TRY(page->path()), Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(TRY(page->path()), Core::File::OpenMode::Read));
TRY(Core::System::pledge("stdio proc"));
diff --git a/Userland/Utilities/markdown-check.cpp b/Userland/Utilities/markdown-check.cpp
index 55c45d2d75..549a18f272 100644
--- a/Userland/Utilities/markdown-check.cpp
+++ b/Userland/Utilities/markdown-check.cpp
@@ -20,6 +20,7 @@
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/DeprecatedFile.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibMain/Main.h>
#include <LibMarkdown/Document.h>
@@ -249,7 +250,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
outln("Reading and parsing Markdown files ...");
HashMap<DeprecatedString, MarkdownLinkage> files;
for (auto path : file_paths) {
- auto file_or_error = Core::Stream::File::open(path, Core::Stream::OpenMode::Read);
+ auto file_or_error = Core::File::open(path, Core::File::OpenMode::Read);
if (file_or_error.is_error()) {
warnln("Failed to open {}: {}", path, file_or_error.error());
// Since this should never happen anyway, fail early.
diff --git a/Userland/Utilities/md.cpp b/Userland/Utilities/md.cpp
index a027043219..6c28fc31f9 100644
--- a/Userland/Utilities/md.cpp
+++ b/Userland/Utilities/md.cpp
@@ -6,6 +6,7 @@
#include <AK/DeprecatedString.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -41,7 +42,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}
- auto file = TRY(Core::Stream::File::open_file_or_standard_stream(filename, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open_file_or_standard_stream(filename, Core::File::OpenMode::Read));
TRY(Core::System::pledge("stdio"));
diff --git a/Userland/Utilities/mount.cpp b/Userland/Utilities/mount.cpp
index e1d91b4146..3b6f9f323d 100644
--- a/Userland/Utilities/mount.cpp
+++ b/Userland/Utilities/mount.cpp
@@ -9,6 +9,7 @@
#include <AK/JsonValue.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/DirIterator.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -112,8 +113,8 @@ static ErrorOr<void> mount_all()
bool all_ok = true;
auto process_fstab_entries = [&](StringView path) -> ErrorOr<void> {
- auto file_unbuffered = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
- auto file = TRY(Core::Stream::BufferedFile::create(move(file_unbuffered)));
+ auto file_unbuffered = TRY(Core::File::open(path, Core::File::OpenMode::Read));
+ auto file = TRY(Core::BufferedFile::create(move(file_unbuffered)));
while (TRY(file->can_read_line())) {
auto line = TRY(file->read_line(buffer));
@@ -148,7 +149,7 @@ static ErrorOr<void> mount_all()
static ErrorOr<void> print_mounts()
{
// Output info about currently mounted filesystems.
- auto df = TRY(Core::Stream::File::open("/sys/kernel/df"sv, Core::Stream::OpenMode::Read));
+ auto df = TRY(Core::File::open("/sys/kernel/df"sv, Core::File::OpenMode::Read));
auto content = TRY(df->read_until_eof());
auto json = TRY(JsonValue::from_string(content));
diff --git a/Userland/Utilities/netstat.cpp b/Userland/Utilities/netstat.cpp
index 0f5038591e..6e99860a45 100644
--- a/Userland/Utilities/netstat.cpp
+++ b/Userland/Utilities/netstat.cpp
@@ -11,6 +11,7 @@
#include <AK/JsonObject.h>
#include <AK/QuickSort.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/ProcessStatisticsReader.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
@@ -154,7 +155,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
if (!has_protocol_flag || flag_tcp) {
- auto file = TRY(Core::Stream::File::open("/sys/kernel/net/tcp"sv, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open("/sys/kernel/net/tcp"sv, Core::File::OpenMode::Read));
auto file_contents = TRY(file->read_until_eof());
auto json_or_error = JsonValue::from_string(file_contents);
if (json_or_error.is_error()) {
@@ -246,7 +247,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
if (!has_protocol_flag || flag_udp) {
- auto file = TRY(Core::Stream::File::open("/sys/kernel/net/udp"sv, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open("/sys/kernel/net/udp"sv, Core::File::OpenMode::Read));
auto file_contents = TRY(file->read_until_eof());
auto json = TRY(JsonValue::from_string(file_contents));
diff --git a/Userland/Utilities/nologin.cpp b/Userland/Utilities/nologin.cpp
index 8c187d9764..c28572c626 100644
--- a/Userland/Utilities/nologin.cpp
+++ b/Userland/Utilities/nologin.cpp
@@ -5,6 +5,7 @@
*/
#include <AK/StringView.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -13,7 +14,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
{
TRY(Core::System::pledge("stdio rpath"sv));
- auto file_or_error = Core::Stream::File::open("/etc/nologin"sv, Core::Stream::OpenMode::Read);
+ auto file_or_error = Core::File::open("/etc/nologin"sv, Core::File::OpenMode::Read);
if (file_or_error.is_error()) {
outln("This account is currently not available.");
} else {
diff --git a/Userland/Utilities/nproc.cpp b/Userland/Utilities/nproc.cpp
index 54f730fe7a..4d8eccc00b 100644
--- a/Userland/Utilities/nproc.cpp
+++ b/Userland/Utilities/nproc.cpp
@@ -5,6 +5,7 @@
*/
#include <AK/JsonObject.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -12,7 +13,7 @@
ErrorOr<int> serenity_main(Main::Arguments)
{
TRY(Core::System::pledge("stdio rpath"));
- auto file = TRY(Core::Stream::File::open("/sys/kernel/cpuinfo"sv, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open("/sys/kernel/cpuinfo"sv, Core::File::OpenMode::Read));
auto buffer = TRY(file->read_until_eof());
auto json = TRY(JsonValue::from_string(buffer));
diff --git a/Userland/Utilities/pmap.cpp b/Userland/Utilities/pmap.cpp
index 7a95a43231..49bb7d8153 100644
--- a/Userland/Utilities/pmap.cpp
+++ b/Userland/Utilities/pmap.cpp
@@ -8,6 +8,7 @@
#include <AK/JsonObject.h>
#include <AK/QuickSort.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -26,7 +27,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_positional_argument(pid, "PID", "PID", Core::ArgsParser::Required::Yes);
args_parser.parse(arguments);
- auto file = TRY(Core::Stream::File::open(DeprecatedString::formatted("/proc/{}/vm", pid), Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(DeprecatedString::formatted("/proc/{}/vm", pid), Core::File::OpenMode::Read));
outln("{}:", pid);
diff --git a/Userland/Utilities/pro.cpp b/Userland/Utilities/pro.cpp
index 0f8b8dda3b..150f80394d 100644
--- a/Userland/Utilities/pro.cpp
+++ b/Userland/Utilities/pro.cpp
@@ -242,7 +242,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
RefPtr<Protocol::Request> request;
auto protocol_client = TRY(Protocol::RequestClient::try_create());
- auto output_stream = ConditionalOutputStream { [&] { return should_save_stream_data; }, TRY(Core::Stream::File::adopt_fd(output_fd, Core::Stream::OpenMode::Write)) };
+ auto output_stream = ConditionalOutputStream { [&] { return should_save_stream_data; }, TRY(Core::File::adopt_fd(output_fd, Core::File::OpenMode::Write)) };
// https://httpwg.org/specs/rfc9110.html#authentication
auto const has_credentials = !credentials.is_empty();
diff --git a/Userland/Utilities/reboot.cpp b/Userland/Utilities/reboot.cpp
index 2c24c9b225..2aea62645b 100644
--- a/Userland/Utilities/reboot.cpp
+++ b/Userland/Utilities/reboot.cpp
@@ -5,12 +5,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibMain/Main.h>
ErrorOr<int> serenity_main(Main::Arguments)
{
- auto file = TRY(Core::Stream::File::open("/sys/kernel/power_state"sv, Core::Stream::OpenMode::Write));
+ auto file = TRY(Core::File::open("/sys/kernel/power_state"sv, Core::File::OpenMode::Write));
const DeprecatedString file_contents = "1";
TRY(file->write(file_contents.bytes()));
diff --git a/Userland/Utilities/route.cpp b/Userland/Utilities/route.cpp
index 93c89a0167..84fe136dcd 100644
--- a/Userland/Utilities/route.cpp
+++ b/Userland/Utilities/route.cpp
@@ -11,6 +11,7 @@
#include <AK/QuickSort.h>
#include <AK/StringView.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/ProcessStatisticsReader.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
@@ -89,7 +90,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
};
if (modify_action.is_empty()) {
- auto file = TRY(Core::Stream::File::open("/sys/kernel/net/route"sv, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open("/sys/kernel/net/route"sv, Core::File::OpenMode::Read));
auto file_contents = TRY(file->read_until_eof());
auto json = TRY(JsonValue::from_string(file_contents));
diff --git a/Userland/Utilities/sed.cpp b/Userland/Utilities/sed.cpp
index d25dd969a7..cd1d4363e2 100644
--- a/Userland/Utilities/sed.cpp
+++ b/Userland/Utilities/sed.cpp
@@ -8,6 +8,7 @@
#include <AK/GenericLexer.h>
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -116,17 +117,17 @@ ErrorOr<int> serenity_main(Main::Arguments args)
auto command = TRY(parse_command(command_input));
- Optional<NonnullOwnPtr<Core::Stream::File>> maybe_output_file;
+ Optional<NonnullOwnPtr<Core::File>> maybe_output_file;
if (command.output_filepath.has_value())
- maybe_output_file = TRY(Core::Stream::File::open_file_or_standard_stream(command.output_filepath.release_value(), Core::Stream::OpenMode::Write));
+ maybe_output_file = TRY(Core::File::open_file_or_standard_stream(command.output_filepath.release_value(), Core::File::OpenMode::Write));
if (filepaths.is_empty())
filepaths = { "-"sv };
Array<u8, PAGE_SIZE> buffer {};
for (auto const& filepath : filepaths) {
- auto file_unbuffered = TRY(Core::Stream::File::open_file_or_standard_stream(filepath, Core::Stream::OpenMode::Read));
- auto file = TRY(Core::Stream::BufferedFile::create(move(file_unbuffered)));
+ auto file_unbuffered = TRY(Core::File::open_file_or_standard_stream(filepath, Core::File::OpenMode::Read));
+ auto file = TRY(Core::BufferedFile::create(move(file_unbuffered)));
while (!file->is_eof()) {
auto line = TRY(file->read_line(buffer));
diff --git a/Userland/Utilities/shot.cpp b/Userland/Utilities/shot.cpp
index 3ecbfff3cb..f39f8df362 100644
--- a/Userland/Utilities/shot.cpp
+++ b/Userland/Utilities/shot.cpp
@@ -161,7 +161,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (edit_image)
output_path = Core::DateTime::now().to_deprecated_string("/tmp/screenshot-%Y-%m-%d-%H-%M-%S.png"sv);
- auto file_or_error = Core::Stream::File::open(output_path, Core::Stream::OpenMode::ReadWrite);
+ auto file_or_error = Core::File::open(output_path, Core::File::OpenMode::ReadWrite);
if (file_or_error.is_error()) {
warnln("Could not open '{}' for writing: {}", output_path, file_or_error.error());
return 1;
diff --git a/Userland/Utilities/shuf.cpp b/Userland/Utilities/shuf.cpp
index 30a1c9f379..1b0c94bf99 100644
--- a/Userland/Utilities/shuf.cpp
+++ b/Userland/Utilities/shuf.cpp
@@ -9,6 +9,7 @@
#include <AK/Random.h>
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -28,7 +29,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.parse(arguments);
- auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read));
ByteBuffer buffer = TRY(file->read_until_eof());
u8 input_delimiter = is_zero_terminated ? '\0' : '\n';
diff --git a/Userland/Utilities/shutdown.cpp b/Userland/Utilities/shutdown.cpp
index 5555ba3693..968e88e835 100644
--- a/Userland/Utilities/shutdown.cpp
+++ b/Userland/Utilities/shutdown.cpp
@@ -6,6 +6,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibMain/Main.h>
#include <fcntl.h>
@@ -14,7 +15,7 @@
ErrorOr<int> serenity_main(Main::Arguments)
{
- auto file = TRY(Core::Stream::File::open("/sys/kernel/power_state"sv, Core::Stream::OpenMode::Write));
+ auto file = TRY(Core::File::open("/sys/kernel/power_state"sv, Core::File::OpenMode::Write));
const DeprecatedString file_contents = "2";
TRY(file->write(file_contents.bytes()));
diff --git a/Userland/Utilities/sort.cpp b/Userland/Utilities/sort.cpp
index 46d0a9ca80..d91cbf3d08 100644
--- a/Userland/Utilities/sort.cpp
+++ b/Userland/Utilities/sort.cpp
@@ -9,6 +9,7 @@
#include <AK/QuickSort.h>
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -60,8 +61,8 @@ struct Options {
static ErrorOr<void> load_file(Options options, StringView filename, Vector<Line>& lines, HashTable<Line>& seen)
{
- auto file = TRY(Core::Stream::BufferedFile::create(
- TRY(Core::Stream::File::open_file_or_standard_stream(filename, Core::Stream::OpenMode::Read))));
+ auto file = TRY(Core::BufferedFile::create(
+ TRY(Core::File::open_file_or_standard_stream(filename, Core::File::OpenMode::Read))));
// FIXME: Unlimited line length
auto buffer = TRY(ByteBuffer::create_uninitialized(4096));
diff --git a/Userland/Utilities/sql.cpp b/Userland/Utilities/sql.cpp
index 9158cc793e..31be2c664f 100644
--- a/Userland/Utilities/sql.cpp
+++ b/Userland/Utilities/sql.cpp
@@ -152,7 +152,7 @@ private:
NonnullRefPtr<SQL::SQLClient> m_sql_client;
SQL::ConnectionID m_connection_id { 0 };
Core::EventLoop& m_loop;
- OwnPtr<Core::Stream::BufferedFile> m_input_file { nullptr };
+ OwnPtr<Core::BufferedFile> m_input_file { nullptr };
bool m_quit_when_files_read { false };
Vector<DeprecatedString> m_input_file_chain {};
Array<u8, 4096> m_buffer {};
@@ -161,13 +161,13 @@ private:
{
if (!m_input_file && !m_input_file_chain.is_empty()) {
auto file_name = m_input_file_chain.take_first();
- auto file_or_error = Core::Stream::File::open(file_name, Core::Stream::OpenMode::Read);
+ auto file_or_error = Core::File::open(file_name, Core::File::OpenMode::Read);
if (file_or_error.is_error()) {
warnln("Input file {} could not be opened: {}", file_name, file_or_error.error());
return {};
}
- auto buffered_file_or_error = Core::Stream::BufferedFile::create(file_or_error.release_value());
+ auto buffered_file_or_error = Core::BufferedFile::create(file_or_error.release_value());
if (buffered_file_or_error.is_error()) {
warnln("Input file {} could not be buffered: {}", file_name, buffered_file_or_error.error());
return {};
diff --git a/Userland/Utilities/strace.cpp b/Userland/Utilities/strace.cpp
index 1996e5d12d..a20ae8a55a 100644
--- a/Userland/Utilities/strace.cpp
+++ b/Userland/Utilities/strace.cpp
@@ -11,6 +11,7 @@
#include <AK/Types.h>
#include <Kernel/API/SyscallString.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -836,8 +837,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
parser.parse(arguments);
auto trace_file = output_filename.is_empty()
- ? TRY(Core::Stream::File::standard_error())
- : TRY(Core::Stream::File::open(output_filename, Core::Stream::OpenMode::Write));
+ ? TRY(Core::File::standard_error())
+ : TRY(Core::File::open(output_filename, Core::File::OpenMode::Write));
auto parse_syscalls = [](char const* option, auto& hash_table) {
if (option != nullptr) {
diff --git a/Userland/Utilities/strings.cpp b/Userland/Utilities/strings.cpp
index 531db31838..2fb364c97f 100644
--- a/Userland/Utilities/strings.cpp
+++ b/Userland/Utilities/strings.cpp
@@ -7,6 +7,7 @@
#include <AK/CharacterTypes.h>
#include <AK/Forward.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -67,7 +68,7 @@ static ErrorOr<void> process_strings_in_file(StringView path, bool show_paths, S
{
Array<u8, buffer_read_size> buffer;
Vector<u8> output_characters;
- auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read));
size_t processed_characters = 0;
size_t string_offset_position = 0;
bool did_show_path = false;
diff --git a/Userland/Utilities/sysctl.cpp b/Userland/Utilities/sysctl.cpp
index c234edbf85..3834f9aa12 100644
--- a/Userland/Utilities/sysctl.cpp
+++ b/Userland/Utilities/sysctl.cpp
@@ -7,6 +7,7 @@
#include <LibCore/ArgsParser.h>
#include <LibCore/DirIterator.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibMain/Main.h>
@@ -15,7 +16,7 @@ static bool s_set_variable = false;
static DeprecatedString get_variable(StringView name)
{
auto path = DeprecatedString::formatted("/sys/kernel/variables/{}", name);
- auto file = Core::Stream::File::open(path, Core::Stream::OpenMode::Read);
+ auto file = Core::File::open(path, Core::File::OpenMode::Read);
if (file.is_error()) {
warnln("Failed to open {}: {}", path, file.error());
return {};
@@ -43,7 +44,7 @@ static bool write_variable(StringView name, StringView value)
if (old_value.is_null())
return false;
auto path = DeprecatedString::formatted("/sys/kernel/variables/{}", name);
- auto file = Core::Stream::File::open(path, Core::Stream::OpenMode::Write);
+ auto file = Core::File::open(path, Core::File::OpenMode::Write);
if (file.is_error()) {
warnln("Failed to open {}: {}", path, file.error());
return false;
diff --git a/Userland/Utilities/tail.cpp b/Userland/Utilities/tail.cpp
index 96b5fe0234..658c4aba34 100644
--- a/Userland/Utilities/tail.cpp
+++ b/Userland/Utilities/tail.cpp
@@ -6,13 +6,14 @@
#include <LibCore/ArgsParser.h>
#include <LibCore/EventLoop.h>
+#include <LibCore/File.h>
#include <LibCore/FileWatcher.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#define DEFAULT_LINE_COUNT 10
-static ErrorOr<void> tail_from_pos(Core::Stream::File& file, off_t startline)
+static ErrorOr<void> tail_from_pos(Core::File& file, off_t startline)
{
TRY(file.seek(startline + 1, SeekMode::SetPosition));
auto buffer = TRY(file.read_until_eof());
@@ -20,7 +21,7 @@ static ErrorOr<void> tail_from_pos(Core::Stream::File& file, off_t startline)
return {};
}
-static ErrorOr<off_t> find_seek_pos(Core::Stream::File& file, int wanted_lines)
+static ErrorOr<off_t> find_seek_pos(Core::File& file, int wanted_lines)
{
// Rather than reading the whole file, start at the end and work backwards,
// stopping when we've found the number of lines we want.
@@ -61,7 +62,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_positional_argument(file, "File path", "file", Core::ArgsParser::Required::No);
args_parser.parse(arguments);
- auto f = TRY(Core::Stream::File::open_file_or_standard_stream(file, Core::Stream::OpenMode::Read));
+ auto f = TRY(Core::File::open_file_or_standard_stream(file, Core::File::OpenMode::Read));
if (!follow)
TRY(Core::System::pledge("stdio"));
diff --git a/Userland/Utilities/tar.cpp b/Userland/Utilities/tar.cpp
index c7af350005..2a156b9d02 100644
--- a/Userland/Utilities/tar.cpp
+++ b/Userland/Utilities/tar.cpp
@@ -64,7 +64,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (!directory.is_empty())
TRY(Core::System::chdir(directory));
- NonnullOwnPtr<AK::Stream> input_stream = TRY(Core::Stream::File::open_file_or_standard_stream(archive_file, Core::Stream::OpenMode::Read));
+ NonnullOwnPtr<AK::Stream> input_stream = TRY(Core::File::open_file_or_standard_stream(archive_file, Core::File::OpenMode::Read));
if (gzip)
input_stream = make<Compress::GzipDecompressor>(move(input_stream));
@@ -206,10 +206,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 1;
}
- NonnullOwnPtr<AK::Stream> output_stream = TRY(Core::Stream::File::standard_output());
+ NonnullOwnPtr<AK::Stream> output_stream = TRY(Core::File::standard_output());
if (!archive_file.is_empty())
- output_stream = TRY(Core::Stream::File::open(archive_file, Core::Stream::OpenMode::Write));
+ output_stream = TRY(Core::File::open(archive_file, Core::File::OpenMode::Write));
if (!directory.is_empty())
TRY(Core::System::chdir(directory));
diff --git a/Userland/Utilities/test-fuzz.cpp b/Userland/Utilities/test-fuzz.cpp
index a7539d1774..8f01380dd0 100644
--- a/Userland/Utilities/test-fuzz.cpp
+++ b/Userland/Utilities/test-fuzz.cpp
@@ -6,6 +6,7 @@
#include <AK/DeprecatedString.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibMain/Main.h>
#include <unistd.h>
@@ -156,7 +157,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto fn = parse_target_name(type);
- auto file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Read));
auto input = TRY(file->read_until_eof());
return fn(input.data(), input.size());
diff --git a/Userland/Utilities/tsort.cpp b/Userland/Utilities/tsort.cpp
index 201e063698..f51b2f96f6 100644
--- a/Userland/Utilities/tsort.cpp
+++ b/Userland/Utilities/tsort.cpp
@@ -7,6 +7,7 @@
#include <AK/CharacterTypes.h>
#include <AK/HashMap.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -103,7 +104,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_option(quiet, "Suppress warnings about cycles", "quiet", 'q');
args_parser.parse(arguments);
- auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read));
auto input_bytes = TRY(file->read_until_eof());
auto inputs = StringView(input_bytes).split_view_if(is_ascii_space);
diff --git a/Userland/Utilities/uniq.cpp b/Userland/Utilities/uniq.cpp
index c8166e4968..35b502e4c8 100644
--- a/Userland/Utilities/uniq.cpp
+++ b/Userland/Utilities/uniq.cpp
@@ -8,11 +8,12 @@
#include <AK/RefPtr.h>
#include <AK/StringView.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <unistd.h>
-static ErrorOr<void> write_line_content(StringView line, size_t count, bool duplicates_only, bool print_count, Core::Stream::File& outfile)
+static ErrorOr<void> write_line_content(StringView line, size_t count, bool duplicates_only, bool print_count, Core::File& outfile)
{
if (duplicates_only && count <= 1)
return {};
@@ -79,8 +80,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 0;
}
- auto infile = TRY(Core::Stream::BufferedFile::create(TRY(Core::Stream::File::open_file_or_standard_stream(inpath, Core::Stream::OpenMode::Read))));
- auto outfile = TRY(Core::Stream::File::open_file_or_standard_stream(outpath, Core::Stream::OpenMode::Write));
+ auto infile = TRY(Core::BufferedFile::create(TRY(Core::File::open_file_or_standard_stream(inpath, Core::File::OpenMode::Read))));
+ auto outfile = TRY(Core::File::open_file_or_standard_stream(outpath, Core::File::OpenMode::Write));
size_t count = 0;
ByteBuffer previous_buf = TRY(ByteBuffer::create_uninitialized(1024));
diff --git a/Userland/Utilities/uptime.cpp b/Userland/Utilities/uptime.cpp
index 265fda6be5..f70cdaf8c4 100644
--- a/Userland/Utilities/uptime.cpp
+++ b/Userland/Utilities/uptime.cpp
@@ -6,6 +6,7 @@
*/
#include <AK/NumberFormat.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -14,7 +15,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
{
TRY(Core::System::pledge("stdio rpath"));
- auto file = TRY(Core::Stream::File::open("/sys/kernel/uptime"sv, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open("/sys/kernel/uptime"sv, Core::File::OpenMode::Read));
TRY(Core::System::pledge("stdio"));
diff --git a/Userland/Utilities/utmpupdate.cpp b/Userland/Utilities/utmpupdate.cpp
index cc7e282488..0bca719706 100644
--- a/Userland/Utilities/utmpupdate.cpp
+++ b/Userland/Utilities/utmpupdate.cpp
@@ -10,6 +10,7 @@
#include <AK/JsonValue.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/DateTime.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@@ -42,7 +43,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
dbgln("Updating utmp from UID={} GID={} EGID={} PID={}", getuid(), getgid(), getegid(), pid);
- auto file = TRY(Core::Stream::File::open("/var/run/utmp"sv, Core::Stream::OpenMode::ReadWrite));
+ auto file = TRY(Core::File::open("/var/run/utmp"sv, Core::File::OpenMode::ReadWrite));
auto file_contents = TRY(file->read_until_eof());
auto previous_json = TRY(JsonValue::from_string(file_contents));
diff --git a/Userland/Utilities/w.cpp b/Userland/Utilities/w.cpp
index 96f3854b2d..e92f791055 100644
--- a/Userland/Utilities/w.cpp
+++ b/Userland/Utilities/w.cpp
@@ -7,6 +7,7 @@
#include <AK/JsonObject.h>
#include <AK/JsonValue.h>
#include <LibCore/DateTime.h>
+#include <LibCore/File.h>
#include <LibCore/ProcessStatisticsReader.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
@@ -25,7 +26,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
- auto file = TRY(Core::Stream::File::open("/var/run/utmp"sv, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open("/var/run/utmp"sv, Core::File::OpenMode::Read));
auto file_contents = TRY(file->read_until_eof());
auto json = TRY(JsonValue::from_string(file_contents));
if (!json.is_object()) {
diff --git a/Userland/Utilities/wasm.cpp b/Userland/Utilities/wasm.cpp
index 5dababeb10..d82ff82fa2 100644
--- a/Userland/Utilities/wasm.cpp
+++ b/Userland/Utilities/wasm.cpp
@@ -7,6 +7,7 @@
#include <AK/MemoryStream.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/File.h>
#include <LibCore/MappedFile.h>
#include <LibLine/Editor.h>
#include <LibMain/Main.h>
@@ -338,7 +339,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (!parse_result.has_value())
return 1;
- g_stdout = TRY(Core::Stream::File::standard_output());
+ g_stdout = TRY(Core::File::standard_output());
g_printer = TRY(try_make<Wasm::Printer>(*g_stdout));
if (print && !attempt_instantiate) {
diff --git a/Userland/Utilities/xml.cpp b/Userland/Utilities/xml.cpp
index 7be705dd6a..78796142c5 100644
--- a/Userland/Utilities/xml.cpp
+++ b/Userland/Utilities/xml.cpp
@@ -10,6 +10,7 @@
#include <AK/URLParser.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/DeprecatedFile.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibMain/Main.h>
#include <LibXML/DOM/Document.h>
@@ -371,7 +372,7 @@ static auto parse(StringView contents)
if (url.scheme() != "file")
return Error::from_string_literal("NYI: Nonlocal entity");
- auto file = TRY(Core::Stream::File::open(url.path(), Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(url.path(), Core::File::OpenMode::Read));
return DeprecatedString::copy(TRY(file->read_until_eof()));
},
},
@@ -440,7 +441,7 @@ static void do_run_tests(XML::Document& document)
continue;
}
- auto file_result = Core::Stream::File::open(url.path(), Core::Stream::OpenMode::Read);
+ auto file_result = Core::File::open(url.path(), Core::File::OpenMode::Read);
if (file_result.is_error()) {
warnln("Read error for {}: {}", url.path(), file_result.error());
s_test_results.set(url.path(), TestResult::RunnerFailed);
@@ -468,7 +469,7 @@ static void do_run_tests(XML::Document& document)
auto out = suite.attributes.find("OUTPUT");
if (out != suite.attributes.end()) {
auto out_path = LexicalPath::join(test_base_path, out->value).string();
- auto file_result = Core::Stream::File::open(out_path, Core::Stream::OpenMode::Read);
+ auto file_result = Core::File::open(out_path, Core::File::OpenMode::Read);
if (file_result.is_error()) {
warnln("Read error for {}: {}", out_path, file_result.error());
s_test_results.set(url.path(), TestResult::RunnerFailed);
@@ -516,7 +517,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
parser.parse(arguments);
s_path = Core::DeprecatedFile::real_path_for(filename);
- auto file = TRY(Core::Stream::File::open(s_path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(s_path, Core::File::OpenMode::Read));
auto contents = TRY(file->read_until_eof());
auto xml_parser = parse(contents);
diff --git a/Userland/Utilities/zip.cpp b/Userland/Utilities/zip.cpp
index 7a9b88deff..12679b67e0 100644
--- a/Userland/Utilities/zip.cpp
+++ b/Userland/Utilities/zip.cpp
@@ -12,6 +12,7 @@
#include <LibCore/DateTime.h>
#include <LibCore/DeprecatedFile.h>
#include <LibCore/DirIterator.h>
+#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibCrypto/Checksum/CRC32.h>
@@ -50,12 +51,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
outln("Archive: {}", zip_file_path);
- auto file_stream = TRY(Core::Stream::File::open(zip_file_path, Core::Stream::OpenMode::Write));
+ auto file_stream = TRY(Core::File::open(zip_file_path, Core::File::OpenMode::Write));
Archive::ZipOutputStream zip_stream(move(file_stream));
auto add_file = [&](DeprecatedString path) -> ErrorOr<void> {
auto canonicalized_path = LexicalPath::canonicalized_path(path);
- auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
+ auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
auto file_buffer = TRY(file->read_until_eof());
Archive::ZipMember member {};
member.name = TRY(String::from_deprecated_string(canonicalized_path));