1 |
/*************************************************************************** |
/*************************************************************************** |
2 |
* * |
* * |
3 |
* libgig - C++ cross-platform Gigasampler format file loader library * |
* libgig - C++ cross-platform Gigasampler format file access library * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003-2005 by Christian Schoenebeck * |
* Copyright (C) 2003-2006 by Christian Schoenebeck * |
6 |
* <cuse@users.sourceforge.net> * |
* <cuse@users.sourceforge.net> * |
7 |
* * |
* * |
8 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
78 |
|
|
79 |
/** Whether file stream is open in read or in read/write mode. */ |
/** Whether file stream is open in read or in read/write mode. */ |
80 |
typedef enum { |
typedef enum { |
81 |
stream_mode_read, |
stream_mode_read = 0, |
82 |
stream_mode_read_write |
stream_mode_read_write = 1, |
83 |
|
stream_mode_closed = 2 |
84 |
} stream_mode_t; |
} stream_mode_t; |
85 |
|
|
86 |
/** Current state of the file stream. */ |
/** Current state of the file stream. */ |
145 |
unsigned long ulStartPos; /* actual position in file where chunk (without header) starts */ |
unsigned long ulStartPos; /* actual position in file where chunk (without header) starts */ |
146 |
unsigned long ulPos; /* # of bytes from ulStartPos */ |
unsigned long ulPos; /* # of bytes from ulStartPos */ |
147 |
uint8_t* pChunkData; |
uint8_t* pChunkData; |
148 |
|
unsigned long ulChunkDataSize; |
149 |
|
|
150 |
Chunk(File* pFile); |
Chunk(File* pFile); |
151 |
Chunk(File* pFile, List* pParent, uint32_t uiChunkID, uint uiBodySize); |
Chunk(File* pFile, List* pParent, uint32_t uiChunkID, uint uiBodySize); |
224 |
void ReadHeader(unsigned long fPos); |
void ReadHeader(unsigned long fPos); |
225 |
void WriteHeader(unsigned long fPos); |
void WriteHeader(unsigned long fPos); |
226 |
void LoadSubChunks(); |
void LoadSubChunks(); |
227 |
|
void LoadSubChunksRecursively(); |
228 |
virtual unsigned long WriteChunk(unsigned long ulWritePos, unsigned long ulCurrentDataOffset); |
virtual unsigned long WriteChunk(unsigned long ulWritePos, unsigned long ulCurrentDataOffset); |
229 |
virtual void __resetPos(); ///< Sets List Chunk's read/write position to zero and causes all sub chunks to do the same. |
virtual void __resetPos(); ///< Sets List Chunk's read/write position to zero and causes all sub chunks to do the same. |
230 |
}; |
}; |
232 |
/** Parses arbitrary RIFF files and provides together with it's base classes convenient methods to walk through the RIFF tree. */ |
/** Parses arbitrary RIFF files and provides together with it's base classes convenient methods to walk through the RIFF tree. */ |
233 |
class File : public List { |
class File : public List { |
234 |
public: |
public: |
235 |
File(); |
File(uint32_t FileType); |
236 |
File(const String& path); |
File(const String& path); |
237 |
stream_mode_t GetMode(); |
stream_mode_t GetMode(); |
238 |
bool SetMode(stream_mode_t NewMode); |
bool SetMode(stream_mode_t NewMode); |
260 |
|
|
261 |
unsigned long GetFileSize(); |
unsigned long GetFileSize(); |
262 |
void ResizeFile(unsigned long ulNewSize); |
void ResizeFile(unsigned long ulNewSize); |
263 |
|
#if POSIX |
264 |
|
unsigned long __GetFileSize(int hFile); |
265 |
|
#else |
266 |
|
unsigned long __GetFileSize(FILE* hFile); |
267 |
|
#endif |
268 |
}; |
}; |
269 |
|
|
270 |
/** Will be thrown whenever an error occurs while parsing a RIFF file. */ |
/** Will be thrown whenever an error occurs while parsing a RIFF file. */ |