mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 21:41:26 +12:00
Move PPU and shader cache
New hash-based location (already used for SPU) Bump PPU cache version, improve naming and decrease size Remove fs::get_data_dir Disable boot.elf cache
This commit is contained in:
parent
aefee04c4a
commit
a419e98acb
7 changed files with 91 additions and 160 deletions
|
@ -1463,75 +1463,6 @@ const std::string& fs::get_cache_dir()
|
|||
return s_dir;
|
||||
}
|
||||
|
||||
std::string fs::get_data_dir(const std::string& prefix, const std::string& location, const std::string& suffix)
|
||||
{
|
||||
static const std::string s_dir = []
|
||||
{
|
||||
const std::string dir = get_cache_dir() + "data/";
|
||||
|
||||
if (!create_path(dir))
|
||||
{
|
||||
return get_cache_dir();
|
||||
}
|
||||
|
||||
return dir;
|
||||
}();
|
||||
|
||||
std::vector<u8> buf;
|
||||
buf.reserve(location.size() + 1);
|
||||
|
||||
// Normalize location
|
||||
for (char c : location)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (c == '/' || c == '\\')
|
||||
#else
|
||||
if (c == '/')
|
||||
#endif
|
||||
{
|
||||
if (buf.empty() || buf.back() != '/')
|
||||
{
|
||||
buf.push_back('/');
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
buf.push_back(c);
|
||||
}
|
||||
|
||||
// Calculate hash
|
||||
u8 hash[20];
|
||||
sha1(buf.data(), buf.size(), hash);
|
||||
|
||||
// Concatenate
|
||||
std::string result = fmt::format("%s%s/%016llx%08x-%s/", s_dir, prefix, reinterpret_cast<be_t<u64>&>(hash[0]), reinterpret_cast<be_t<u32>&>(hash[8]), suffix);
|
||||
|
||||
// Create dir if necessary
|
||||
if (create_path(result))
|
||||
{
|
||||
// Acknowledge original location
|
||||
file(result + ".location", rewrite).write(buf);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string fs::get_data_dir(const std::string& prefix, const std::string& path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
const auto& delim = "/\\";
|
||||
#else
|
||||
const auto& delim = "/";
|
||||
#endif
|
||||
|
||||
// Extract file name and location
|
||||
const std::string& location = fs::get_parent_dir(path);
|
||||
const std::size_t name_pos = path.find_first_not_of(delim, location.size());
|
||||
|
||||
return fs::get_data_dir(prefix, location, name_pos == -1 ? std::string{} : path.substr(name_pos));
|
||||
}
|
||||
|
||||
void fs::remove_all(const std::string& path, bool remove_root)
|
||||
{
|
||||
for (const auto& entry : dir(path))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue