/[svn]/libgig/trunk/src/RIFF.cpp
ViewVC logotype

Diff of /libgig/trunk/src/RIFF.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1063 by schoenebeck, Sat Mar 3 21:45:25 2007 UTC revision 1095 by schoenebeck, Mon Mar 12 18:16:55 2007 UTC
# Line 70  namespace RIFF { Line 70  namespace RIFF {
70      }      }
71    
72      Chunk::~Chunk() {      Chunk::~Chunk() {
73            if (CurrentChunkSize != NewChunkSize) pFile->UnlogResized(this);
74          if (pChunkData) delete[] pChunkData;          if (pChunkData) delete[] pChunkData;
75      }      }
76    
# Line 1155  namespace RIFF { Line 1156  namespace RIFF {
1156       *       *
1157       * Removes the sub chunk given by \a pSubChunk from this list and frees       * Removes the sub chunk given by \a pSubChunk from this list and frees
1158       * it completely from RAM. The given chunk can either be a normal sub       * it completely from RAM. The given chunk can either be a normal sub
1159       * chunk or a list sub chunk. You should call File::Save() to make this       * chunk or a list sub chunk. In case the given chunk is a list chunk,
1160       * change persistent at any time.       * all its subchunks (if any) will be removed recursively as well. You
1161         * should call File::Save() to make this change persistent at any time.
1162       *       *
1163       * @param pSubChunk - sub chunk or sub list chunk to be removed       * @param pSubChunk - sub chunk or sub list chunk to be removed
1164       */       */
# Line 1514  namespace RIFF { Line 1516  namespace RIFF {
1516          // first we sum up all positive chunk size changes (and skip all negative ones)          // first we sum up all positive chunk size changes (and skip all negative ones)
1517          unsigned long ulPositiveSizeDiff = 0;          unsigned long ulPositiveSizeDiff = 0;
1518          for (ChunkList::iterator iter = ResizedChunks.begin(), end = ResizedChunks.end(); iter != end; ++iter) {          for (ChunkList::iterator iter = ResizedChunks.begin(), end = ResizedChunks.end(); iter != end; ++iter) {
1519              if ((*iter)->GetNewSize() == 0) throw Exception("There is at least one empty chunk (zero size)");              if ((*iter)->GetNewSize() == 0) {
1520                    // just to make the exception message a bit more verbose: resolve the chunk's path
1521                    String sChunkPath;
1522                    for (Chunk* pChunk = *iter; pChunk; pChunk = pChunk->GetParent()) {
1523                        if (pChunk->GetChunkID() == CHUNK_ID_LIST) {
1524                            List* pList = (List*) pChunk;
1525                            sChunkPath = "->'" + pList->GetListTypeString() + "'" + sChunkPath;
1526                        } else {
1527                            sChunkPath = "->'" + pChunk->GetChunkIDString() + "'" + sChunkPath;
1528                        }
1529                    }
1530                    throw Exception("There is at least one empty chunk (zero size): " + sChunkPath);
1531                }
1532              if ((*iter)->GetNewSize() + 1L > (*iter)->GetSize()) {              if ((*iter)->GetNewSize() + 1L > (*iter)->GetSize()) {
1533                  unsigned long ulDiff = (*iter)->GetNewSize() - (*iter)->GetSize() + 1L; // +1 in case we have to add a pad byte                  unsigned long ulDiff = (*iter)->GetNewSize() - (*iter)->GetSize() + 1L; // +1 in case we have to add a pad byte
1534                  ulPositiveSizeDiff += ulDiff;                  ulPositiveSizeDiff += ulDiff;
# Line 1675  namespace RIFF { Line 1689  namespace RIFF {
1689          ResizedChunks.push_back(pResizedChunk);          ResizedChunks.push_back(pResizedChunk);
1690      }      }
1691    
1692        void File::UnlogResized(Chunk* pResizedChunk) {
1693            ResizedChunks.remove(pResizedChunk);
1694        }
1695    
1696      unsigned long File::GetFileSize() {      unsigned long File::GetFileSize() {
1697          return __GetFileSize(hFileRead);          return __GetFileSize(hFileRead);
1698      }      }

Legend:
Removed from v.1063  
changed lines
  Added in v.1095

  ViewVC Help
Powered by ViewVC