summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Tests/LibWasm/test-wasm.cpp3
-rw-r--r--Userland/Applications/FontEditor/GlyphEditorWidget.cpp1
-rw-r--r--Userland/Applications/HexEditor/HexEditor.cpp1
-rw-r--r--Userland/Applications/PixelPaint/Image.cpp2
-rw-r--r--Userland/Applications/PixelPaint/PaletteWidget.cpp3
-rw-r--r--Userland/Applications/Run/RunWindow.cpp1
-rw-r--r--Userland/Applications/Spreadsheet/ExportDialog.cpp1
-rw-r--r--Userland/Applications/Spreadsheet/Readers/Test/TestXSV.cpp1
-rw-r--r--Userland/Applications/Spreadsheet/Workbook.cpp2
-rw-r--r--Userland/Libraries/LibCore/File.cpp4
-rw-r--r--Userland/Libraries/LibCore/File.h4
-rw-r--r--Userland/Libraries/LibCore/FileStream.h45
-rw-r--r--Userland/Libraries/LibGUI/FileIconProvider.cpp1
-rw-r--r--Userland/Libraries/LibGfx/BitmapFont.cpp1
-rw-r--r--Userland/Libraries/LibSQL/Heap.h1
-rw-r--r--Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp4
-rw-r--r--Userland/Services/FileOperation/main.cpp6
-rw-r--r--Userland/Services/WindowServer/ScreenLayout.ipp1
-rw-r--r--Userland/Utilities/arp.cpp1
-rw-r--r--Userland/Utilities/cksum.cpp1
-rw-r--r--Userland/Utilities/errno.cpp2
-rw-r--r--Userland/Utilities/hexdump.cpp1
-rw-r--r--Userland/Utilities/mv.cpp1
-rw-r--r--Userland/Utilities/sql.cpp2
24 files changed, 42 insertions, 48 deletions
diff --git a/Tests/LibWasm/test-wasm.cpp b/Tests/LibWasm/test-wasm.cpp
index f761a74243..e748ae5f71 100644
--- a/Tests/LibWasm/test-wasm.cpp
+++ b/Tests/LibWasm/test-wasm.cpp
@@ -8,6 +8,7 @@
#include <LibTest/JavaScriptTestRunner.h>
#include <LibWasm/AbstractMachine/BytecodeInterpreter.h>
#include <LibWasm/Types.h>
+#include <string.h>
TEST_ROOT("Userland/Libraries/LibWasm/Tests");
@@ -16,7 +17,7 @@ TESTJS_GLOBAL_FUNCTION(read_binary_wasm_file, readBinaryWasmFile)
auto filename = TRY(vm.argument(0).to_string(global_object));
auto file = Core::File::open(filename, Core::OpenMode::ReadOnly);
if (file.is_error())
- return vm.throw_completion<JS::TypeError>(global_object, file.error().string());
+ return vm.throw_completion<JS::TypeError>(global_object, strerror(file.error().code()));
auto contents = file.value()->read_all();
auto array = JS::Uint8Array::create(global_object, contents.size());
contents.span().copy_to(array->data());
diff --git a/Userland/Applications/FontEditor/GlyphEditorWidget.cpp b/Userland/Applications/FontEditor/GlyphEditorWidget.cpp
index a36b3586bb..d4877bca4e 100644
--- a/Userland/Applications/FontEditor/GlyphEditorWidget.cpp
+++ b/Userland/Applications/FontEditor/GlyphEditorWidget.cpp
@@ -11,6 +11,7 @@
#include <LibGUI/Painter.h>
#include <LibGfx/BitmapFont.h>
#include <LibGfx/Palette.h>
+#include <string.h>
static int x_offset;
static int y_offset;
diff --git a/Userland/Applications/HexEditor/HexEditor.cpp b/Userland/Applications/HexEditor/HexEditor.cpp
index e4ec9af54e..35dc37f6ec 100644
--- a/Userland/Applications/HexEditor/HexEditor.cpp
+++ b/Userland/Applications/HexEditor/HexEditor.cpp
@@ -23,6 +23,7 @@
#include <ctype.h>
#include <fcntl.h>
#include <stdio.h>
+#include <string.h>
#include <unistd.h>
HexEditor::HexEditor()
diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp
index dca4e320e5..25b60c704b 100644
--- a/Userland/Applications/PixelPaint/Image.cpp
+++ b/Userland/Applications/PixelPaint/Image.cpp
@@ -159,7 +159,7 @@ Result<void, String> Image::write_to_file(const String& file_path) const
auto file_or_error = Core::File::open(file_path, (Core::OpenMode)(Core::OpenMode::WriteOnly | Core::OpenMode::Truncate));
if (file_or_error.is_error())
- return String { file_or_error.error().string() };
+ return String { strerror(file_or_error.error().code()) };
if (!file_or_error.value()->write(builder.string_view()))
return String { file_or_error.value()->error_string() };
diff --git a/Userland/Applications/PixelPaint/PaletteWidget.cpp b/Userland/Applications/PixelPaint/PaletteWidget.cpp
index bae64b426c..d5adcf290c 100644
--- a/Userland/Applications/PixelPaint/PaletteWidget.cpp
+++ b/Userland/Applications/PixelPaint/PaletteWidget.cpp
@@ -15,6 +15,7 @@
#include <LibGUI/ColorPicker.h>
#include <LibGUI/MessageBox.h>
#include <LibGfx/Palette.h>
+#include <string.h>
REGISTER_WIDGET(PixelPaint, PaletteWidget);
@@ -263,7 +264,7 @@ Result<Vector<Color>, String> PaletteWidget::load_palette_path(String const& fil
{
auto file_or_error = Core::File::open(file_path, Core::OpenMode::ReadOnly);
if (file_or_error.is_error())
- return String { file_or_error.error().string() };
+ return String { strerror(file_or_error.error().code()) };
auto& file = *file_or_error.value();
return load_palette_file(file);
diff --git a/Userland/Applications/Run/RunWindow.cpp b/Userland/Applications/Run/RunWindow.cpp
index 6964ac3be8..96eb30ce35 100644
--- a/Userland/Applications/Run/RunWindow.cpp
+++ b/Userland/Applications/Run/RunWindow.cpp
@@ -20,6 +20,7 @@
#include <LibGUI/Widget.h>
#include <spawn.h>
#include <stdio.h>
+#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
diff --git a/Userland/Applications/Spreadsheet/ExportDialog.cpp b/Userland/Applications/Spreadsheet/ExportDialog.cpp
index 62a82f53be..680d770e66 100644
--- a/Userland/Applications/Spreadsheet/ExportDialog.cpp
+++ b/Userland/Applications/Spreadsheet/ExportDialog.cpp
@@ -22,6 +22,7 @@
#include <LibGUI/TextBox.h>
#include <LibGUI/Wizards/WizardDialog.h>
#include <LibGUI/Wizards/WizardPage.h>
+#include <string.h>
#include <unistd.h>
// This is defined in ImportDialog.cpp, we can't include it twice, since the generated symbol is exported.
diff --git a/Userland/Applications/Spreadsheet/Readers/Test/TestXSV.cpp b/Userland/Applications/Spreadsheet/Readers/Test/TestXSV.cpp
index 5dbe2a5966..0103e4c6c0 100644
--- a/Userland/Applications/Spreadsheet/Readers/Test/TestXSV.cpp
+++ b/Userland/Applications/Spreadsheet/Readers/Test/TestXSV.cpp
@@ -10,6 +10,7 @@
#include "../XSV.h"
#include <AK/ByteBuffer.h>
#include <LibCore/File.h>
+#include <string.h>
TEST_CASE(should_parse_valid_data)
{
diff --git a/Userland/Applications/Spreadsheet/Workbook.cpp b/Userland/Applications/Spreadsheet/Workbook.cpp
index 40c94e12fe..df9b331d4e 100644
--- a/Userland/Applications/Spreadsheet/Workbook.cpp
+++ b/Userland/Applications/Spreadsheet/Workbook.cpp
@@ -51,7 +51,7 @@ Result<bool, String> Workbook::load(const StringView& filename)
sb.append("Failed to open ");
sb.append(filename);
sb.append(" for reading. Error: ");
- sb.append(file_or_error.error().string());
+ sb.appendff("{}", file_or_error.error());
return sb.to_string();
}
diff --git a/Userland/Libraries/LibCore/File.cpp b/Userland/Libraries/LibCore/File.cpp
index 141163b354..184042d569 100644
--- a/Userland/Libraries/LibCore/File.cpp
+++ b/Userland/Libraries/LibCore/File.cpp
@@ -27,11 +27,11 @@
namespace Core {
-Result<NonnullRefPtr<File>, OSError> File::open(String filename, OpenMode mode, mode_t permissions)
+ErrorOr<NonnullRefPtr<File>> File::open(String filename, OpenMode mode, mode_t permissions)
{
auto file = File::construct(move(filename));
if (!file->open_impl(mode, permissions))
- return OSError(file->error());
+ return Error::from_errno(file->error());
return file;
}
diff --git a/Userland/Libraries/LibCore/File.h b/Userland/Libraries/LibCore/File.h
index 2ec2e8c0a4..34b024b160 100644
--- a/Userland/Libraries/LibCore/File.h
+++ b/Userland/Libraries/LibCore/File.h
@@ -7,8 +7,6 @@
#pragma once
#include <AK/Error.h>
-#include <AK/OSError.h>
-#include <AK/Result.h>
#include <AK/String.h>
#include <LibCore/IODevice.h>
#include <sys/stat.h>
@@ -20,7 +18,7 @@ class File final : public IODevice {
public:
virtual ~File() override;
- static Result<NonnullRefPtr<File>, OSError> open(String filename, OpenMode, mode_t = 0644);
+ static ErrorOr<NonnullRefPtr<File>> open(String filename, OpenMode, mode_t = 0644);
String filename() const { return m_filename; }
void set_filename(const String filename) { m_filename = move(filename); }
diff --git a/Userland/Libraries/LibCore/FileStream.h b/Userland/Libraries/LibCore/FileStream.h
index 4069383b37..f8462397d7 100644
--- a/Userland/Libraries/LibCore/FileStream.h
+++ b/Userland/Libraries/LibCore/FileStream.h
@@ -9,6 +9,7 @@
#include <AK/Buffered.h>
#include <AK/ByteBuffer.h>
#include <AK/Stream.h>
+#include <AK/Try.h>
#include <LibCore/File.h>
namespace Core {
@@ -20,28 +21,18 @@ public:
{
}
- static Result<InputFileStream, OSError> open(StringView filename, OpenMode mode = OpenMode::ReadOnly, mode_t permissions = 0644)
+ static ErrorOr<InputFileStream> open(StringView filename, OpenMode mode = OpenMode::ReadOnly, mode_t permissions = 0644)
{
VERIFY(has_flag(mode, OpenMode::ReadOnly));
-
- auto file_result = File::open(filename, mode, permissions);
-
- if (file_result.is_error())
- return file_result.error();
-
- return InputFileStream { file_result.value() };
+ auto file = TRY(File::open(filename, mode, permissions));
+ return InputFileStream { move(file) };
}
- static Result<Buffered<InputFileStream>, OSError> open_buffered(StringView filename, OpenMode mode = OpenMode::ReadOnly, mode_t permissions = 0644)
+ static ErrorOr<Buffered<InputFileStream>> open_buffered(StringView filename, OpenMode mode = OpenMode::ReadOnly, mode_t permissions = 0644)
{
VERIFY(has_flag(mode, OpenMode::ReadOnly));
-
- auto file_result = File::open(filename, mode, permissions);
-
- if (file_result.is_error())
- return file_result.error();
-
- return Buffered<InputFileStream> { file_result.value() };
+ auto file = TRY(File::open(filename, mode, permissions));
+ return Buffered<InputFileStream> { move(file) };
}
size_t read(Bytes bytes) override
@@ -89,28 +80,18 @@ public:
{
}
- static Result<OutputFileStream, OSError> open(StringView filename, OpenMode mode = OpenMode::WriteOnly, mode_t permissions = 0644)
+ static ErrorOr<OutputFileStream> open(StringView filename, OpenMode mode = OpenMode::WriteOnly, mode_t permissions = 0644)
{
VERIFY(has_flag(mode, OpenMode::WriteOnly));
-
- auto file_result = File::open(filename, mode, permissions);
-
- if (file_result.is_error())
- return file_result.error();
-
- return OutputFileStream { file_result.value() };
+ auto file = TRY(File::open(filename, mode, permissions));
+ return OutputFileStream { move(file) };
}
- static Result<Buffered<OutputFileStream>, OSError> open_buffered(StringView filename, OpenMode mode = OpenMode::WriteOnly, mode_t permissions = 0644)
+ static ErrorOr<Buffered<OutputFileStream>> open_buffered(StringView filename, OpenMode mode = OpenMode::WriteOnly, mode_t permissions = 0644)
{
VERIFY(has_flag(mode, OpenMode::WriteOnly));
-
- auto file_result = File::open(filename, mode, permissions);
-
- if (file_result.is_error())
- return file_result.error();
-
- return Buffered<OutputFileStream> { file_result.value() };
+ auto file = TRY(File::open(filename, mode, permissions));
+ return Buffered<OutputFileStream> { move(file) };
}
static OutputFileStream standard_output()
diff --git a/Userland/Libraries/LibGUI/FileIconProvider.cpp b/Userland/Libraries/LibGUI/FileIconProvider.cpp
index a51dbe6be3..82180adee0 100644
--- a/Userland/Libraries/LibGUI/FileIconProvider.cpp
+++ b/Userland/Libraries/LibGUI/FileIconProvider.cpp
@@ -16,6 +16,7 @@
#include <LibGUI/Painter.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/PNGLoader.h>
+#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
diff --git a/Userland/Libraries/LibGfx/BitmapFont.cpp b/Userland/Libraries/LibGfx/BitmapFont.cpp
index 60ad4b16f0..b97968b013 100644
--- a/Userland/Libraries/LibGfx/BitmapFont.cpp
+++ b/Userland/Libraries/LibGfx/BitmapFont.cpp
@@ -11,6 +11,7 @@
#include <LibCore/FileStream.h>
#include <LibGfx/FontDatabase.h>
#include <LibGfx/FontStyleMapping.h>
+#include <string.h>
namespace Gfx {
diff --git a/Userland/Libraries/LibSQL/Heap.h b/Userland/Libraries/LibSQL/Heap.h
index caef7e8702..b78b486dda 100644
--- a/Userland/Libraries/LibSQL/Heap.h
+++ b/Userland/Libraries/LibSQL/Heap.h
@@ -8,6 +8,7 @@
#include <AK/Debug.h>
#include <AK/HashMap.h>
+#include <AK/Result.h>
#include <AK/String.h>
#include <AK/Vector.h>
#include <LibCore/File.h>
diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp
index 1c2bb06208..e87e674d98 100644
--- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp
+++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp
@@ -177,9 +177,9 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, con
auto file_result = Core::File::open(url.path(), Core::OpenMode::ReadOnly);
if (file_result.is_error()) {
auto& error = file_result.error();
- log_failure(request, error.string());
+ log_failure(request, error);
if (error_callback)
- error_callback(error.string(), error.error());
+ error_callback(String::formatted("{}", error), error.code());
return;
}
diff --git a/Userland/Services/FileOperation/main.cpp b/Userland/Services/FileOperation/main.cpp
index 188d472b1f..5515a3569d 100644
--- a/Userland/Services/FileOperation/main.cpp
+++ b/Userland/Services/FileOperation/main.cpp
@@ -34,7 +34,7 @@ static int perform_delete(Vector<String> const& sources);
static int execute_work_items(Vector<WorkItem> const& items);
static void report_error(String message);
static void report_warning(String message);
-static AK::Result<AK::NonnullRefPtr<Core::File>, AK::OSError> open_destination_file(String const& destination);
+static ErrorOr<NonnullRefPtr<Core::File>> open_destination_file(String const& destination);
static String deduplicate_destination_file_name(String const& destination);
int main(int argc, char** argv)
@@ -379,10 +379,10 @@ int execute_work_items(Vector<WorkItem> const& items)
return 0;
}
-AK::Result<AK::NonnullRefPtr<Core::File>, AK::OSError> open_destination_file(String const& destination)
+ErrorOr<NonnullRefPtr<Core::File>> open_destination_file(String const& destination)
{
auto destination_file_or_error = Core::File::open(destination, (Core::OpenMode)(Core::OpenMode::WriteOnly | Core::OpenMode::Truncate | Core::OpenMode::MustBeNew));
- if (destination_file_or_error.is_error() && destination_file_or_error.error().error() == EEXIST) {
+ if (destination_file_or_error.is_error() && destination_file_or_error.error().code() == EEXIST) {
return open_destination_file(deduplicate_destination_file_name(destination));
}
return destination_file_or_error;
diff --git a/Userland/Services/WindowServer/ScreenLayout.ipp b/Userland/Services/WindowServer/ScreenLayout.ipp
index 04c9f4f87e..877c10db76 100644
--- a/Userland/Services/WindowServer/ScreenLayout.ipp
+++ b/Userland/Services/WindowServer/ScreenLayout.ipp
@@ -9,6 +9,7 @@
#include <Services/WindowServer/ScreenLayout.h>
#include <errno.h>
#include <fcntl.h>
+#include <string.h>
// Must be included after LibIPC/Forward.h
#include <LibIPC/Decoder.h>
diff --git a/Userland/Utilities/arp.cpp b/Userland/Utilities/arp.cpp
index 11837795ed..d19a89140d 100644
--- a/Userland/Utilities/arp.cpp
+++ b/Userland/Utilities/arp.cpp
@@ -16,6 +16,7 @@
#include <net/if_arp.h>
#include <net/route.h>
#include <netinet/in.h>
+#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <unistd.h>
diff --git a/Userland/Utilities/cksum.cpp b/Userland/Utilities/cksum.cpp
index 46250a664c..be7a6d3711 100644
--- a/Userland/Utilities/cksum.cpp
+++ b/Userland/Utilities/cksum.cpp
@@ -8,6 +8,7 @@
#include <LibCore/File.h>
#include <LibCrypto/Checksum/Adler32.h>
#include <LibCrypto/Checksum/CRC32.h>
+#include <string.h>
int main(int argc, char** argv)
{
diff --git a/Userland/Utilities/errno.cpp b/Userland/Utilities/errno.cpp
index a95885914a..7618d4c3e5 100644
--- a/Userland/Utilities/errno.cpp
+++ b/Userland/Utilities/errno.cpp
@@ -5,7 +5,7 @@
*/
#include <LibCore/ArgsParser.h>
-#include <LibCore/File.h>
+#include <string.h>
int main(int argc, char** argv)
{
diff --git a/Userland/Utilities/hexdump.cpp b/Userland/Utilities/hexdump.cpp
index f14eb43a1b..2a8c08aff3 100644
--- a/Userland/Utilities/hexdump.cpp
+++ b/Userland/Utilities/hexdump.cpp
@@ -8,6 +8,7 @@
#include <LibCore/ArgsParser.h>
#include <LibCore/File.h>
#include <ctype.h>
+#include <string.h>
static constexpr size_t LINE_LENGTH_BYTES = 16;
diff --git a/Userland/Utilities/mv.cpp b/Userland/Utilities/mv.cpp
index 29f607d2be..56cc52343e 100644
--- a/Userland/Utilities/mv.cpp
+++ b/Userland/Utilities/mv.cpp
@@ -9,6 +9,7 @@
#include <LibCore/ArgsParser.h>
#include <LibCore/File.h>
#include <stdio.h>
+#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
diff --git a/Userland/Utilities/sql.cpp b/Userland/Utilities/sql.cpp
index d0ae3ab87d..b078b728bd 100644
--- a/Userland/Utilities/sql.cpp
+++ b/Userland/Utilities/sql.cpp
@@ -178,7 +178,7 @@ private:
auto file_name = m_input_file_chain.take_first();
auto file_or_error = Core::File::open(file_name, Core::OpenMode::ReadOnly);
if (file_or_error.is_error()) {
- warnln("Input file {} could not be opened: {}", file_name, file_or_error.error().string());
+ warnln("Input file {} could not be opened: {}", file_name, file_or_error.error());
return {};
}
m_input_file = file_or_error.value();