File Mapping

· by Benjamin Meyer · 1 min read · original post ↗

·

Traditionally when you wanted to map a file into memory on Unix this was done using mmap and on Windows with CreateFileMapping. Continuing the tradition of simple, consistent API’s, in 4.4 QFile will have two new functions: map() and unmap() that provide the ability to map files into memory.

An quick example:

QFile file("foo"); file.open(QFile::ReadOnly); uchar *memory = file.map(0, file.size()); if (memory) { // have some fun with the data file.unmap(); }

You can check out more in the
map and unmap documentation.

Qt

More on Qt

More from Benjamin Meyer