vcglib/apps/nexus/file.h

59 lines
991 B
C
Raw Normal View History

#ifndef NXS_FILE_H
#define NXS_FILE_H
//TODO move includes in cpp
#ifdef WIN32
2004-11-28 05:12:04 +01:00
#ifndef _WINDOWS_
#define _WINSOCKAPI_
#include <windows.h>
2004-11-28 05:12:04 +01:00
#endif
#else
#include <unistd.h>
#endif
#include <stdio.h>
#include <string>
namespace nxs {
class File {
public:
File(): fp(NULL) {}
~File() { Close(); }
2004-10-21 14:14:02 +02:00
File(const File &file) {
fp = file.fp;
size = file.size;
readonly = file.readonly;
((File &)file).fp = NULL;
2004-10-21 15:40:16 +02:00
}
bool Create(const std::string &filename);
2004-10-08 16:46:26 +02:00
bool Load(const std::string &filename, bool readonly = false);
void Close();
2004-10-08 16:46:26 +02:00
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);
2004-10-08 16:46:26 +02:00
bool IsReadOnly() { return readonly; }
2004-11-18 19:30:15 +01:00
static void Delete(const std::string &filename);
#ifdef WIN32
HANDLE fp;
#else
FILE *fp;
#endif
unsigned int size;
2004-10-08 16:46:26 +02:00
bool readonly;
};
}
#endif