mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 02:00:41 +00:00
Move roms copied to localstate to a dedicated dir and clear on start up [XBOX/UWP] (#13392)
* make roms copy to a specific cache dir in the localstate folder when its copied * auto delete vfs cache dir on start up Co-authored-by: Tunip3 <tunip3@users.noreply.github.com>
This commit is contained in:
parent
eff6f41a38
commit
fb6bf6023a
@ -1053,8 +1053,6 @@ static bool content_file_load(
|
|||||||
// I am genuinely really proud of these work arounds
|
// I am genuinely really proud of these work arounds
|
||||||
wchar_t wcontent_path[MAX_PATH];
|
wchar_t wcontent_path[MAX_PATH];
|
||||||
mbstowcs(wcontent_path, content_path, MAX_PATH);
|
mbstowcs(wcontent_path, content_path, MAX_PATH);
|
||||||
wchar_t wuwp_dir_data[MAX_PATH];
|
|
||||||
mbstowcs(wuwp_dir_data, uwp_dir_data, MAX_PATH);
|
|
||||||
uwp_set_acl(wcontent_path, L"S-1-15-2-1");
|
uwp_set_acl(wcontent_path, L"S-1-15-2-1");
|
||||||
if (!is_path_accessible_using_standard_io(content_path))
|
if (!is_path_accessible_using_standard_io(content_path))
|
||||||
{
|
{
|
||||||
@ -1080,6 +1078,15 @@ static bool content_file_load(
|
|||||||
"but cache directory was not set or found. "
|
"but cache directory was not set or found. "
|
||||||
"Setting cache directory to root of writable app directory...\n");
|
"Setting cache directory to root of writable app directory...\n");
|
||||||
strlcpy(new_basedir, uwp_dir_data, sizeof(new_basedir));
|
strlcpy(new_basedir, uwp_dir_data, sizeof(new_basedir));
|
||||||
|
strcat(new_basedir, "VFSCACHE\\");
|
||||||
|
DWORD dwAttrib = GetFileAttributes(new_basedir);
|
||||||
|
if ((dwAttrib == INVALID_FILE_ATTRIBUTES) || (!(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)))
|
||||||
|
{
|
||||||
|
if (!CreateDirectoryA(new_basedir, NULL))
|
||||||
|
{
|
||||||
|
strlcpy(new_basedir, uwp_dir_data, sizeof(new_basedir));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fill_pathname_join(new_path, new_basedir,
|
fill_pathname_join(new_path, new_basedir,
|
||||||
path_basename(content_path), sizeof(new_path));
|
path_basename(content_path), sizeof(new_path));
|
||||||
|
@ -50,6 +50,7 @@ using namespace Windows::Foundation;
|
|||||||
using namespace Windows::Foundation::Collections;
|
using namespace Windows::Foundation::Collections;
|
||||||
using namespace Windows::Graphics::Display;
|
using namespace Windows::Graphics::Display;
|
||||||
using namespace Windows::Devices::Enumeration;
|
using namespace Windows::Devices::Enumeration;
|
||||||
|
using namespace Windows::Storage;
|
||||||
|
|
||||||
char uwp_dir_install[PATH_MAX_LENGTH] = { 0 };
|
char uwp_dir_install[PATH_MAX_LENGTH] = { 0 };
|
||||||
char uwp_dir_data[PATH_MAX_LENGTH] = { 0 };
|
char uwp_dir_data[PATH_MAX_LENGTH] = { 0 };
|
||||||
@ -217,6 +218,21 @@ int main(Platform::Array<Platform::String^>^)
|
|||||||
Platform::String^ data_dir = Windows::Storage::ApplicationData::Current->LocalFolder->Path + L"\\";
|
Platform::String^ data_dir = Windows::Storage::ApplicationData::Current->LocalFolder->Path + L"\\";
|
||||||
wcstombs(uwp_dir_data, data_dir->Data(), sizeof(uwp_dir_data));
|
wcstombs(uwp_dir_data, data_dir->Data(), sizeof(uwp_dir_data));
|
||||||
|
|
||||||
|
|
||||||
|
// delete vfs cache dir, we do this because this allows a far far more consise implementation than manually implementing a function to do this
|
||||||
|
// this may be a little slower but shouldn't really matter as the cache dir should never have more than a few items
|
||||||
|
Platform::String^ vfs_dir = Windows::Storage::ApplicationData::Current->LocalFolder->Path + L"\\VFSCACHE";
|
||||||
|
char vfs_cache_dir[MAX_PATH];
|
||||||
|
wcstombs(vfs_cache_dir, vfs_dir->Data(), sizeof(vfs_cache_dir));
|
||||||
|
DWORD dwAttrib = GetFileAttributesA(vfs_cache_dir);
|
||||||
|
if ((dwAttrib != INVALID_FILE_ATTRIBUTES) && (dwAttrib & FILE_ATTRIBUTE_DIRECTORY))
|
||||||
|
{
|
||||||
|
concurrency::task<StorageFolder^> vfsdirtask = concurrency::create_task(StorageFolder::GetFolderFromPathAsync(vfs_dir));
|
||||||
|
vfsdirtask.wait();
|
||||||
|
StorageFolder^ vfsdir = vfsdirtask.get();
|
||||||
|
vfsdir->DeleteAsync();
|
||||||
|
}
|
||||||
|
|
||||||
wcstombs(uwp_device_family,
|
wcstombs(uwp_device_family,
|
||||||
AnalyticsInfo::VersionInfo->DeviceFamily->Data(),
|
AnalyticsInfo::VersionInfo->DeviceFamily->Data(),
|
||||||
sizeof(uwp_device_family));
|
sizeof(uwp_device_family));
|
||||||
|
Loading…
Reference in New Issue
Block a user