-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathinfo.ixx
98 lines (79 loc) · 2.39 KB
/
info.ixx
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
module;
#include <filesystem>
#include <fstream>
#include <list>
#include <sstream>
#include <string>
#include <utility>
#include "systems/system.hh"
#include "throw_line.hh"
export module info;
import cd.cdrom;
import dump;
import filesystem.iso9660;
import options;
import readers.image_bin_form1_reader;
import readers.image_iso_form1_reader;
import readers.image_raw_reader;
import readers.sector_reader;
import systems.systems;
import utils.hex_bin;
import utils.logger;
import utils.misc;
import utils.strings;
namespace gpsxre
{
enum class TrackType
{
DATA,
AUDIO,
ISO
};
export void redumper_info(Context &ctx, Options &options)
{
image_check_empty(options);
auto image_prefix = (std::filesystem::path(options.image_path) / options.image_name).string();
std::list<std::pair<std::filesystem::path, TrackType>> tracks;
if(std::filesystem::exists(image_prefix + ".cue"))
{
for(auto const &t : cue_get_entries(image_prefix + ".cue"))
tracks.emplace_back(std::filesystem::path(options.image_path) / t.first, t.second ? TrackType::DATA : TrackType::AUDIO);
}
else if(std::filesystem::exists(image_prefix + ".iso"))
{
tracks.emplace_back(image_prefix + ".iso", TrackType::ISO);
}
else
throw_line("image file not found");
bool separate_nl = false;
for(auto const &t : tracks)
{
std::shared_ptr<SectorReader> raw_reader;
std::shared_ptr<SectorReader> form1_reader;
if(t.second == TrackType::ISO)
form1_reader = std::make_shared<Image_ISO_Reader>(t.first);
else if(t.second == TrackType::DATA)
{
raw_reader = std::make_shared<Image_RawReader>(t.first);
form1_reader = std::make_shared<Image_BIN_Form1Reader>(t.first);
}
for(auto const &s : Systems::get())
{
auto system = s();
auto reader = system->getType() == System::Type::ISO ? form1_reader : raw_reader;
if(!reader)
continue;
std::stringstream ss;
system->printInfo(ss, reader.get(), t.first);
if(ss.rdbuf()->in_avail())
{
if(separate_nl)
LOG("");
separate_nl = true;
LOG("{} [{}]:", system->getName(), t.first.filename().string());
LOG_F("{}", ss.str());
}
}
}
}
}