mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 11:36:13 +00:00
[Win32] Allow renaming uppercase RAP/EDAT to lowercase with drag-and-drop from /exdata
This commit is contained in:
parent
962e140cea
commit
9ba9d9424e
1 changed files with 16 additions and 4 deletions
|
@ -527,15 +527,15 @@ void main_window::BootRsxCapture(std::string path)
|
|||
|
||||
bool main_window::InstallFileInExData(const std::string& extension, const QString& path, const std::string& filename)
|
||||
{
|
||||
if (path.isEmpty() || filename.empty())
|
||||
if (path.isEmpty() || filename.empty() || extension.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Copy file atomically with thread/process-safe error checking for file size
|
||||
|
||||
fs::pending_file to(rpcs3::utils::get_hdd0_dir() + "/home/" + Emu.GetUsr() + "/exdata/" + filename.substr(0, filename.find_last_of('.')) + "." + extension);
|
||||
const fs::file from(sstr(path));
|
||||
const std::string to_path = rpcs3::utils::get_hdd0_dir() + "/home/" + Emu.GetUsr() + "/exdata/" + filename.substr(0, filename.find_last_of('.'));
|
||||
fs::pending_file to(to_path + "." + extension);
|
||||
fs::file from(sstr(path));
|
||||
|
||||
if (!to.file || !from)
|
||||
{
|
||||
|
@ -543,6 +543,7 @@ bool main_window::InstallFileInExData(const std::string& extension, const QStrin
|
|||
}
|
||||
|
||||
to.file.write(from.to_vector<u8>());
|
||||
from.close();
|
||||
|
||||
if (to.file.size() < 0x10)
|
||||
{
|
||||
|
@ -550,6 +551,17 @@ bool main_window::InstallFileInExData(const std::string& extension, const QStrin
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// In the case of an unexpected crash during the operation, the temporary file can be used as the deleted file
|
||||
// See below
|
||||
to.file.sync();
|
||||
|
||||
// In case we want to rename upper-case file to lower-case
|
||||
// Windows will ignore such rename operation if the file exists
|
||||
// So delete it
|
||||
fs::remove_file(to_path + "." + fmt::to_upper(extension));
|
||||
#endif
|
||||
|
||||
return to.commit();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue