mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-12-29 03:24:36 +00:00
fs: implement fs::get_temp_dir() (Win32)
Trying to workaround issues with sparse files (#10231)
This commit is contained in:
parent
546b52200b
commit
e24ada37bf
@ -1729,6 +1729,32 @@ const std::string& fs::get_cache_dir()
|
||||
return s_dir;
|
||||
}
|
||||
|
||||
const std::string& fs::get_temp_dir()
|
||||
{
|
||||
static const std::string s_dir = []
|
||||
{
|
||||
std::string dir;
|
||||
|
||||
#ifdef _WIN32
|
||||
wchar_t buf[MAX_PATH + 2]{};
|
||||
if (GetTempPathW(MAX_PATH + 1, buf) - 1 > MAX_PATH)
|
||||
{
|
||||
MessageBoxA(nullptr, fmt::format("GetTempPath() failed: error %u.", GetLastError()).c_str(), "fs::get_temp_dir()", MB_ICONERROR);
|
||||
return dir; // empty
|
||||
}
|
||||
|
||||
to_utf8(dir, buf);
|
||||
#else
|
||||
// TODO
|
||||
dir = get_cache_dir();
|
||||
#endif
|
||||
|
||||
return dir;
|
||||
}();
|
||||
|
||||
return s_dir;
|
||||
}
|
||||
|
||||
bool fs::remove_all(const std::string& path, bool remove_root)
|
||||
{
|
||||
if (const auto root_dir = dir(path))
|
||||
|
@ -636,6 +636,9 @@ namespace fs
|
||||
// Get common cache directory
|
||||
const std::string& get_cache_dir();
|
||||
|
||||
// Temporary directory
|
||||
const std::string& get_temp_dir();
|
||||
|
||||
// Unique pending file creation destined to be renamed to the destination file
|
||||
struct pending_file
|
||||
{
|
||||
|
@ -1128,7 +1128,7 @@ namespace vm
|
||||
if (flags & page_size_4k || flags & preallocated)
|
||||
{
|
||||
// Special path for whole-allocated areas allowing 4k granularity
|
||||
m_common = std::make_shared<utils::shm>(size, fs::get_cache_dir() + std::to_string(utils::get_unique_tsc()));
|
||||
m_common = std::make_shared<utils::shm>(size);
|
||||
m_common->map_critical(vm::base(addr), utils::protection::no);
|
||||
m_common->map_critical(vm::get_super_ptr(addr));
|
||||
}
|
||||
@ -1632,7 +1632,7 @@ namespace vm
|
||||
|
||||
inline namespace ps3_
|
||||
{
|
||||
static utils::shm s_hook{0x800000000, fs::get_cache_dir() + "hook.dat"};
|
||||
static utils::shm s_hook{0x800000000, fmt::format("%s/rpcs3_vm_hook_%s", fs::get_temp_dir(), fmt::base57(utils::get_unique_tsc()))};
|
||||
|
||||
void init()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user