/[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 1102 by persson, Sun Mar 18 07:13:06 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 1134  namespace RIFF { Line 1135  namespace RIFF {
1135          return pNewChunk;          return pNewChunk;
1136      }      }
1137    
1138        /** @brief Moves a sub chunk.
1139         *
1140         * Moves a sub chunk from one position in a list to another
1141         * position in the same list. The pSrc chunk is placed before the
1142         * pDst chunk.
1143         *
1144         * @param pSrc - sub chunk to be moved
1145         * @param pDst - the position to move to. pSrc will be placed
1146         *               before pDst. If pDst is 0, pSrc will be placed
1147         *               last in list.
1148         */
1149        void List::MoveSubChunk(Chunk* pSrc, Chunk* pDst) {
1150            if (!pSubChunks) LoadSubChunks();
1151            pSubChunks->remove(pSrc);
1152            ChunkList::iterator iter = find(pSubChunks->begin(), pSubChunks->end(), pDst);
1153            pSubChunks->insert(iter, pSrc);
1154        }
1155    
1156      /** @brief Creates a new list sub chunk.      /** @brief Creates a new list sub chunk.
1157       *       *
1158       * Creates and adds a new list sub chunk to this list chunk. Note that       * Creates and adds a new list sub chunk to this list chunk. Note that
# Line 1155  namespace RIFF { Line 1174  namespace RIFF {
1174       *       *
1175       * 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
1176       * 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
1177       * 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,
1178       * change persistent at any time.       * all its subchunks (if any) will be removed recursively as well. You
1179         * should call File::Save() to make this change persistent at any time.
1180       *       *
1181       * @param pSubChunk - sub chunk or sub list chunk to be removed       * @param pSubChunk - sub chunk or sub list chunk to be removed
1182       */       */
# Line 1514  namespace RIFF { Line 1534  namespace RIFF {
1534          // 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)
1535          unsigned long ulPositiveSizeDiff = 0;          unsigned long ulPositiveSizeDiff = 0;
1536          for (ChunkList::iterator iter = ResizedChunks.begin(), end = ResizedChunks.end(); iter != end; ++iter) {          for (ChunkList::iterator iter = ResizedChunks.begin(), end = ResizedChunks.end(); iter != end; ++iter) {
1537              if ((*iter)->GetNewSize() == 0) throw Exception("There is at least one empty chunk (zero size)");              if ((*iter)->GetNewSize() == 0) {
1538                    // just to make the exception message a bit more verbose: resolve the chunk's path
1539                    String sChunkPath;
1540                    for (Chunk* pChunk = *iter; pChunk; pChunk = pChunk->GetParent()) {
1541                        if (pChunk->GetChunkID() == CHUNK_ID_LIST) {
1542                            List* pList = (List*) pChunk;
1543                            sChunkPath = "->'" + pList->GetListTypeString() + "'" + sChunkPath;
1544                        } else {
1545                            sChunkPath = "->'" + pChunk->GetChunkIDString() + "'" + sChunkPath;
1546                        }
1547                    }
1548                    throw Exception("There is at least one empty chunk (zero size): " + sChunkPath);
1549                }
1550              if ((*iter)->GetNewSize() + 1L > (*iter)->GetSize()) {              if ((*iter)->GetNewSize() + 1L > (*iter)->GetSize()) {
1551                  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
1552                  ulPositiveSizeDiff += ulDiff;                  ulPositiveSizeDiff += ulDiff;
# Line 1675  namespace RIFF { Line 1707  namespace RIFF {
1707          ResizedChunks.push_back(pResizedChunk);          ResizedChunks.push_back(pResizedChunk);
1708      }      }
1709    
1710        void File::UnlogResized(Chunk* pResizedChunk) {
1711            ResizedChunks.remove(pResizedChunk);
1712        }
1713    
1714      unsigned long File::GetFileSize() {      unsigned long File::GetFileSize() {
1715          return __GetFileSize(hFileRead);          return __GetFileSize(hFileRead);
1716      }      }

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

  ViewVC Help
Powered by ViewVC