Remove SHA-256 indices

Nothing uses this code
This commit is contained in:
Ilari Liusvaara 2012-02-27 21:16:09 +02:00
parent fc10354bce
commit 0e6a6b7804

View file

@ -631,75 +631,6 @@ void load_core_state(const std::vector<char>& buf) throw(std::runtime_error)
throw std::runtime_error("SNES core rejected savestate");
}
namespace
{
struct index_entry
{
std::string hash;
std::string relpath;
std::string from;
};
std::list<index_entry> rom_index;
void replace_index(std::list<index_entry> new_index, const std::string& source)
{
std::list<index_entry> tmp_index;
for(auto i : rom_index) {
if(i.from != source)
tmp_index.push_back(i);
}
for(auto i : new_index) {
tmp_index.push_back(i);
}
rom_index = new_index;
}
}
void load_index_file(const std::string& filename) throw(std::bad_alloc, std::runtime_error)
{
std::istream& s = open_file_relative(filename, "");
try {
std::list<index_entry> partial_index;
std::string line;
while(std::getline(s, line)) {
index_entry e;
if(line == "")
continue;
tokensplitter t(line);
e.hash = static_cast<std::string>(t);
e.relpath = t.tail();
e.from = filename;
if(e.hash.length() != 64 || e.relpath == "")
throw std::runtime_error("Bad index file");
partial_index.push_back(e);
}
replace_index(partial_index, filename);
} catch(...) {
delete &s;
throw;
}
delete &s;
}
std::string lookup_file_by_sha256(const std::string& hash) throw(std::bad_alloc, std::runtime_error)
{
if(hash == "")
return "";
for(auto i : rom_index) {
if(i.hash != hash)
continue;
try {
std::istream& o = open_file_relative(i.relpath, i.from);
delete &o;
return resolve_file_relative(i.relpath, i.from);
} catch(...) {
continue;
}
}
throw std::runtime_error("No file with hash '" + hash + "' found in known indices");
}
std::string name_subrom(enum rom_type major, unsigned romnumber) throw(std::bad_alloc)
{
if(romnumber == 0)