This release is the first one to have code by @ADM228. It contains multiple quality of life improvements, as well as several new things.
libriff-X: A new name
Since this fork will be extended a lot more (and also due to 2 other libraries existing with the same name), I have decided to rename the library to libriff-X to represent the fact that it has extended features. This name is purely external, as every file and namespace is still riff.
C++ wrapper
The biggest new thing in this release is the C++ wrapper, with separate header and implementation files:
- Has a wide compatibility spectrum by being written in C++11
- It provides an easy to use
RIFFFileclass that automatically allocates ariff_handlefor itself- It also automatically allocates a new
riff_handlewhen being copied. - ERRATA: It allocates a new
riff_handle, but not a new file / memory object
- It also automatically allocates a new
- Every C function is explicitly or implicitly (the allocator/deallocator) mirrored in the C++ wrappe
- The C++ wrapper stores the latest error code of its methods
- This allows the programmer to not constantly write
err = riff_...()- it's done automatically - The latest error can be accessed with the
RIFF::latestErrormethod, and printed withRIFF::latestErrorToString
- This allows the programmer to not constantly write
- File handling improvements:
- A new way to open files is via
std::fstreamvia theRIFF::openFstreammethod - C FILE objects and memory blocks are still supported via
RIFF::openCFILEandRIFF::openMemoryrespectively RIFFFilecan also open its own C FILE andstd::fstreamobjects - you just supply the filename and the work is done for youconst char *andstd::stringarguments are always availablestd::filesystem::pathargument is toggleable on/off as a C++17-only feature
- A new way to open files is via
- A convenient
RIFFFile::readChunkDatamethod that reads the entire chunk's data in one go - The
example.cfile was also ported to C++ to createexample.cpp
CMake API
A very easy to use CMake API is now available:
- Can be used with
FetchContentas well as just being a subdirectory - Has several useful options:
RIFF_STATIC_LIBRARIESallows libriff to compile as a static or dynamic libraryRIFF_CXX_WRAPPERallows disabling the C++ wrapperRIFF_CXX_STD_FILESYSTEM_PATHallows enabling/disablingstd::filesystem::patharguments forRIFFFile::open_...methodsRIFF_CXX_PRINT_ERRORScontrols whether error messages will be printed from from the C++ wrapper to stdout
Base C library changes
The files have moved
Instead of just being in the root folder, riff.c and riff.h now reside in the src folder. The riff.cpp and riff.hpp files are also located there.
Bugfixes
- Memory reading/seeking fixed by taking
riff_handle->posinto account- The internal
riff_handlefunctionsfp_readandfp_seekhave had their first argument changed fromvoid *fhtostruct riff_handle *rhto make this happen (this is incompatible but idgaf since these are purely internal)
- The internal
- Every
riff_...function now checks if theriff_handleis valid - A
mallochas been replaced with acallocfor better level stack allocation - Multiple
strcpys andstrcmps replaced withmemcpys andmemcmps for better security
New features
<stdint.h>is now used for more consistency across platforms- Now dependent header files (
<stddef.h>,<stdio.h>and<stdint.h>) are automatically included in riff.h - Preliminary support for 64-bit sized files
- Documentation can be found here
- libriff now works with files and chunk lists with the ID
BW64in addition toRIFF - If the first chunk is
ds64and the file size is specified to be in this chunk, the 64-bit real file size is read automatically
- New functions for more convenience:
int riff_seekLevelParentStart(struct riff_handle *rh)seeks to the start of the parent levelint riff_seekLevelParentNext(struct riff_handle *rh)seeks to the parent level and then to the next chunkint riff_fileValidate(struct riff_handle *rh)validates the entire RIFF file recursivelyint32_t riff_amountOfChunksInLevel(struct riff_handle *rh)counts the amount of chunks in a chunk levelint32_t riff_amountOfChunksInLevelWithID(struct riff_handle *rh, const char * id)counts the amount of chunks with a matching ID in a chunk level- All of these functions are also available in the C++ wrapper
Doxygen-compatible documentation
This was one of the TODOs done originally specified by the original creator @murkymark back in 2016 - and it has finally been implemented. The riff.h and riff.hpp files contain a Doxygen-compatible documentation entry for everything. There is also a Doxyfile in the repository which can be used to generate preliminary Doxygen documentation. The new docs.h file also exists to provide some more useful documenation.