-
Notifications
You must be signed in to change notification settings - Fork 7
/
UnicvDbParser.cpp
60 lines (49 loc) · 1.35 KB
/
UnicvDbParser.cpp
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
#include "UnicvDbParser.h"
#include <string>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <iomanip>
#include "UnicvDbTypes.h"
UnicvDbParser::UnicvDbParser(const psvpfs::path& titleIdPath, std::ostream& output)
: m_titleIdPath(titleIdPath), m_output(output)
{
}
int UnicvDbParser::parse()
{
if(!psvpfs::exists(m_titleIdPath))
{
m_output << "Root directory does not exist" << std::endl;
return -1;
}
psvpfs::path filepath = m_titleIdPath / "sce_pfs" / "unicv.db";
if(!psvpfs::exists(filepath))
{
psvpfs::path filepath2 = m_titleIdPath / "sce_pfs" / "icv.db";
if(!psvpfs::exists(filepath2) || !psvpfs::is_directory(filepath2))
{
m_output << "failed to find unicv.db file or icv.db folder" << std::endl;
return -1;
}
else
{
m_output << "parsing icv.db..." << std::endl;
m_fdb = std::unique_ptr<sce_idb_base_t>(new sce_icvdb_t(m_output));
if(!m_fdb->read(filepath2))
return -1;
return 0;
}
}
else
{
m_output << "parsing unicv.db..." << std::endl;
m_fdb = std::unique_ptr<sce_idb_base_t>(new sce_irodb_t(m_output));
if(!m_fdb->read(filepath))
return -1;
return 0;
}
}
const std::unique_ptr<sce_idb_base_t>& UnicvDbParser::get_idatabase() const
{
return m_fdb;
}