-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdump.cpp
More file actions
50 lines (42 loc) · 1.97 KB
/
Copy pathdump.cpp
File metadata and controls
50 lines (42 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// dump.cpp - print the metadata of a .rhm file.
#include <rhmParse/rhmParse.h>
#include <cstdio>
#include <fstream>
#include <iterator>
#include <vector>
int main(int argc, char** argv)
{
if (argc < 2) { std::fprintf(stderr, "usage: %s path/to/map.rhm\n", argv[0]); return 2; }
std::ifstream f(argv[1], std::ios::binary);
if (!f) { std::fprintf(stderr, "cannot open %s\n", argv[1]); return 1; }
std::vector<uint8_t> bytes((std::istreambuf_iterator<char>(f)),
std::istreambuf_iterator<char>());
rhm::Rhm rhm;
if (!rhm::Parse(bytes, rhm)) { std::fprintf(stderr, "invalid .rhm\n"); return 1; }
const auto& m = rhm.map;
std::printf("Title: %s\n", m.title.c_str());
std::printf("Song: %s\n", m.songName.c_str());
std::printf("LegacyId: %s\n", m.legacyId.c_str());
std::printf("OnlineId: %s\n",
m.onlineId ? std::to_string(*m.onlineId).c_str() : "(null)");
std::printf("OnlineStatus: %s\n",
m.onlineStatus ? m.onlineStatus->c_str() : "(null)");
std::printf("Mappers: ");
for (std::size_t i = 0; i < m.mappers.size(); ++i)
{
if (i) std::printf(", ");
std::printf("%s", m.mappers[i].c_str());
}
std::printf("\n");
std::printf("Duration: %d ms\n", m.duration);
std::printf("Difficulty: %d\n", m.difficulty);
std::printf("CustomDifficultyName: \"%s\"\n", m.customDifficultyName.c_str());
std::printf("StarRating: %.4f\n", static_cast<double>(m.starRating));
std::printf("Notes: %zu\n", m.notes.size());
std::printf("AudioFileName: %s\n", m.audioFileName.c_str());
std::printf("ImagePath: %s\n",
m.imagePath ? m.imagePath->c_str() : "(null)");
std::printf("Audio bytes: %zu\n", rhm.audio.size());
std::printf("Cover bytes: %zu\n", rhm.cover.size());
return 0;
}