42 static String __resolveChunkPath(Chunk* pCk) {
44 for (Chunk* pChunk = pCk; pChunk; pChunk = pChunk->GetParent()) {
46 List* pList = (List*) pChunk;
47 sPath =
"->'" + pList->GetListTypeString() +
"'" + sPath;
49 sPath =
"->'" + pChunk->GetChunkIDString() +
"'" + sPath;
74 std::cout <<
"Chunk::Chunk(File* pFile)" << std::endl;
88 std::cout <<
"Chunk::Chunk(File*,ulong,bool,List*),StartPos=" << StartPos << std::endl;
120 std::cout <<
"Chunk::Readheader(" << fPos <<
") ";
129 if (SetFilePointer(
pFile->
hFileRead, fPos, NULL, FILE_BEGIN) != INVALID_SET_FILE_POINTER) {
142 #else // little endian 147 #endif // WORDS_BIGENDIAN 162 uint32_t uiNewChunkID =
ChunkID;
166 #else // little endian 168 #endif // WORDS_BIGENDIAN 182 if (SetFilePointer(
pFile->
hFileWrite, fPos, NULL, FILE_BEGIN) != INVALID_SET_FILE_POINTER) {
183 DWORD dwBytesWritten;
185 WriteFile(
pFile->
hFileWrite, &uiNewChunkSize, 4, &dwBytesWritten, NULL);
217 std::cout <<
"Chunk::SetPos(ulong)" << std::endl;
267 std::cout <<
"Chunk::GetState()" << std::endl;
271 #elif defined (WIN32) 296 unsigned long Chunk::Read(
void* pData,
unsigned long WordCount,
unsigned long WordSize) {
298 std::cout <<
"Chunk::Read(void*,ulong,ulong)" << std::endl;
305 ssize_t readWords = read(
pFile->
hFileRead, pData, WordCount * WordSize);
308 std::cerr <<
"POSIX read() failed: " << strerror(errno) << std::endl << std::flush;
312 readWords /= WordSize;
316 ReadFile(
pFile->
hFileRead, pData, WordCount * WordSize, &readWords, NULL);
317 if (readWords < 1)
return 0;
318 readWords /= WordSize;
319 #else // standard C functions 321 size_t readWords = fread(pData, WordSize, WordCount,
pFile->
hFileRead);
326 for (
unsigned long iWord = 0; iWord < readWords; iWord++)
330 for (
unsigned long iWord = 0; iWord < readWords; iWord++)
334 for (
unsigned long iWord = 0; iWord < readWords; iWord++)
335 swapBytes((uint8_t*) pData + iWord * WordSize, WordSize);
359 unsigned long Chunk::Write(
void* pData,
unsigned long WordCount,
unsigned long WordSize) {
361 throw Exception(
"Cannot write data to chunk, file has to be opened in read+write mode first");
363 throw Exception(
"End of chunk reached while trying to write data");
367 for (
unsigned long iWord = 0; iWord < WordCount; iWord++)
371 for (
unsigned long iWord = 0; iWord < WordCount; iWord++)
375 for (
unsigned long iWord = 0; iWord < WordCount; iWord++)
376 swapBytes((uint8_t*) pData + iWord * WordSize, WordSize);
385 unsigned long writtenWords = write(
pFile->
hFileWrite, pData, WordCount * WordSize);
386 if (writtenWords < 1)
throw Exception(
"POSIX IO Error while trying to write chunk data");
387 writtenWords /= WordSize;
394 WriteFile(
pFile->
hFileWrite, pData, WordCount * WordSize, &writtenWords, NULL);
395 if (writtenWords < 1)
throw Exception(
"Windows IO Error while trying to write chunk data");
396 writtenWords /= WordSize;
397 #else // standard C functions 402 unsigned long writtenWords = fwrite(pData, WordSize, WordCount,
pFile->
hFileWrite);
410 unsigned long readWords =
Read(pData, WordCount, WordSize);
411 if (readWords != WordCount)
throw RIFF::Exception(
"End of chunk data reached.");
428 std::cout <<
"Chunk::ReadInt8(int8_t*,ulong)" << std::endl;
448 return Write(pData, WordCount, 1);
465 std::cout <<
"Chunk::ReadUint8(uint8_t*,ulong)" << std::endl;
485 return Write(pData, WordCount, 1);
502 std::cout <<
"Chunk::ReadInt16(int16_t*,ulong)" << std::endl;
522 return Write(pData, WordCount, 2);
539 std::cout <<
"Chunk::ReadUint16(uint16_t*,ulong)" << std::endl;
559 return Write(pData, WordCount, 2);
576 std::cout <<
"Chunk::ReadInt32(int32_t*,ulong)" << std::endl;
596 return Write(pData, WordCount, 4);
613 std::cout <<
"Chunk::ReadUint32(uint32_t*,ulong)" << std::endl;
629 char* buf =
new char[size];
631 s.assign(buf, std::find(buf, buf + size,
'\0'));
650 return Write(pData, WordCount, 4);
662 std::cout <<
"Chunk::ReadInt8()" << std::endl;
678 std::cout <<
"Chunk::ReadUint8()" << std::endl;
695 std::cout <<
"Chunk::ReadInt16()" << std::endl;
712 std::cout <<
"Chunk::ReadUint16()" << std::endl;
729 std::cout <<
"Chunk::ReadInt32()" << std::endl;
746 std::cout <<
"Chunk::ReadUint32()" << std::endl;
802 if (!pNewBuffer)
throw Exception(
"Could not enlarge chunk data buffer to " + ToString(
NewChunkSize) +
" bytes");
845 throw Exception(
"There is at least one empty chunk (zero size): " + __resolveChunkPath(
this));
865 const unsigned long ulOriginalPos = ulWritePos;
869 throw Exception(
"Cannot write list chunk, file has to be opened in read+write mode");
879 throw Exception(
"Writing Chunk data (from RAM) failed");
883 DWORD dwBytesWritten;
886 throw Exception(
"Writing Chunk data (from RAM) failed");
891 throw Exception(
"Writing Chunk data (from RAM) failed");
896 int8_t* pCopyBuffer =
new int8_t[4096];
899 DWORD iBytesMoved = 1;
903 for (
unsigned long ulOffset = 0; ulToMove > 0 && iBytesMoved > 0; ulOffset += iBytesMoved, ulToMove -= iBytesMoved) {
904 iBytesMoved = (ulToMove < 4096) ? ulToMove : 4096;
912 ReadFile(
pFile->
hFileRead, pCopyBuffer, iBytesMoved, &iBytesMoved, NULL);
913 SetFilePointer(
pFile->
hFileWrite, ulWritePos + ulOffset, NULL, FILE_BEGIN);
914 WriteFile(
pFile->
hFileWrite, pCopyBuffer, iBytesMoved, &iBytesMoved, NULL);
917 iBytesMoved = fread(pCopyBuffer, 1, iBytesMoved,
pFile->
hFileRead);
922 delete[] pCopyBuffer;
923 if (iBytesMoved < 0)
throw Exception(
"Writing Chunk data (from file) failed");
930 __notify_progress(pProgress, 1.0);
938 const char cPadByte = 0;
944 DWORD dwBytesWritten;
967 std::cout <<
"List::List(File* pFile)" << std::endl;
974 :
Chunk(pFile, StartPos, Parent) {
976 std::cout <<
"List::List(File*,ulong,bool,List*)" << std::endl;
993 std::cout <<
"List::~List()" << std::endl;
1000 ChunkList::iterator iter =
pSubChunks->begin();
1002 while (iter != end) {
1028 std::cout <<
"List::GetSubChunk(uint32_t)" << std::endl;
1047 std::cout <<
"List::GetSubList(uint32_t)" << std::endl;
1050 ChunkList::iterator iter =
pSubChunks->begin();
1052 while (iter != end) {
1072 std::cout <<
"List::GetFirstSubChunk()" << std::endl;
1088 std::cout <<
"List::GetNextSubChunk()" << std::endl;
1106 std::cout <<
"List::GetFirstSubList()" << std::endl;
1128 std::cout <<
"List::GetNextSubList()" << std::endl;
1154 unsigned int result = 0;
1156 ChunkList::iterator iter =
pSubChunks->begin();
1158 while (iter != end) {
1159 if ((*iter)->GetChunkID() ==
ChunkID) {
1179 unsigned int result = 0;
1181 ChunkList::iterator iter =
pSubChunks->begin();
1183 while (iter != end) {
1207 if (uiBodySize == 0)
throw Exception(
"Chunk body size must be at least 1 byte");
1211 (*pSubChunksMap)[uiChunkID] = pNewChunk;
1212 pNewChunk->
Resize(uiBodySize);
1245 if (pNewParent ==
this || !pNewParent)
return;
1254 ChunkList::iterator iter =
pSubChunks->begin();
1256 for (; iter != end; ++iter) {
1257 if ((*iter)->GetChunkID() == pSrc->
GetChunkID()) {
1258 (*pSubChunksMap)[pSrc->
GetChunkID()] = *iter;
1284 return pNewListChunk;
1303 ChunkList::iterator iter =
pSubChunks->begin();
1305 for (; iter != end; ++iter) {
1306 if ((*iter)->GetChunkID() == pSubChunk->
GetChunkID()) {
1307 (*pSubChunksMap)[pSubChunk->
GetChunkID()] = *iter;
1317 std::cout <<
"List::Readheader(ulong) ";
1325 #elif defined(WIN32) 1349 #elif defined(WIN32) 1351 DWORD dwBytesWritten;
1361 std::cout <<
"List::LoadSubChunks()";
1371 unsigned long uiOriginalPos =
GetPos();
1389 (*pSubChunksMap)[ckid] = ck;
1394 __notify_progress(pProgress, 1.0);
1403 __divide_progress(pProgress, &subprogress, n, i);
1405 pList->LoadSubChunksRecursively(&subprogress);
1407 __notify_progress(pProgress, 1.0);
1426 const unsigned long ulOriginalPos = ulWritePos;
1430 throw Exception(
"Cannot write list chunk, file has to be opened in read+write mode");
1436 for (ChunkList::iterator iter =
pSubChunks->begin(), end =
pSubChunks->end(); iter != end; ++iter, ++i) {
1439 __divide_progress(pProgress, &subprogress, n, i);
1441 ulWritePos = (*iter)->WriteChunk(ulWritePos, ulCurrentDataOffset, &subprogress);
1452 __notify_progress(pProgress, 1.0);
1460 for (ChunkList::iterator iter =
pSubChunks->begin(), end =
pSubChunks->end(); iter != end; ++iter) {
1461 (*iter)->__resetPos();
1518 std::cout <<
"File::File("<<path<<
")" << std::endl;
1522 __openExistingFile(path);
1559 :
List(this), Filename(path), bIsNewFile(false), Layout(layout)
1563 __openExistingFile(path, &FileType);
1581 void File::__openExistingFile(
const String& path, uint32_t* FileType) {
1582 ResizedChunks.clear();
1587 String sError = strerror(errno);
1590 #elif defined(WIN32) 1592 path.c_str(), GENERIC_READ,
1593 FILE_SHARE_READ | FILE_SHARE_WRITE,
1594 NULL, OPEN_EXISTING,
1595 FILE_ATTRIBUTE_NORMAL |
1596 FILE_FLAG_RANDOM_ACCESS, NULL
1598 if (
hFileRead == INVALID_HANDLE_VALUE) {
1611 if (FileType &&
ChunkID != *FileType)
1619 if (
Read(&ckid, 4, 1) != 4) {
1620 throw RIFF::Exception(
"Invalid file header ID (premature end of header)");
1621 }
else if (ckid != *FileType) {
1659 if (NewMode != Mode) {
1667 String sError = strerror(errno);
1668 throw Exception(
"Could not (re)open file \"" +
Filename +
"\" in read mode: " + sError);
1670 #elif defined(WIN32) 1674 FILE_SHARE_READ | FILE_SHARE_WRITE,
1675 NULL, OPEN_EXISTING,
1676 FILE_ATTRIBUTE_NORMAL |
1677 FILE_FLAG_RANDOM_ACCESS,
1680 if (
hFileRead == INVALID_HANDLE_VALUE) {
1697 String sError = strerror(errno);
1698 throw Exception(
"Could not open file \"" +
Filename +
"\" in read+write mode: " + sError);
1700 #elif defined(WIN32) 1704 GENERIC_READ | GENERIC_WRITE,
1707 FILE_ATTRIBUTE_NORMAL |
1708 FILE_FLAG_RANDOM_ACCESS,
1711 if (
hFileRead == INVALID_HANDLE_VALUE) {
1714 FILE_SHARE_READ | FILE_SHARE_WRITE,
1715 NULL, OPEN_EXISTING,
1716 FILE_ATTRIBUTE_NORMAL |
1717 FILE_FLAG_RANDOM_ACCESS,
1720 throw Exception(
"Could not (re)open file \"" +
Filename +
"\" in read+write mode");
1736 #elif defined(WIN32) 1746 throw Exception(
"Unknown file access mode");
1785 throw Exception(
"Saving a RIFF file with layout_flat is not implemented yet");
1791 __divide_progress(pProgress, &subprogress, 3.f, 0.f);
1795 __notify_progress(&subprogress, 1.f);
1809 unsigned long ulPositiveSizeDiff = 0;
1810 for (std::set<Chunk*>::const_iterator iter = ResizedChunks.begin(), end = ResizedChunks.end(); iter != end; ++iter) {
1811 if ((*iter)->GetNewSize() == 0) {
1812 throw Exception(
"There is at least one empty chunk (zero size): " + __resolveChunkPath(*iter));
1814 unsigned long newSizePadded = (*iter)->GetNewSize() + (*iter)->GetNewSize() % 2;
1815 unsigned long oldSizePadded = (*iter)->GetSize() + (*iter)->GetSize() % 2;
1816 if (newSizePadded > oldSizePadded) ulPositiveSizeDiff += newSizePadded - oldSizePadded;
1819 unsigned long ulWorkingFileSize = GetFileSize();
1822 if (ulPositiveSizeDiff > 0) {
1825 __divide_progress(pProgress, &subprogress, 3.f, 1.f);
1828 ulWorkingFileSize += ulPositiveSizeDiff;
1829 ResizeFile(ulWorkingFileSize);
1831 int8_t* pCopyBuffer =
new int8_t[4096];
1834 DWORD iBytesMoved = 1;
1836 int iBytesMoved = 1;
1838 for (
unsigned long ulPos = ulFileSize, iNotif = 0; iBytesMoved > 0; ++iNotif) {
1840 ulPos -= iBytesMoved;
1843 iBytesMoved = read(
hFileRead, pCopyBuffer, iBytesMoved);
1845 iBytesMoved = write(
hFileWrite, pCopyBuffer, iBytesMoved);
1846 #elif defined(WIN32) 1848 ReadFile(
hFileRead, pCopyBuffer, iBytesMoved, &iBytesMoved, NULL);
1849 SetFilePointer(
hFileWrite,
ulPos + ulPositiveSizeDiff, NULL, FILE_BEGIN);
1850 WriteFile(
hFileWrite, pCopyBuffer, iBytesMoved, &iBytesMoved, NULL);
1853 iBytesMoved = fread(pCopyBuffer, 1, iBytesMoved,
hFileRead);
1855 iBytesMoved = fwrite(pCopyBuffer, 1, iBytesMoved,
hFileWrite);
1857 if (!(iNotif % 8) && iBytesMoved > 0)
1858 __notify_progress(&subprogress,
float(ulFileSize -
ulPos) /
float(ulFileSize));
1860 delete[] pCopyBuffer;
1861 if (iBytesMoved < 0)
throw Exception(
"Could not modify file while trying to enlarge it");
1863 __notify_progress(&subprogress, 1.f);
1870 __divide_progress(pProgress, &subprogress, 3.f, 2.f);
1872 unsigned long ulTotalSize =
WriteChunk(0, ulPositiveSizeDiff, &subprogress);
1873 unsigned long ulActualSize = __GetFileSize(
hFileWrite);
1875 __notify_progress(&subprogress, 1.f);
1878 if (ulTotalSize < ulActualSize) ResizeFile(ulTotalSize);
1881 ResizedChunks.clear();
1883 __notify_progress(pProgress, 1.0);
1905 throw Exception(
"Saving a RIFF file with layout_flat is not implemented yet");
1911 __divide_progress(pProgress, &subprogress, 2.f, 0.f);
1915 __notify_progress(&subprogress, 1.f);
1921 hFileWrite = open(path.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP);
1924 String sError = strerror(errno);
1925 throw Exception(
"Could not open file \"" + path +
"\" for writing: " + sError);
1927 #elif defined(WIN32) 1929 path.c_str(), GENERIC_WRITE, FILE_SHARE_READ,
1930 NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL |
1931 FILE_FLAG_RANDOM_ACCESS, NULL
1935 throw Exception(
"Could not open file \"" + path +
"\" for writing");
1941 throw Exception(
"Could not open file \"" + path +
"\" for writing");
1947 unsigned long ulTotalSize;
1951 __divide_progress(pProgress, &subprogress, 2.f, 1.f);
1953 ulTotalSize =
WriteChunk(0, 0, &subprogress);
1955 __notify_progress(&subprogress, 1.f);
1957 unsigned long ulActualSize = __GetFileSize(
hFileWrite);
1960 if (ulTotalSize < ulActualSize) ResizeFile(ulTotalSize);
1963 ResizedChunks.clear();
1967 #elif defined(WIN32) 1980 __notify_progress(pProgress, 1.0);
1983 void File::ResizeFile(
unsigned long ulNewSize) {
1987 #elif defined(WIN32) 1989 SetFilePointer(
hFileWrite, ulNewSize, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER ||
1993 # error Sorry, this version of libgig only supports POSIX and Windows systems yet. 1994 # error Reason: portable implementation of RIFF::File::ResizeFile() is missing (yet)! 2000 std::cout <<
"File::~File()" << std::endl;
2013 void File::Cleanup() {
2016 #elif defined(WIN32) 2023 ResizedChunks.clear();
2027 ResizedChunks.insert(pResizedChunk);
2031 ResizedChunks.erase(pResizedChunk);
2034 unsigned long File::GetFileSize() {
2039 unsigned long File::__GetFileSize(
int hFile) {
2040 struct stat filestat;
2041 fstat(hFile, &filestat);
2042 long size = filestat.st_size;
2045 #elif defined(WIN32) 2046 unsigned long File::__GetFileSize(HANDLE hFile) {
2047 DWORD dwSize = ::GetFileSize(hFile, NULL );
2048 if (dwSize == INVALID_FILE_SIZE)
2049 throw Exception(
"Windows FS error: could not determine file size");
2052 #else // standard C functions 2053 unsigned long File::__GetFileSize(FILE* hFile) {
2054 long curpos = ftell(hFile);
2055 fseek(hFile, 0, SEEK_END);
2056 long size = ftell(hFile);
2057 fseek(hFile, curpos, SEEK_SET);
2067 std::cout <<
"RIFF::Exception: " <<
Message << std::endl;
bool IsNew() const
Returns true if this file has been created new from scratch and has not been stored to disk yet...
unsigned long WriteUint32(uint32_t *pData, unsigned long WordCount=1)
Writes WordCount number of 32 Bit unsigned integer words from the buffer pointed by pData to the chun...
int16_t ReadInt16()
Reads one 16 Bit signed integer word and increments the position within the chunk.
void UnlogResized(Chunk *pResizedChunk)
void swapBytes_16(void *Word)
stream_whence_t
File stream position dependent to these relations.
unsigned long Read(void *pData, unsigned long WordCount, unsigned long WordSize)
Reads WordCount number of data words with given WordSize and copies it into a buffer pointed by pData...
Chunk * GetFirstSubChunk()
Returns the first subchunk within the list.
String libraryName()
Returns the name of this C++ library.
virtual unsigned long WriteChunk(unsigned long ulWritePos, unsigned long ulCurrentDataOffset, progress_t *pProgress=NULL)
Write list chunk persistently e.g.
File(uint32_t FileType)
Create new RIFF file.
unsigned long WriteUint16(uint16_t *pData, unsigned long WordCount=1)
Writes WordCount number of 16 Bit unsigned integer words from the buffer pointed by pData to the chun...
uint32_t GetChunkID()
Chunk ID in unsigned integer representation.
layout_t Layout
An ordinary RIFF file is always set to layout_standard.
void(* callback)(progress_t *)
Callback function pointer which has to be assigned to a function for progress notification.
void ReadHeader(unsigned long fPos)
void swapBytes(void *Word, unsigned long WordSize)
stream_state_t
Current state of the file stream.
unsigned long SetPos(unsigned long Where, stream_whence_t Whence=stream_start)
Sets the position within the chunk body, thus within the data portion of the chunk (in bytes)...
void ReadString(String &s, int size)
Reads a null-padded string of size characters and copies it into the string s.
void WriteHeader(unsigned long fPos)
String libraryVersion()
Returns version of this C++ library.
List * GetSubList(uint32_t ListType)
Returns sublist chunk with list type ListType within this chunk list.
void DeleteSubChunk(Chunk *pSubChunk)
Removes a sub chunk.
unsigned long WriteInt16(int16_t *pData, unsigned long WordCount=1)
Writes WordCount number of 16 Bit signed integer words from the buffer pointed by pData to the chunk'...
#define CHUNK_HEADER_SIZE
int hFileWrite
handle / descriptor for writing to (some) file
unsigned long RemainingBytes()
Returns the number of bytes left to read in the chunk body.
List * GetFirstSubList()
Returns the first sublist within the list (that is a subchunk with chunk ID "LIST").
stream_mode_t
Whether file stream is open in read or in read/write mode.
std::list< Chunk * > ChunkList
unsigned long GetPos()
Position within the chunk data body.
void SetByteOrder(endian_t Endian)
Set the byte order to be used when saving.
int8_t ReadInt8()
Reads one 8 Bit signed integer word and increments the position within the chunk. ...
void ReadHeader(unsigned long fPos)
String GetListTypeString()
Returns string representation of the lists's id.
ChunkList::iterator ListIterator
float __range_min
Only for internal usage, do not modify!
unsigned long WriteInt32(int32_t *pData, unsigned long WordCount=1)
Writes WordCount number of 32 Bit signed integer words from the buffer pointed by pData to the chunk'...
Chunk * GetSubChunk(uint32_t ChunkID)
Returns subchunk with chunk ID ChunkID within this chunk list.
Chunk * GetNextSubChunk()
Returns the next subchunk within the list.
unsigned long ReadSceptical(void *pData, unsigned long WordCount, unsigned long WordSize)
Just an internal wrapper for the main Read() method with additional Exception throwing on errors...
int32_t ReadInt32()
Reads one 32 Bit signed integer word and increments the position within the chunk.
virtual void Save(progress_t *pProgress=NULL)
Save changes to same file.
layout_t
General chunk structure of a file.
stream_state_t GetState()
Returns the current state of the chunk object.
uint32_t GetListType()
Returns unsigned integer representation of the list's ID.
uint32_t ReadUint32()
Reads one 32 Bit unsigned integer word and increments the position within the chunk.
ChunkList::iterator ChunksIterator
void * custom
This pointer can be used for arbitrary data.
unsigned long Write(void *pData, unsigned long WordCount, unsigned long WordSize)
Writes WordCount number of data words with given WordSize from the buffer pointed by pData...
Used for indicating the progress of a certain task.
virtual unsigned long WriteChunk(unsigned long ulWritePos, unsigned long ulCurrentDataOffset, progress_t *pProgress=NULL)
Write chunk persistently e.g.
void swapBytes_32(void *Word)
Chunk * AddSubChunk(uint32_t uiChunkID, uint uiBodySize)
Creates a new sub chunk.
int hFileRead
handle / descriptor for reading from file
Not a "real" RIFF file: First chunk in file is an ordinary data chunk, not a List chunk...
void LogAsResized(Chunk *pResizedChunk)
virtual void __resetPos()
Sets Chunk's read/write position to zero.
uint16_t ReadUint16()
Reads one 16 Bit unsigned integer word and increments the position within the chunk.
virtual void __resetPos()
Sets List Chunk's read/write position to zero and causes all sub chunks to do the same...
uint32_t CurrentChunkSize
endian_t
Alignment of data bytes in memory (system dependant).
void SetFileName(const String &path)
void * LoadChunkData()
Load chunk body into RAM.
unsigned long WriteInt8(int8_t *pData, unsigned long WordCount=1)
Writes WordCount number of 8 Bit signed integer words from the buffer pointed by pData to the chunk's...
void LoadSubChunksRecursively(progress_t *pProgress=NULL)
Standard RIFF file layout: First chunk in file is a List chunk which contains all other chunks and th...
unsigned long ulChunkDataSize
layout_t GetLayout() const
List * AddSubList(uint32_t uiListType)
Creates a new list sub chunk.
RIFF specific classes and definitions.
unsigned long GetSize() const
Chunk size in bytes (without header, thus the chunk data body)
List(File *pFile, unsigned long StartPos, List *Parent)
void MoveSubChunk(Chunk *pSrc, Chunk *pDst)
Moves a sub chunk witin this list.
unsigned int CountSubChunks()
Returns number of subchunks within the list.
String convertToString(uint32_t word)
bool SetMode(stream_mode_t NewMode)
Change file access mode.
float __range_max
Only for internal usage, do not modify!
Will be thrown whenever an error occurs while handling a RIFF file.
unsigned long WriteUint8(uint8_t *pData, unsigned long WordCount=1)
Writes WordCount number of 8 Bit unsigned integer words from the buffer pointed by pData to the chunk...
void LoadSubChunks(progress_t *pProgress=NULL)
void ReleaseChunkData()
Free loaded chunk body from RAM.
unsigned int CountSubLists()
Returns number of sublists within the list.
String GetChunkIDString()
Returns the String representation of the chunk's ID (e.g.
void WriteHeader(unsigned long fPos)
std::map< uint32_t, RIFF::Chunk * > ChunkMap
void Resize(int iNewSize)
Resize chunk.
List * GetNextSubList()
Returns the next sublist (that is a subchunk with chunk ID "LIST") within the list.
Chunk(File *pFile, unsigned long StartPos, List *Parent)
uint8_t ReadUint8()
Reads one 8 Bit unsigned integer word and increments the position within the chunk.