2 |
* * |
* * |
3 |
* libgig - C++ cross-platform Gigasampler format file access library * |
* libgig - C++ cross-platform Gigasampler format file access library * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003-2019 by Christian Schoenebeck * |
* Copyright (C) 2003-2021 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 * |
894 |
uint8_t* pNewBuffer = new uint8_t[ullNewChunkSize]; |
uint8_t* pNewBuffer = new uint8_t[ullNewChunkSize]; |
895 |
if (!pNewBuffer) throw Exception("Could not enlarge chunk data buffer to " + ToString(ullNewChunkSize) + " bytes"); |
if (!pNewBuffer) throw Exception("Could not enlarge chunk data buffer to " + ToString(ullNewChunkSize) + " bytes"); |
896 |
memset(pNewBuffer, 0 , ullNewChunkSize); |
memset(pNewBuffer, 0 , ullNewChunkSize); |
897 |
memcpy(pNewBuffer, pChunkData, ullChunkDataSize); |
if (pChunkData) { |
898 |
delete[] pChunkData; |
memcpy(pNewBuffer, pChunkData, ullChunkDataSize); |
899 |
|
delete[] pChunkData; |
900 |
|
} |
901 |
pChunkData = pNewBuffer; |
pChunkData = pNewBuffer; |
902 |
ullChunkDataSize = ullNewChunkSize; |
ullChunkDataSize = ullNewChunkSize; |
903 |
} |
} |
1498 |
while (RemainingBytes() >= CHUNK_HEADER_SIZE(pFile->FileOffsetSize)) { |
while (RemainingBytes() >= CHUNK_HEADER_SIZE(pFile->FileOffsetSize)) { |
1499 |
Chunk* ck; |
Chunk* ck; |
1500 |
uint32_t ckid; |
uint32_t ckid; |
1501 |
Read(&ckid, 4, 1); |
// return value check is required here to prevent a potential |
1502 |
|
// garbage data use of 'ckid' below in case Read() failed |
1503 |
|
if (Read(&ckid, 4, 1) != 4) |
1504 |
|
throw Exception("LoadSubChunks(): Failed reading RIFF chunk ID"); |
1505 |
#if DEBUG_RIFF |
#if DEBUG_RIFF |
1506 |
std::cout << " ckid=" << convertToString(ckid) << std::endl; |
std::cout << " ckid=" << convertToString(ckid) << std::endl; |
1507 |
#endif // DEBUG_RIFF |
#endif // DEBUG_RIFF |
1803 |
* @param NewMode - new file access mode |
* @param NewMode - new file access mode |
1804 |
* @returns true if mode was changed, false if current mode already |
* @returns true if mode was changed, false if current mode already |
1805 |
* equals new mode |
* equals new mode |
1806 |
* @throws RIFF::Exception if new file access mode is unknown |
* @throws RIFF::Exception if file could not be opened in requested file |
1807 |
|
* access mode or if passed access mode is unknown |
1808 |
*/ |
*/ |
1809 |
bool File::SetMode(stream_mode_t NewMode) { |
bool File::SetMode(stream_mode_t NewMode) { |
1810 |
if (NewMode != Mode) { |
if (NewMode != Mode) { |