28 lines
485 B
C++
28 lines
485 B
C++
#ifndef FILE_H
|
|
#define FILE_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include "Span.h"
|
|
|
|
class File
|
|
{
|
|
public:
|
|
File() : m_fd(-1) {}
|
|
~File() { close(); }
|
|
bool open(const char * filename, bool writing = false);
|
|
void close();
|
|
size_t get_size();
|
|
bool read(uint8_t * buf, size_t size);
|
|
bool write(const uint8_t * buf, size_t size);
|
|
bool write(const Span & span)
|
|
{
|
|
return write(span.start, span.length);
|
|
}
|
|
|
|
protected:
|
|
int m_fd;
|
|
};
|
|
|
|
#endif
|