53 lines
801 B
C++
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;
|
|
};
|