mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:47:35 +00:00
LibCore: Add a ConfigFile::open() overload for Core::Stream::File
Core::Stream is already used internally, but ironically you could not open a ConfigFile using one!
This commit is contained in:
parent
678b4983cb
commit
f6884235e2
2 changed files with 6 additions and 0 deletions
|
@ -60,6 +60,11 @@ ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(String const& filename, Allo
|
|||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(String const& filename, int fd)
|
||||
{
|
||||
auto file = TRY(Stream::File::adopt_fd(fd, Stream::OpenMode::ReadWrite));
|
||||
return open(filename, move(file));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(String const& filename, NonnullOwnPtr<Core::Stream::File> file)
|
||||
{
|
||||
auto buffered_file = TRY(Stream::BufferedFile::create(move(file)));
|
||||
|
||||
auto config_file = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ConfigFile(filename, move(buffered_file))));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue