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

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

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

revision 2 by schoenebeck, Sat Oct 25 20:15:04 2003 UTC revision 3468 by persson, Tue Feb 12 18:54:40 2019 UTC
# Line 1  Line 1 
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 by Christian Schoenebeck                           *   *   Copyright (C) 2003-2019 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  *
9   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 24  Line 24 
24  #ifndef __RIFF_H__  #ifndef __RIFF_H__
25  #define __RIFF_H__  #define __RIFF_H__
26    
27  #define POSIX 1  #ifdef WIN32
28  #define DEBUG 0  # define POSIX 0
29    #endif
30    
31    #ifndef POSIX
32    # define POSIX 1
33    #endif
34    
35    #ifndef DEBUG
36    # define DEBUG 0
37    #endif
38    
39  #include <string>  #include <string>
40  #include <list>  #include <list>
41  #include <map>  #include <map>
42    #include <set>
43  #include <iostream>  #include <iostream>
44    #include <stdarg.h>
45    
46    #ifdef HAVE_CONFIG_H
47    # include <config.h>
48    #endif
49    
50  #if POSIX  #if POSIX
51  # include <sys/types.h>  # include <sys/types.h>
# Line 39  Line 54 
54  # include <unistd.h>  # include <unistd.h>
55  #endif // POSIX  #endif // POSIX
56    
57    #ifdef _MSC_VER
58    // Visual C++ 2008 doesn't have stdint.h
59    typedef __int8 int8_t;
60    typedef __int16 int16_t;
61    typedef __int32 int32_t;
62    typedef __int64 int64_t;
63    typedef unsigned __int8 uint8_t;
64    typedef unsigned __int16 uint16_t;
65    typedef unsigned __int32 uint32_t;
66    typedef unsigned __int64 uint64_t;
67    #else
68  #include <stdint.h>  #include <stdint.h>
69    #endif
70    
71  //typedef unsigned char  uint8_t;  #ifdef WIN32
72  //typedef unsigned short uint16_t;  # if (_WIN32 && !_WIN64) || (__GNUC__ && !(__x86_64__ || __ppc64__)) /* if 32 bit windows compilation */
73  //typedef unsigned int   uint32_t;  #  if _WIN32_WINNT < 0x0501
74    #   undef _WIN32_WINNT
75    #   define _WIN32_WINNT 0x0501 /* Win XP (no service pack): required for 32 bit compilation for GetFileSizeEx() to be declared by windows.h */
76    #  endif
77    # endif
78    # include <windows.h>
79      typedef unsigned int   uint;
80    #endif // WIN32
81    
82  #include <stdio.h>  #include <stdio.h>
83    
# Line 51  Line 85 
85  # define CHUNK_ID_RIFF  0x52494646  # define CHUNK_ID_RIFF  0x52494646
86  # define CHUNK_ID_RIFX  0x52494658  # define CHUNK_ID_RIFX  0x52494658
87  # define CHUNK_ID_LIST  0x4C495354  # define CHUNK_ID_LIST  0x4C495354
88    
89    # define LIST_TYPE_INFO 0x494E464F
90    # define CHUNK_ID_ICMT  0x49434D54
91    # define CHUNK_ID_ICOP  0x49434F50
92    # define CHUNK_ID_ICRD  0x49435244
93    # define CHUNK_ID_IENG  0x49454E47
94    # define CHUNK_ID_INAM  0x494E414D
95    # define CHUNK_ID_IPRD  0x49505244
96    # define CHUNK_ID_ISFT  0x49534654
97    
98    # define CHUNK_ID_SMPL  0x736D706C
99    
100  #else  // little endian  #else  // little endian
101  # define CHUNK_ID_RIFF  0x46464952  # define CHUNK_ID_RIFF  0x46464952
102  # define CHUNK_ID_RIFX  0x58464952  # define CHUNK_ID_RIFX  0x58464952
103  # define CHUNK_ID_LIST  0x5453494C  # define CHUNK_ID_LIST  0x5453494C
 #endif // WORDS_BIGENDIAN  
104    
105  #define CHUNK_HEADER_SIZE       8  # define LIST_TYPE_INFO 0x4F464E49
106  #define LIST_HEADER_SIZE        12  # define CHUNK_ID_ICMT  0x544D4349
107  #define RIFF_HEADER_SIZE        12  # define CHUNK_ID_ICOP  0x504F4349
108    # define CHUNK_ID_ICRD  0x44524349
109    # define CHUNK_ID_IENG  0x474E4549
110    # define CHUNK_ID_INAM  0x4D414E49
111    # define CHUNK_ID_IPRD  0x44525049
112    # define CHUNK_ID_ISFT  0x54465349
113    
114    # define CHUNK_ID_SMPL  0x6C706D73
115    
116    #endif // WORDS_BIGENDIAN
117    
118  /** RIFF specific classes and definitions */  #define CHUNK_HEADER_SIZE(fileOffsetSize)   (4 + fileOffsetSize)
119    #define LIST_HEADER_SIZE(fileOffsetSize)    (8 + fileOffsetSize)
120    #define RIFF_HEADER_SIZE(fileOffsetSize)    (8 + fileOffsetSize)
121    
122    /**
123     * @brief RIFF specific classes and definitions
124     *
125     * The Resource Interchange File Format (RIFF) is a generic tree-structured
126     * meta-format which stores data in so called "chunks". It can be compared
127     * to XML, but in contrast to XML, RIFF is entirely binary encoded, that is
128     * not ASCII based. RIFF is used as basis for many file formats like AVI,
129     * WAV, DLS and of course the Gigasampler file format. ;-)
130     *
131     * RIFF chunks can be seen as containers for data. There are two distinct
132     * types of chunks:
133     *
134     * - @e ordinary @e chunks are the leafs of the data tree which encapsulate
135     *   the actual data of the file (i.e. the sample data of a .wav file)
136     *
137     * - @e list @e chunks are the nodes of the data tree which hold an
138     *   arbitrary amount of subchunks (can be both, list chunks and/or ordinary
139     *   chunks)
140     */
141  namespace RIFF {  namespace RIFF {
142    
143      /* just symbol prototyping */      /* just symbol prototyping */
144      class Chunk;      class Chunk;
145      class List;      class List;
146        class File;
147    
148      typedef std::string String;      typedef std::string String;
149    
150        /** Type used by libgig for handling file positioning during file I/O tasks. */
151        typedef uint64_t file_offset_t;
152    
153        /** Whether file stream is open in read or in read/write mode. */
154        enum stream_mode_t {
155            stream_mode_read       = 0,
156            stream_mode_read_write = 1,
157            stream_mode_closed     = 2
158        };
159    
160      /** Current state of the file stream. */      /** Current state of the file stream. */
161      typedef enum {      enum stream_state_t {
162          stream_ready       = 0,          stream_ready       = 0,
163          stream_end_reached = 1,          stream_end_reached = 1,
164          stream_closed      = 2          stream_closed      = 2
165      } stream_state_t;      };
166    
167      /** File stream position dependent to these relations. */      /** File stream position dependent to these relations. */
168      typedef enum {      enum stream_whence_t {
169          stream_start    = 0,          stream_start    = 0,
170          stream_curpos   = 1,          stream_curpos   = 1,
171          stream_backward = 2,          stream_backward = 2,
172          stream_end      = 3          stream_end      = 3
173      } stream_whence_t;      };
174    
175      /** Provides convenient methods to access data of RIFF chunks in general. */      /** Alignment of data bytes in memory (system dependant). */
176        enum endian_t {
177            endian_little = 0,
178            endian_big    = 1,
179            endian_native = 2
180        };
181    
182        /** General RIFF chunk structure of a RIFF file. */
183        enum layout_t {
184            layout_standard = 0, ///< Standard RIFF file layout: First chunk in file is a List chunk which contains all other chunks and there are no chunks outside the scope of that very first (List) chunk.
185            layout_flat     = 1  ///< Not a "real" RIFF file: First chunk in file is an ordinary data chunk, not a List chunk, and there might be other chunks after that first chunk.
186        };
187    
188        /** Size of RIFF file offsets used in all RIFF chunks' headers. @see File::GetFileOffsetSize() */
189        enum offset_size_t {
190            offset_size_auto  = 0, ///< Use 32 bit offsets for files smaller than 4 GB, use 64 bit offsets for files equal or larger than 4 GB.
191            offset_size_32bit = 4, ///< Always use 32 bit offsets (even for files larger than 4 GB).
192            offset_size_64bit = 8  ///< Always use 64 bit offsets (even for files smaller than 4 GB).
193        };
194    
195        /**
196         * @brief Used for indicating the progress of a certain task.
197         *
198         * The function pointer argument has to be supplied with a valid
199         * function of the given signature which will then be called on
200         * progress changes. An equivalent progress_t structure will be passed
201         * back as argument to the callback function on each progress change.
202         * The factor field of the supplied progress_t structure will then
203         * reflect the current progress as value between 0.0 and 1.0. You might
204         * want to use the custom field for data needed in your callback
205         * function.
206         */
207        struct progress_t {
208            void (*callback)(progress_t*); ///< Callback function pointer which has to be assigned to a function for progress notification.
209            float factor;                  ///< Reflects current progress as value between 0.0 and 1.0.
210            void* custom;                  ///< This pointer can be used for arbitrary data.
211            float __range_min;             ///< Only for internal usage, do not modify!
212            float __range_max;             ///< Only for internal usage, do not modify!
213            progress_t();
214        };
215    
216        /** @brief Ordinary RIFF Chunk
217         *
218         * Provides convenient methods to access data of ordinary RIFF chunks
219         * in general.
220         */
221      class Chunk {      class Chunk {
222          public:          public:
223              #if POSIX              Chunk(File* pFile, file_offset_t StartPos, List* Parent);
224              Chunk(int hFile, unsigned long StartPos, bool EndianNative, List* Parent);              String         GetChunkIDString() const;
225              #else              uint32_t       GetChunkID() const { return ChunkID; }       ///< Chunk ID in unsigned integer representation.
226              Chunk(FILE* hFile, unsigned long StartPos, bool EndianNative, List* Parent);              File*          GetFile() const    { return pFile;   }       ///< Returns pointer to the chunk's File object.
227              #endif // POSIX              List*          GetParent() const  { return pParent; }       ///< Returns pointer to the chunk's parent list chunk.
228              String         GetChunkIDString();              file_offset_t  GetSize() const { return ullCurrentChunkSize; } ///< Chunk size in bytes (without header, thus the chunk data body)
229              uint32_t       GetChunkID() { return ChunkID; };              file_offset_t  GetNewSize() const { return ullNewChunkSize; } ///< New chunk size if it was modified with Resize(), otherwise value returned will be equal to GetSize().
230              List*          GetParent()  { return pParent; };              file_offset_t  GetPos() const { return ullPos; }            ///< Position within the chunk data body (starting with 0).
231              unsigned long  GetSize()    { return ChunkSize; }; ///< Chunk size in bytes (without header, thus the chunk data body)              file_offset_t  GetFilePos() const { return ullStartPos + ullPos; } ///< Current, actual offset of chunk data body start in file.
232              unsigned long  GetPos()     { return ulPos; };     ///< Position within the chunk data body              file_offset_t  SetPos(file_offset_t Where, stream_whence_t Whence = stream_start);
233              unsigned long  GetFilePos() { return ulStartPos + ulPos; }; ///< Current, actual offset in file.              file_offset_t  RemainingBytes() const;
234              unsigned long  SetPos(unsigned long Where, stream_whence_t Whence = stream_start);              stream_state_t GetState() const;
235              unsigned long  RemainingBytes();              file_offset_t  Read(void* pData, file_offset_t WordCount, file_offset_t WordSize);
236              stream_state_t GetState();              file_offset_t  ReadInt8(int8_t* pData,     file_offset_t WordCount = 1);
237              unsigned long  Read(void* pData, unsigned long WordCount, unsigned long WordSize);              file_offset_t  ReadUint8(uint8_t* pData,   file_offset_t WordCount = 1);
238              unsigned long  ReadInt8(int8_t* pData,     unsigned long WordCount = 1);              file_offset_t  ReadInt16(int16_t* pData,   file_offset_t WordCount = 1);
239              unsigned long  ReadUint8(uint8_t* pData,   unsigned long WordCount = 1);              file_offset_t  ReadUint16(uint16_t* pData, file_offset_t WordCount = 1);
240              unsigned long  ReadInt16(int16_t* pData,   unsigned long WordCount = 1);              file_offset_t  ReadInt32(int32_t* pData,   file_offset_t WordCount = 1);
241              unsigned long  ReadUint16(uint16_t* pData, unsigned long WordCount = 1);              file_offset_t  ReadUint32(uint32_t* pData, file_offset_t WordCount = 1);
             unsigned long  ReadInt32(int32_t* pData,   unsigned long WordCount = 1);  
             unsigned long  ReadUint32(uint32_t* pData, unsigned long WordCount = 1);  
242              int8_t         ReadInt8();              int8_t         ReadInt8();
243              uint8_t        ReadUint8();              uint8_t        ReadUint8();
244              int16_t        ReadInt16();              int16_t        ReadInt16();
245              uint16_t       ReadUint16();              uint16_t       ReadUint16();
246              int32_t        ReadInt32();              int32_t        ReadInt32();
247              uint32_t       ReadUint32();              uint32_t       ReadUint32();
248              void*          LoadChunkData();     ///< Load the whole chunk body in memory (on success returns a pointer to the data in RAM, else NULL).              void           ReadString(String& s, int size);
249              void           ReleaseChunkData();  ///< Free loaded chunk body data from memory (RAM).              file_offset_t  Write(void* pData, file_offset_t WordCount, file_offset_t WordSize);
250             ~Chunk();              file_offset_t  WriteInt8(int8_t* pData,     file_offset_t WordCount = 1);
251                file_offset_t  WriteUint8(uint8_t* pData,   file_offset_t WordCount = 1);
252                file_offset_t  WriteInt16(int16_t* pData,   file_offset_t WordCount = 1);
253                file_offset_t  WriteUint16(uint16_t* pData, file_offset_t WordCount = 1);
254                file_offset_t  WriteInt32(int32_t* pData,   file_offset_t WordCount = 1);
255                file_offset_t  WriteUint32(uint32_t* pData, file_offset_t WordCount = 1);
256                void*          LoadChunkData();
257                void           ReleaseChunkData();
258                void           Resize(file_offset_t NewSize);
259                virtual ~Chunk();
260          protected:          protected:
261              uint32_t      ChunkID;              uint32_t      ChunkID;
262              uint32_t      ChunkSize;            /* in bytes */              file_offset_t ullCurrentChunkSize;          /* in bytes */
263                file_offset_t ullNewChunkSize;                      /* in bytes (if chunk was scheduled to be resized) */
264              List*         pParent;              List*         pParent;
265              #if POSIX              File*         pFile;
266              int           hFile;              file_offset_t ullStartPos;  /* actual position in file where chunk data (without header) starts */
267              #else              file_offset_t ullPos;       /* # of bytes from ulStartPos */
             FILE*         hFile;  
             #endif // POSIX  
             unsigned long ulStartPos;           /* actual position in file where chunk (without header) starts */  
             unsigned long ulPos;                /* # of bytes from ulStartPos */  
             bool          bEndianNative;  
268              uint8_t*      pChunkData;              uint8_t*      pChunkData;
269                file_offset_t ullChunkDataSize;
270    
271              Chunk();              Chunk(File* pFile);
272              void          ReadHeader(unsigned long fPos);              Chunk(File* pFile, List* pParent, uint32_t uiChunkID, file_offset_t ullBodySize);
273              unsigned long ReadSceptical(void* pData, unsigned long WordCount, unsigned long WordSize);              void ReadHeader(file_offset_t filePos);
274              inline void   swapBytes_16(void* Word) {              void WriteHeader(file_offset_t filePos);
275                  uint8_t byteCache = *((uint8_t*) Word);              file_offset_t ReadSceptical(void* pData, file_offset_t WordCount, file_offset_t WordSize);
276                  *((uint8_t*) Word)     = *((uint8_t*) Word + 1);              inline static String convertToString(uint32_t word) {
                 *((uint8_t*) Word + 1) = byteCache;  
             }  
             inline void   swapBytes_32(void* Word) {  
                 uint8_t byteCache = *((uint8_t*) Word);  
                 *((uint8_t*) Word)     = *((uint8_t*) Word + 3);  
                 *((uint8_t*) Word + 3) = byteCache;  
                 byteCache = *((uint8_t*) Word + 1);  
                 *((uint8_t*) Word + 1) = *((uint8_t*) Word + 2);  
                 *((uint8_t*) Word + 2) = byteCache;  
             }  
             inline void   swapBytes(void* Word, unsigned long WordSize) {  
                 uint8_t byteCache;  
                 unsigned long lo = 0, hi = WordSize - 1;  
                 for (; lo < hi; hi--, lo++) {  
                     byteCache = *((uint8_t*) Word + lo);  
                     *((uint8_t*) Word + lo) = *((uint8_t*) Word + hi);  
                     *((uint8_t*) Word + hi) = byteCache;  
                 }  
             }  
             inline String convertToString(uint32_t word) {  
277                  String result;                  String result;
278                  for (int i = 0; i < 4; i++) {                  for (int i = 0; i < 4; i++) {
279                      uint8_t byte = *((uint8_t*)(&word) + i);                      uint8_t byte = *((uint8_t*)(&word) + i);
# Line 167  namespace RIFF { Line 282  namespace RIFF {
282                  }                  }
283                  return result;                  return result;
284              }              }
285                virtual file_offset_t RequiredPhysicalSize(int fileOffsetSize);
286                virtual file_offset_t WriteChunk(file_offset_t ullWritePos, file_offset_t ullCurrentDataOffset, progress_t* pProgress = NULL);
287                virtual void __resetPos(); ///< Sets Chunk's read/write position to zero.
288    
289                friend class List;
290      };      };
291    
292      /** Provides convenient methods to access data of RIFF list chunks and their subchunks. */      /** @brief RIFF List Chunk
293         *
294         * Provides convenient methods to access data of RIFF list chunks and
295         * their subchunks.
296         */
297      class List : public Chunk {      class List : public Chunk {
298          public:          public:
299              #if POSIX              List(File* pFile, file_offset_t StartPos, List* Parent);
300              List(int hFile, unsigned long StartPos, bool EndianNative, List* Parent);              String       GetListTypeString() const;
301              #else              uint32_t     GetListType() const { return ListType; } ///< Returns unsigned integer representation of the list's ID
302              List(FILE* hFile, unsigned long StartPos, bool EndianNative, List* Parent);              Chunk*       GetSubChunk(uint32_t ChunkID);
303              #endif // POSIX              List*        GetSubList(uint32_t ListType);
             String       GetListTypeString();  
             uint32_t     GetListType() { return ListType; }  
             Chunk*       GetSubChunk(uint32_t ChunkID); /* use this if you expect only one subchunk of that type in the list */  
             List*        GetSubList(uint32_t ListType); /* use this if you expect only one sublist chunk of that type in the list */  
304              Chunk*       GetFirstSubChunk();              Chunk*       GetFirstSubChunk();
305              Chunk*       GetNextSubChunk();              Chunk*       GetNextSubChunk();
306              List*        GetFirstSubList();              List*        GetFirstSubList();
307              List*        GetNextSubList();              List*        GetNextSubList();
308              unsigned int CountSubChunks();              size_t       CountSubChunks();
309              unsigned int CountSubChunks(uint32_t ChunkID);              size_t       CountSubChunks(uint32_t ChunkID);
310              unsigned int CountSubLists();              size_t       CountSubLists();
311              unsigned int CountSubLists(uint32_t ListType);              size_t       CountSubLists(uint32_t ListType);
312             ~List();              Chunk*       AddSubChunk(uint32_t uiChunkID, file_offset_t ullBodySize);
313                List*        AddSubList(uint32_t uiListType);
314                void         DeleteSubChunk(Chunk* pSubChunk);
315                void         MoveSubChunk(Chunk* pSrc, Chunk* pDst); // read API doc comments !!!
316                void         MoveSubChunk(Chunk* pSrc, List* pNewParent);
317                virtual ~List();
318          protected:          protected:
319              typedef std::map<uint32_t, RIFF::Chunk*>  ChunkMap;              typedef std::map<uint32_t, RIFF::Chunk*>  ChunkMap;
320              typedef std::list<Chunk*>                 ChunkList;              typedef std::list<Chunk*>                 ChunkList;
321                typedef std::set<Chunk*>                  ChunkSet;
322    
323              uint32_t   ListType;              uint32_t   ListType;
324              ChunkList* pSubChunks;              ChunkList* pSubChunks;
# Line 200  namespace RIFF { Line 326  namespace RIFF {
326              ChunkList::iterator ChunksIterator;              ChunkList::iterator ChunksIterator;
327              ChunkList::iterator ListIterator;              ChunkList::iterator ListIterator;
328    
329              List();              List(File* pFile);
330              void ReadHeader(unsigned long fPos);              List(File* pFile, List* pParent, uint32_t uiListID);
331              void LoadSubChunks();              void ReadHeader(file_offset_t filePos);
332                void WriteHeader(file_offset_t filePos);
333                void LoadSubChunks(progress_t* pProgress = NULL);
334                void LoadSubChunksRecursively(progress_t* pProgress = NULL);
335                virtual file_offset_t RequiredPhysicalSize(int fileOffsetSize);
336                virtual file_offset_t WriteChunk(file_offset_t ullWritePos, file_offset_t ullCurrentDataOffset, progress_t* pProgress = NULL);
337                virtual void __resetPos(); ///< Sets List Chunk's read/write position to zero and causes all sub chunks to do the same.
338                void DeleteChunkList();
339      };      };
340    
341      /** Parses arbitrary RIFF files and provides together with it's base classes convenient methods to walk through the RIFF tree. */      /** @brief RIFF File
342         *
343         * Handles arbitrary RIFF files and provides together with its base
344         * classes convenient methods to walk through, read and modify the
345         * file's RIFF tree.
346         */
347      class File : public List {      class File : public List {
348          public:          public:
349                File(uint32_t FileType);
350              File(const String& path);              File(const String& path);
351             ~File();              File(const String& path, uint32_t FileType, endian_t Endian, layout_t layout, offset_size_t fileOffsetSize = offset_size_auto);
352                stream_mode_t GetMode() const;
353                bool          SetMode(stream_mode_t NewMode);
354                void SetByteOrder(endian_t Endian);
355                String GetFileName() const;
356                void SetFileName(const String& path);
357                bool IsNew() const;
358                layout_t GetLayout() const;
359                file_offset_t GetCurrentFileSize() const;
360                file_offset_t GetRequiredFileSize();
361                file_offset_t GetRequiredFileSize(offset_size_t fileOffsetSize);
362                int GetFileOffsetSize() const;
363                int GetRequiredFileOffsetSize();
364    
365                virtual void Save(progress_t* pProgress = NULL);
366                virtual void Save(const String& path, progress_t* pProgress = NULL);
367                virtual ~File();
368            protected:
369                #if POSIX
370                int    hFileRead;  ///< handle / descriptor for reading from file
371                int    hFileWrite; ///< handle / descriptor for writing to (some) file
372                #elif defined(WIN32)
373                HANDLE hFileRead;  ///< handle / descriptor for reading from file
374                HANDLE hFileWrite; ///< handle / descriptor for writing to (some) file
375                #else
376                FILE*  hFileRead;  ///< handle / descriptor for reading from file
377                FILE*  hFileWrite; ///< handle / descriptor for writing to (some) file
378                #endif // POSIX
379                String Filename;
380                bool   bEndianNative;
381                bool   bIsNewFile;
382                layout_t Layout; ///< An ordinary RIFF file is always set to layout_standard.
383                offset_size_t FileOffsetPreference;
384                int FileOffsetSize; ///< Size of file offsets (in bytes) when this file was opened (or saved the last time).
385    
386                friend class Chunk;
387                friend class List;
388          private:          private:
389              unsigned long GetFileSize();              stream_mode_t  Mode;
390    
391                void __openExistingFile(const String& path, uint32_t* FileType = NULL);
392                void ResizeFile(file_offset_t ullNewSize);
393                #if POSIX
394                file_offset_t __GetFileSize(int hFile) const;
395                #elif defined(WIN32)
396                file_offset_t __GetFileSize(HANDLE hFile) const;
397                #else
398                file_offset_t __GetFileSize(FILE* hFile) const;
399                #endif
400                int FileOffsetSizeFor(file_offset_t fileSize) const;
401                void Cleanup();
402      };      };
403    
404      /** Will be thrown whenever an error occurs while parsing a RIFF file. */      /**
405         * Will be thrown whenever an error occurs while handling a RIFF file.
406         */
407      class Exception {      class Exception {
408          public:          public:
409              String Message;              String Message;
410    
411              Exception(String Message) { Exception::Message = Message; };              Exception(String format, ...);
412                Exception(String format, va_list arg);
413              void PrintMessage();              void PrintMessage();
414              virtual ~Exception() {};              virtual ~Exception() {}
415    
416            protected:
417                Exception();
418                static String assemble(String format, va_list arg);
419      };      };
420    
421        String libraryName();
422        String libraryVersion();
423    
424  } // namespace RIFF  } // namespace RIFF
425  #endif // __RIFF_H__  #endif // __RIFF_H__

Legend:
Removed from v.2  
changed lines
  Added in v.3468

  ViewVC Help
Powered by ViewVC