72 Log::error(
"VirtualFile::peek(): the file is closed.\n");
76 long long read_bytes =
read(buffer, byte_count);
78 Log::error(
"VirtualFile::peek() called on a non seek-able VirtualFile.\n");
107 Log::error(
Say(
"VirtualFile::seekSet(%n): invalid offset.\n") << offset);
111 if (offset >
size() )
113 Log::error(
Say(
"VirtualFile::seekSet(%n): invalid offset past end of stream.\n") << offset);
133 data.resize( (
size_t)
size() );
135 return load(&data[0], data.size());
146 long long bytes =
read(buffer,max);
162 read64(&data, little_endian_data);
169 read32(&data, little_endian_data);
175 unsigned long long data = 0;
176 read64(&data, little_endian_data);
183 read64(&data, little_endian_data);
189 unsigned long data = 0;
190 read32(&data, little_endian_data);
197 read32(&data, little_endian_data);
203 unsigned short data = 0;
204 read16(&data, little_endian_data);
211 read16(&data, little_endian_data);
217 unsigned char data = 0;
233 return read64(buffer, count, little_endian_data);
238 return read32(buffer, count, little_endian_data);
243 return read64(buffer, count, little_endian_data);
248 return read64(buffer, count, little_endian_data);
253 return read32(buffer, count, little_endian_data);
258 return read32(buffer, count, little_endian_data);
263 return read16(buffer, count, little_endian_data);
268 return read16(buffer, count, little_endian_data);
273 return read(buffer, count);
278 return read(buffer, count);
285 return write64(&data, little_endian_data);
290 return write32(&data, little_endian_data);
295 return write64(&data, little_endian_data);
300 return write64(&data, little_endian_data);
305 return write32(&data, little_endian_data);
310 return write32(&data, little_endian_data);
315 return write16(&data, little_endian_data);
320 return write16(&data, little_endian_data);
325 return write(&data, 1);
330 return write(&data, 1);
337 return write64(buffer, count, little_endian_data);
342 return write32(buffer, count, little_endian_data);
347 return write64(buffer, count, little_endian_data);
352 return write64(buffer, count, little_endian_data);
357 return write32(buffer, count, little_endian_data);
362 return write32(buffer, count, little_endian_data);
367 return write16(buffer, count, little_endian_data);
372 return write16(buffer, count, little_endian_data);
377 return write(buffer, count);
382 return write(buffer, count);
389 unsigned short bet = 0x00FF;
390 bool little_endian_cpu = ((
unsigned char*)&bet)[0] == 0xFF;
391 if (little_endian_cpu != little_endian_data)
394 for(
long long i=0; i<count; ++i)
395 ret +=
write64( (
char*)buffer+i*8, little_endian_data );
399 return write(buffer, 8*count);
404 unsigned short bet = 0x00FF;
405 bool little_endian_cpu = ((
unsigned char*)&bet)[0] == 0xFF;
406 if (little_endian_cpu != little_endian_data)
409 for(
long long i=0; i<count; ++i)
410 ret +=
write32( (
char*)buffer+i*4, little_endian_data );
414 return write(buffer, 4*count);
419 unsigned short bet = 0x00FF;
420 bool little_endian_cpu = ((
unsigned char*)&bet)[0] == 0xFF;
421 if (little_endian_cpu != little_endian_data)
424 for(
long long i=0; i<count; ++i)
425 ret +=
write16( (
char*)buffer+i*2, little_endian_data );
429 return write(buffer, 2*count);
434 long long ret =
read(buffer, 8*count);
435 unsigned short bet = 0x00FF;
436 bool little_endian_cpu = ((
unsigned char*)&bet)[0] == 0xFF;
437 if ( little_endian_cpu != little_endian_data )
439 char* bytes = (
char*)buffer;
440 for(
int i=0; i<count; ++i, bytes+=8)
443 tmp = bytes[0]; bytes[0] = bytes[7]; bytes[7] = tmp;
444 tmp = bytes[1]; bytes[1] = bytes[6]; bytes[6] = tmp;
445 tmp = bytes[2]; bytes[2] = bytes[5]; bytes[5] = tmp;
446 tmp = bytes[3]; bytes[3] = bytes[4]; bytes[4] = tmp;
454 long long ret =
read(buffer, 4*count);
455 unsigned short bet = 0x00FF;
456 bool little_endian_cpu = ((
unsigned char*)&bet)[0] == 0xFF;
457 if ( little_endian_cpu != little_endian_data )
459 char* bytes = (
char*)buffer;
460 for(
int i=0; i<count; ++i, bytes+=4)
463 tmp = bytes[0]; bytes[0] = bytes[3]; bytes[3] = tmp;
464 tmp = bytes[1]; bytes[1] = bytes[2]; bytes[2] = tmp;
472 long long ret =
read(buffer, 2*count);
473 unsigned short bet = 0x00FF;
474 bool little_endian_cpu = ((
unsigned char*)&bet)[0] == 0xFF;
475 if ( little_endian_cpu != little_endian_data )
477 char* bytes = (
char*)buffer;
478 for(
int i=0; i<count; ++i, bytes+=2)
480 char tmp = bytes[0]; bytes[0] = bytes[1]; bytes[1] = tmp;
488 unsigned short bet = 0x00FF;
489 bool little_endian_cpu = ((
unsigned char*)&bet)[0] == 0xFF;
490 long long dummy = *(
long long*)buffer;
491 char* byte = (
char*)&dummy;
492 if (little_endian_cpu != little_endian_data)
495 tmp = byte[0]; byte[0] = byte[7]; byte[7] = tmp;
496 tmp = byte[1]; byte[1] = byte[6]; byte[6] = tmp;
497 tmp = byte[2]; byte[2] = byte[5]; byte[5] = tmp;
498 tmp = byte[3]; byte[3] = byte[4]; byte[4] = tmp;
500 return write(byte, 8);
505 unsigned short bet = 0x00FF;
506 bool little_endian_cpu = ((
unsigned char*)&bet)[0] == 0xFF;
507 int dummy = *(
int*)buffer;
508 char* byte = (
char*)&dummy;
509 if (little_endian_cpu != little_endian_data)
512 tmp = byte[0]; byte[0] = byte[3]; byte[3] = tmp;
513 tmp = byte[1]; byte[1] = byte[2]; byte[2] = tmp;
515 return write(byte, 4);
520 unsigned short bet = 0x00FF;
521 bool little_endian_cpu = ((
unsigned char*)&bet)[0] == 0xFF;
522 short dummy = *(
short*)buffer;
523 char* byte = (
char*)&dummy;
524 if (little_endian_cpu != little_endian_data)
526 char tmp = byte[0]; byte[0] = byte[1]; byte[1] = tmp;
528 return write(byte, 2);
533 char* bytes = (
char*)buffer;
534 long long ret =
read(bytes, 8);
535 unsigned short bet = 0x00FF;
536 bool little_endian_cpu = ((
unsigned char*)&bet)[0] == 0xFF;
537 if ( little_endian_cpu != little_endian_data )
540 tmp = bytes[0]; bytes[0] = bytes[7]; bytes[7] = tmp;
541 tmp = bytes[1]; bytes[1] = bytes[6]; bytes[6] = tmp;
542 tmp = bytes[2]; bytes[2] = bytes[5]; bytes[5] = tmp;
543 tmp = bytes[3]; bytes[3] = bytes[4]; bytes[4] = tmp;
550 char* bytes = (
char*)buffer;
551 long long ret =
read(bytes, 4);
552 unsigned short bet = 0x00FF;
553 bool little_endian_cpu = ((
unsigned char*)&bet)[0] == 0xFF;
554 if ( little_endian_cpu != little_endian_data )
557 tmp = bytes[0]; bytes[0] = bytes[3]; bytes[3] = tmp;
558 tmp = bytes[1]; bytes[1] = bytes[2]; bytes[2] = tmp;
565 char* bytes = (
char*)buffer;
566 long long ret =
read(bytes, 2);
567 unsigned short bet = 0x00FF;
568 bool little_endian_cpu = ((
unsigned char*)&bet)[0] == 0xFF;
569 if ( little_endian_cpu != little_endian_data )
571 char tmp = bytes[0]; bytes[0] = bytes[1]; bytes[1] = tmp;
long long read(void *buffer, long long byte_count)
Reads byte_count bytes from a file. Returns the number of bytes actually read.
VLCORE_EXPORT FileSystem * defFileSystem()
Returns the default FileSystem used by VisualizationLibrary.
unsigned int compute(const void *buf, int length)
MD5CheckSum md5()
Computes the md5 of the entire file.
Computes the a CRC32 checksum of a given buffer or VirtualFile.
long long writeDouble(double data, bool little_endian_data=true)
Writes a single entry. Returns the number of bytes written.
long long writeUInt16(unsigned short data, bool little_endian_data=true)
Writes a single entry. Returns the number of bytes written.
A simple String formatting class.
void compute(void *buffer, int len)
long long read32(void *buffer, long long count, bool little_endian_data=true)
long long write16(const void *buffer, long long count, bool little_endian_data=true)
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
long long read16(void *buffer, long long count, bool little_endian_data=true)
int readSInt32(bool little_endian_data=true)
Reads single entry.
virtual bool isOpen() const =0
Returns true if the file has been opened.
virtual long long write_Implementation(const void *buffer, long long byte_count)=0
bool seekCur(long long offset)
Changes the current read/write position of a file.
long long writeSInt16(short data, bool little_endian_data=true)
Writes a single entry. Returns the number of bytes written.
long long writeUInt8(unsigned char data)
Writes a single entry. Returns the number of bytes written.
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
virtual long long position_Implementation() const =0
virtual ref< VirtualFile > locateFile(const String &full_path, const String &alternate_path=String()) const
Looks for a VirtualFile on the disk and in the currently active FileSystem.
long long writeUInt64(unsigned long long data, bool little_endian_data=true)
Writes a single entry. Returns the number of bytes written.
short readSInt16(bool little_endian_data=true)
Reads single entry.
long long writeSInt64(long long data, bool little_endian_data=true)
Writes a single entry. Returns the number of bytes written.
long long writeFloat(float data, bool little_endian_data=true)
Writes a single entry. Returns the number of bytes written.
long long readSInt64(bool little_endian_data=true)
Reads single entry.
unsigned long long readUInt64(bool little_endian_data=true)
Reads single entry.
float readFloat(bool little_endian_data=true)
Reads single entry.
virtual void close()=0
Closes the file.
long long writeSInt8(char data)
Writes a single entry. Returns the number of bytes written.
long long writeUInt32(unsigned int data, bool little_endian_data=true)
Writes a single entry. Returns the number of bytes written.
const String & path() const
Returns the path of the file.
Visualization Library main namespace.
long long writeSInt32(int data, bool little_endian_data=true)
Writes a single entry. Returns the number of bytes written.
long long read64(void *buffer, long long count, bool little_endian_data=true)
long long write64(const void *buffer, long long count, bool little_endian_data=true)
unsigned int crc32()
Computes the crc32 of the entire file.
float max(float a, float b)
unsigned char readUInt8()
Reads single entry.
long long write(const void *buffer, long long byte_count)
Writes byte_count bytes to a file. Returns the number of bytes actually written.
virtual bool open(EOpenMode mode)=0
Opens the file in the specified mode.
virtual bool seekSet_Implementation(long long offset)=0
bool seekSet(long long offset)
Changes the current read/write position of a file.
virtual long long size() const =0
Returns the size of the file in bytes.
Computes the MD5 of a given buffer or VirtualFile.
VLCORE_EXPORT ref< VirtualFile > locateFile(const String &path)
Utility function, equivalent to vl::defFileSystem()->locateFile(path)
unsigned short readUInt16(bool little_endian_data=true)
Reads single entry.
virtual long long read_Implementation(void *buffer, long long byte_count)=0
long long peek(void *buffer, long long byte_count)
Reads byte_count bytes and returns to the original position.
char readSInt8()
Reads single entry.
unsigned int readUInt32(bool little_endian_data=true)
Reads single entry.
The ref<> class is used to reference-count an Object.
bool seekEnd(long long offset)
Changes the current read/write position of a file.
long long load(std::vector< char > &data)
Loads the entire file in the specified vector.
long long position() const
Returns the current position in the file.
long long write32(const void *buffer, long long count, bool little_endian_data=true)
double readDouble(bool little_endian_data=true)
Reads single entry.