1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 13:37:44 +00:00

LibCore: Add a static Core::File::open() convenience function

This helper opens a file with a given name, mode and permissions and
returns it in a RefPtr<File>. I think this will be a bit nicer to use
than having to go through Core::File::construct() every time.
This commit is contained in:
Andreas Kling 2020-03-30 12:08:25 +02:00
parent ec91d2eb9f
commit 0df15823b5
2 changed files with 18 additions and 1 deletions

View file

@ -36,6 +36,8 @@ class File final : public IODevice {
public:
virtual ~File() override;
static RefPtr<File> open(const String& filename, IODevice::OpenMode, mode_t = 0644);
String filename() const { return m_filename; }
void set_filename(const StringView& filename) { m_filename = filename; }
@ -59,6 +61,8 @@ private:
}
explicit File(const StringView&, Object* parent = nullptr);
bool open_impl(IODevice::OpenMode, mode_t);
String m_filename;
ShouldCloseFileDescription m_should_close_file_descriptor { ShouldCloseFileDescription::Yes };
};