mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
AK: Add the Input
word to input-only buffered streams
This concerns both `BufferedSeekable` and `BufferedFile`.
This commit is contained in:
parent
48b000a36c
commit
8c34959b53
50 changed files with 101 additions and 102 deletions
|
@ -41,7 +41,7 @@ ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open_for_system(DeprecatedString
|
|||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& filename, AllowWriting allow_altering)
|
||||
{
|
||||
auto maybe_file = File::open(filename, allow_altering == AllowWriting::Yes ? File::OpenMode::ReadWrite : File::OpenMode::Read);
|
||||
OwnPtr<BufferedFile> buffered_file;
|
||||
OwnPtr<InputBufferedFile> 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(BufferedFile::create(maybe_file.release_value()));
|
||||
buffered_file = TRY(InputBufferedFile::create(maybe_file.release_value()));
|
||||
}
|
||||
|
||||
auto config_file = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ConfigFile(filename, move(buffered_file))));
|
||||
|
@ -65,14 +65,14 @@ ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& file
|
|||
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& filename, NonnullOwnPtr<Core::File> file)
|
||||
{
|
||||
auto buffered_file = TRY(BufferedFile::create(move(file)));
|
||||
auto buffered_file = TRY(InputBufferedFile::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<BufferedFile> open_file)
|
||||
ConfigFile::ConfigFile(DeprecatedString const& filename, OwnPtr<InputBufferedFile> open_file)
|
||||
: m_filename(filename)
|
||||
, m_file(move(open_file))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue