A lightweight, header-only C++ library for creating and managing virtual file systems stored in single archive files.
FilePack is a virtual file system implementation that allows you to pack multiple files into a single container file. It's designed for efficient file management, embedding resources, and distributing file collections in a single package.
- Single-file archiving - Pack multiple files into one container
- Stream-based operations - Read/write files using stream interfaces
- Async/Non-blocking I/O - Promise-based API for efficient operations
- JSON metadata - File information stored as readable JSON
- Individual file extraction - Extract all files to a directory
- Memory efficient - Stream-based operations minimize memory usage
- Header-only - Easy to integrate into any project
#include <nodepp/nodepp.h>
#include <filepack/filepack.h>
using namespace nodepp;
void onMain() {
// Create or open a file pack archive
filepack_t pack("myarchive.fpk");
// Write a file
pack.push_string("hello.txt", "Hello World!").await();
// Read a file
auto content = pack.get_readable_data("hello.txt");
if( content.has_value() ) {
console::log( content.value() );
}
}#include <nodepp/nodepp.h>
#include <filepack/filepack.h>
using namespace nodepp;
void onMain() {
// Write a file from a stream
file_t input_file( "data.bin", "r" );
pack.push_writable_stream("data.bin", input_file).await();
// Write multiple files at once
pack.push_writable_list({
"file1.txt",
"file2.txt",
"file3.txt"
}).await();
// Read a file as a stream
auto stream = pack.get_readable_stream("file1.txt");
if( stream.has_value() ) {
// Process the stream asynchronously
}
}#include <nodepp/nodepp.h>
#include <nodepp/zlib.h>
#include <filepack/filepack.h>
using namespace nodepp;
void onMain() {
filepack_t pack( "compressed_pack.fpk" );
auto fout = pack.get_writable_stream( "LICENSE" ).value();
zlib::gzip::pipe( file_t( "LICENSE", "r" ), fout );
}#include <nodepp/nodepp.h>
#include <nodepp/zlib.h>
#include <filepack/filepack.h>
using namespace nodepp;
void onMain() {
filepack_t pack( "compressed_pack.fpk" );
auto fout = pack.get_readable_stream( "LICENSE" ).value();
zlib::gunzip::pipe( fout, file_t( "DONE", "w" ) );
}