#ifndef OSRM_UTIL_MMAP_TAR_HPP #define OSRM_UTIL_MMAP_TAR_HPP #include "storage/tar.hpp" #include "util/mmap_file.hpp" #include #include #include namespace osrm { namespace util { using DataRange = std::pair; using DataMap = std::unordered_map; inline DataMap mmapTarFile(const boost::filesystem::path &path, boost::iostreams::mapped_file_source ®ion) { DataMap map; storage::tar::FileReader reader{path, storage::tar::FileReader::VerifyFingerprint}; std::vector entries; reader.List(std::back_inserter(entries)); auto raw_file = mmapFile(path, region); for (const auto &entry : entries) { auto begin = raw_file.data() + entry.offset; auto end = begin + entry.size; map[entry.name] = DataRange{begin, end}; } return map; } } } #endif