Skip to content

Latest commit

 

History

History
35 lines (26 loc) · 649 Bytes

map-file.pod

File metadata and controls

35 lines (26 loc) · 649 Bytes

NAME

map-file: memory-map a file

EXAMPLE

#include "map-file.hh"

// print out file content
auto file = tue::map_file("filename");
for (auto i=0u; i<file->size; i++)
        std::cerr << reinterpret_cast<char*>(file->data)[i];
std::cerr << "\n";

SYNOPSIS

namespace tue
{
        struct file_map final
        {
                using uptr = std::unique_ptr<file_map>;
                void* data;
                std::size_t size;
        };

        file_map::uptr map_file(std::string const& path);

        inline namespace map_file_exceptions
        {
                struct open_failure : std::runtime_error;
                struct stat_failure : std::runtime_error;
                struct  map_failure : std::runtime_error;
        }
}