Download the PicoStorage Library
PicoStorage allows you to store hierarhical information (similar to "files and directories") inside a single file. The functionality offered is largely equivalent to the one offered by any filesystem, or by the Structured Storage and Compound Files.
PicoStorage can efficiently handle huge numbers of small files, with very economical disk usage; it also allows you to keep open (in RAM) simultaneously a large number of files. Transaction support guarantees data integrity. Learn more about the distinctive advantages of PicoStorage. or look at the benchmark.
The library is available on a dual-license basis: under GPL for free, and under a commercial license for use in closed-source applications.
Using the library
The library contains the classes File and Dir to represent files and directories. On a File you can read or write a number of bytes from a given offset, and set/get the file size. On a Dir you can create entries (either files or subdirectories), open entries, delete entries, and iterate over the directory's content.
The storage itself (i.e. the whole hierarchical structure, contained in a filesystem file) is represented by the class Storage. Using this class, you can create or open a storage, obtain the root directory of the storage, close the storage and do commit or rollback.
Let's look at a small example:
#include "PicoStorage.hpp"
using namespace PicoStorage;
int main() {
char location[] = "storage.pico";
createStorage(location);
Dir root = openStorage(location);
File file = root.createFile("file name");
char txt[] = "hello world";
file.pwrite(txt, sizeof(txt), 0);
root.commit();
}
Class Reference
Below are all the PicoStorage classes which are meaningful to the user of the library. All these classes are in the namespace PicoStorage, and you get them all by including the header file PicoStorage.hpp.
- File A simple file that you can read/write to.
- Dir A directory holds a set of named directory entries, which can be either files or directories
- Storage A storage is the hierarchical collection of files and directories stored in a single filesystem file
- Dir::Iterator Allows to iterate over the entries of a directory
- Exception The unexpected errors are reported through exceptions.