You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hexview/src/main.cpp

32 lines
597 B

#include <fmt/format.h>
#include <fstream>
#include <memory-map.hpp>
#include <hex.hpp>
std::ifstream::pos_type filesize(const char* filename)
{
std::ifstream in(filename, std::ifstream::ate | std::ifstream::binary);
return in.tellg();
}
inline auto map_file(const char* filename)
{
return hv::memory_map(filesize(filename), filename);
}
int main(int argc, char** argv)
{
if(!argv[1]) {
fmt::print("Usage: {} <file>\n", argv[0]);
return 1;
}
auto map = map_file(argv[1]);
auto memory = map.span();
hv::print_screen(memory, 0);
fmt::print("\n");
return 0;
}