vcglib/apps/nexus/file.h

50 lines
772 B
C++

#ifndef NXS_FILE_H
#define NXS_FILE_H
//TODO move includes in cpp
#ifdef WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
#include <stdio.h>
#include <string>
namespace nxs {
class File {
public:
File(): fp(NULL) {}
~File() { Close(); }
bool Create(const std::string &filename);
bool Load(const std::string &filename, bool readonly = false);
void Close();
unsigned int Length() { return size; }
void Redim(unsigned int elem);
void SetPosition(unsigned int chunk);
void ReadBuffer(void *data, unsigned int size);
void WriteBuffer(void *data, unsigned int size);
bool IsReadOnly() { return readonly; }
protected:
#ifdef WIN32
HANDLE fp;
#else
FILE *fp;
#endif
unsigned int size;
bool readonly;
};
}
#endif