diff options
author | Andreas Kling <kling@serenityos.org> | 2021-08-20 11:16:42 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-20 15:31:46 +0200 |
commit | 13f4890c38c9f7f7d6e936d56de550a36916eec2 (patch) | |
tree | 69d94dc0c75984072623a0da09b7637027d7bcb9 /Userland/Libraries | |
parent | 1474a537b630ef1b6b638164bca9043f0622d617 (diff) | |
download | serenity-13f4890c38c9f7f7d6e936d56de550a36916eec2.zip |
LibCore: Make Core::File::open() return OSError in case of failure
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibCore/File.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibCore/File.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibCore/FileStream.h | 8 |
3 files changed, 9 insertions, 9 deletions
diff --git a/Userland/Libraries/LibCore/File.cpp b/Userland/Libraries/LibCore/File.cpp index 24f707d07c..a1d67291b1 100644 --- a/Userland/Libraries/LibCore/File.cpp +++ b/Userland/Libraries/LibCore/File.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -27,11 +27,11 @@ namespace Core { -Result<NonnullRefPtr<File>, String> File::open(String filename, OpenMode mode, mode_t permissions) +Result<NonnullRefPtr<File>, OSError> File::open(String filename, OpenMode mode, mode_t permissions) { auto file = File::construct(move(filename)); if (!file->open_impl(mode, permissions)) - return String(file->error_string()); + return OSError(file->error()); return file; } diff --git a/Userland/Libraries/LibCore/File.h b/Userland/Libraries/LibCore/File.h index c430d1eade..30be3aa333 100644 --- a/Userland/Libraries/LibCore/File.h +++ b/Userland/Libraries/LibCore/File.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -19,7 +19,7 @@ class File final : public IODevice { public: virtual ~File() override; - static Result<NonnullRefPtr<File>, String> open(String filename, OpenMode, mode_t = 0644); + static Result<NonnullRefPtr<File>, OSError> 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 7d8dd164b7..4069383b37 100644 --- a/Userland/Libraries/LibCore/FileStream.h +++ b/Userland/Libraries/LibCore/FileStream.h @@ -20,7 +20,7 @@ public: { } - static Result<InputFileStream, String> open(StringView filename, OpenMode mode = OpenMode::ReadOnly, mode_t permissions = 0644) + static Result<InputFileStream, OSError> open(StringView filename, OpenMode mode = OpenMode::ReadOnly, mode_t permissions = 0644) { VERIFY(has_flag(mode, OpenMode::ReadOnly)); @@ -32,7 +32,7 @@ public: return InputFileStream { file_result.value() }; } - static Result<Buffered<InputFileStream>, String> open_buffered(StringView filename, OpenMode mode = OpenMode::ReadOnly, mode_t permissions = 0644) + static Result<Buffered<InputFileStream>, OSError> open_buffered(StringView filename, OpenMode mode = OpenMode::ReadOnly, mode_t permissions = 0644) { VERIFY(has_flag(mode, OpenMode::ReadOnly)); @@ -89,7 +89,7 @@ public: { } - static Result<OutputFileStream, String> open(StringView filename, OpenMode mode = OpenMode::WriteOnly, mode_t permissions = 0644) + static Result<OutputFileStream, OSError> open(StringView filename, OpenMode mode = OpenMode::WriteOnly, mode_t permissions = 0644) { VERIFY(has_flag(mode, OpenMode::WriteOnly)); @@ -101,7 +101,7 @@ public: return OutputFileStream { file_result.value() }; } - static Result<Buffered<OutputFileStream>, String> open_buffered(StringView filename, OpenMode mode = OpenMode::WriteOnly, mode_t permissions = 0644) + static Result<Buffered<OutputFileStream>, OSError> open_buffered(StringView filename, OpenMode mode = OpenMode::WriteOnly, mode_t permissions = 0644) { VERIFY(has_flag(mode, OpenMode::WriteOnly)); |