ladybird/Libraries/LibCore/CFile.h
Andreas Kling 73fdbba59c AK: Rename <AK/AKString.h> to <AK/String.h>
This was a workaround to be able to build on case-insensitive file
systems where it might get confused about <string.h> vs <String.h>.

Let's just not support building that way, so String.h can have an
objectively nicer name. :^)
2019-09-06 15:36:54 +02:00

30 lines
780 B
C++

#pragma once
#include <AK/String.h>
#include <LibCore/CIODevice.h>
class CFile final : public CIODevice {
C_OBJECT(CFile)
public:
CFile(CObject* parent = nullptr)
: CIODevice(parent)
{
}
explicit CFile(const StringView&, CObject* parent = nullptr);
virtual ~CFile() override;
String filename() const { return m_filename; }
void set_filename(const StringView& filename) { m_filename = filename; }
virtual bool open(CIODevice::OpenMode) override;
enum class ShouldCloseFileDescription {
No = 0,
Yes
};
bool open(int fd, CIODevice::OpenMode, ShouldCloseFileDescription);
private:
String m_filename;
ShouldCloseFileDescription m_should_close_file_descriptor { ShouldCloseFileDescription::Yes };
};