stuff-from-scratch/src/base/core/file_utilities/File.h
2023-12-18 10:16:31 +00:00

53 lines
801 B
C++

#pragma once
#include "FileFormats.h"
#include "FileSystemPath.h"
#include "Optional.h"
#include "String.h"
#include "ByteTypes.h"
#include "Pointer.h"
class FileImpl;
class File
{
public:
enum class AccessMode{
Read,
Write,
ReadWrite
};
public:
File(const FileSystemPath& path);
~File();
void close();
String dumpBinary();
String getExtension() const;
FileFormat::Format inferFormat() const;
String readText();
Vector<String> readLines();
String read();
bool pathExists() const;
bool open(AccessMode mode, bool binary = false);
bool readBinary(VecBytes& bytes);
Optional<Byte> readNextByte();
void writeText(const String& text);
private:
Ptr<FileImpl> m_impl;
FileSystemPath m_path;
};