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-2013 by Christian Schoenebeck * |
* Copyright (C) 2003-2014 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 * |
169 |
endian_native = 2 |
endian_native = 2 |
170 |
} endian_t; |
} endian_t; |
171 |
|
|
172 |
|
/** General chunk structure of a file. */ |
173 |
|
enum layout_t { |
174 |
|
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. |
175 |
|
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. |
176 |
|
}; |
177 |
|
|
178 |
/** @brief Ordinary RIFF Chunk |
/** @brief Ordinary RIFF Chunk |
179 |
* |
* |
180 |
* Provides convenient methods to access data of ordinary RIFF chunks |
* Provides convenient methods to access data of ordinary RIFF chunks |
185 |
Chunk(File* pFile, unsigned long StartPos, List* Parent); |
Chunk(File* pFile, unsigned long StartPos, List* Parent); |
186 |
String GetChunkIDString(); |
String GetChunkIDString(); |
187 |
uint32_t GetChunkID() { return ChunkID; } ///< Chunk ID in unsigned integer representation. |
uint32_t GetChunkID() { return ChunkID; } ///< Chunk ID in unsigned integer representation. |
188 |
|
File* GetFile() { return pFile; } ///< Returns pointer to the chunk's File object. |
189 |
List* GetParent() { return pParent; } ///< Returns pointer to the chunk's parent list chunk. |
List* GetParent() { return pParent; } ///< Returns pointer to the chunk's parent list chunk. |
190 |
unsigned long GetSize() const { return CurrentChunkSize; } ///< Chunk size in bytes (without header, thus the chunk data body) |
unsigned long GetSize() const { return CurrentChunkSize; } ///< Chunk size in bytes (without header, thus the chunk data body) |
191 |
unsigned long GetNewSize() { return NewChunkSize; } ///< New chunk size if it was modified with Resize(). |
unsigned long GetNewSize() { return NewChunkSize; } ///< New chunk size if it was modified with Resize(). |
328 |
public: |
public: |
329 |
File(uint32_t FileType); |
File(uint32_t FileType); |
330 |
File(const String& path); |
File(const String& path); |
331 |
|
File(const String& path, uint32_t FileType, endian_t Endian, layout_t layout); |
332 |
stream_mode_t GetMode(); |
stream_mode_t GetMode(); |
333 |
bool SetMode(stream_mode_t NewMode); |
bool SetMode(stream_mode_t NewMode); |
334 |
void SetByteOrder(endian_t Endian); |
void SetByteOrder(endian_t Endian); |
335 |
String GetFileName(); |
String GetFileName(); |
336 |
void SetFileName(const String& path); |
void SetFileName(const String& path); |
337 |
bool IsNew() const; |
bool IsNew() const; |
338 |
|
layout_t GetLayout() const; |
339 |
virtual void Save(); |
virtual void Save(); |
340 |
virtual void Save(const String& path); |
virtual void Save(const String& path); |
341 |
virtual ~File(); |
virtual ~File(); |
353 |
String Filename; |
String Filename; |
354 |
bool bEndianNative; |
bool bEndianNative; |
355 |
bool bIsNewFile; |
bool bIsNewFile; |
356 |
|
layout_t Layout; ///< An ordinary RIFF file is always set to layout_standard. |
357 |
|
|
358 |
void LogAsResized(Chunk* pResizedChunk); |
void LogAsResized(Chunk* pResizedChunk); |
359 |
void UnlogResized(Chunk* pResizedChunk); |
void UnlogResized(Chunk* pResizedChunk); |
363 |
stream_mode_t Mode; |
stream_mode_t Mode; |
364 |
ChunkList ResizedChunks; ///< All chunks which have been resized (enlarged / shortened). |
ChunkList ResizedChunks; ///< All chunks which have been resized (enlarged / shortened). |
365 |
|
|
366 |
|
void __openExistingFile(const String& path, uint32_t* FileType = NULL); |
367 |
unsigned long GetFileSize(); |
unsigned long GetFileSize(); |
368 |
void ResizeFile(unsigned long ulNewSize); |
void ResizeFile(unsigned long ulNewSize); |
369 |
#if POSIX |
#if POSIX |