Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vm_native.cpp: change rpcs3_vm name/location priority (Win32) #10442

Merged
merged 1 commit into from Jun 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 20 additions & 3 deletions rpcs3/util/vm_native.cpp
Expand Up @@ -341,6 +341,13 @@ namespace utils
FILE_BASIC_INFO info0{};
ensure(GetFileInformationByHandleEx(h, FileBasicInfo, &info0, sizeof(info0)));

if ((info0.FileAttributes & FILE_ATTRIBUTE_ARCHIVE) || (~info0.FileAttributes & FILE_ATTRIBUTE_TEMPORARY))
{
info0.FileAttributes &= ~FILE_ATTRIBUTE_ARCHIVE;
info0.FileAttributes |= FILE_ATTRIBUTE_TEMPORARY;
ensure(SetFileInformationByHandle(h, FileBasicInfo, &info0, sizeof(info0)));
}

if ((info0.FileAttributes & FILE_ATTRIBUTE_SPARSE_FILE) == 0 && version_major <= 7)
{
MessageBoxW(0, L"RPCS3 needs to be restarted to create sparse file rpcs3_vm.", L"RPCS3", MB_ICONEXCLAMATION);
Expand Down Expand Up @@ -384,20 +391,30 @@ namespace utils
return false;
};

const std::string storage2 = fs::get_temp_dir() + "rpcs3_vm_sparse.tmp";
const std::string storage3 = fs::get_cache_dir() + "rpcs3_vm_sparse.tmp";

if (!storage.empty())
{
// Explicitly specified storage
ensure(f.open(storage, fs::read + fs::write + fs::create));
}
else if (!f.open(fs::get_cache_dir() + "rpcs3_vm", fs::read + fs::write + fs::create) || !set_sparse(f.get_handle(), m_size))
else if (!f.open(storage2, fs::read + fs::write + fs::create) || !set_sparse(f.get_handle(), m_size))
{
// Fallback storage
ensure(f.open(storage3, fs::read + fs::write + fs::create));
}
else
{
ensure(f.open(fs::get_temp_dir() + "rpcs3_vm", fs::read + fs::write + fs::create));
goto check;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the go-to. Can't you just add a bool instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like neither, need to refactor this crap anyway to search for various locations where temp file could be placed.


if (!set_sparse(f.get_handle(), m_size))
{
MessageBoxW(0, L"Failed to initialize sparse file.", L"RPCS3", MB_ICONERROR);
MessageBoxW(0, L"Failed to initialize sparse file.\nCan't find a filesystem with sparse file support (NTFS).", L"RPCS3", MB_ICONERROR);
}

check:
if (f.size() != m_size)
{
// Resize the file gradually (bug workaround)
Expand Down