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

Legend:
Removed from v.518  
changed lines
  Added in v.3478

  ViewVC Help
Powered by ViewVC