17 enum MODE {READ = 1, WRITE = 2, READ_WRITE = 3};
33 bool open(MODE m,
const std::string& file_name =
"");
45 bool read(
unsigned char *targetbuffer,
unsigned long num,
unsigned long *numread=NULL);
48 bool write(
const unsigned char *sourcebuffer,
unsigned long num,
unsigned long *numwrote=NULL);
52 bool read(T& v) {
return read((
unsigned char*)(&v),
sizeof(T)); }
55 bool read_array(T* a,
unsigned int n) {
return read((
unsigned char*)a,
sizeof(T)*n); }
59 bool write(
const T& v) {
return write((
const unsigned char*)(&v),
sizeof(T)); }
62 bool write_array(
const T* a,
unsigned int n) {
return write((
const unsigned char*)a,
sizeof(T)*n); }
65 bool seek(
long long index);
74#include <cgv/config/lib_end.h>
class to handle files with very large sizes (>=2GB) hiding the ugly win32 api calls
bool read_array(T *a, unsigned int n)
read an array of typed values
void close()
close the file
big_binary_file(const std::string &filename="")
assosiates the new instance to the file filename
bool write_array(const T *a, unsigned int n)
write an array of typed values
bool read(T &v)
read a typedef value
long long position()
return the position of the file pointer in bytes
bool open(MODE m, const std::string &file_name="")
open a file in read or write mode
long long size()
return the size of the file in bytes
bool is_open()
return true if the file is opened
bool write(const T &v)
write a typedef value
bool read(unsigned char *targetbuffer, unsigned long num, unsigned long *numread=NULL)
read num bytes from the file into the targetbuffer
virtual ~big_binary_file()
close the file (if it is still opened)
bool write(const unsigned char *sourcebuffer, unsigned long num, unsigned long *numwrote=NULL)
write num bytes to the file from the sourcebuffer (file must be opened with write access first)