ForceDirectories (sysutils) failing in Windows Apps context
Summary
When distributing an app through the Microsoft Store (according to search results about the general issue on the internet, might be specific to games on the Windows Xbox Live eco system) the ForceDirectories method always fails.
That function starts with this check:
ADrv:=ExtractFileDrive(Dir);
if (ADrv<>'') and (not DirectoryExists(ADrv)) and (not IsUncDrive(ADrv)) then
Exit;
So it will always first check if the given path starts with a drive name (like "C:") and test the existence of that directory. Unfortunately apps on the store do not have the permission to access the whole file system and thus the check always fails, exiting the whole function early.
System Information
- Operating system: Windows, program shipped as part of a game through Xbox Live / MS Store
- Processor architecture: x86-64
- Compiler version: 3.2.2
- Device: Computer
Steps to reproduce
Have a program distributed through MS Store with default permissions. Call ForceDirectories with any path, our use case is "C:\Users\someuser\AppData\Roaming\ProgramName".
Example Project
If that helps I can give individual people access to our testing sandbox of the game to run the program, unfortunately you won't be able to access its files due to MS restrictions.
What is the current bug behavior?
ForceDirectories will always fail.
What is the expected (correct) behavior?
ForceDirectories works as it would with other paths.
Relevant logs and/or screenshots
None
Possible fixes
Source File: sysutils/disk.inc
I made a copy of the function that skips the check and it works fine for us as we guarantee to pass a regular path. DirectoryExists also works fine in the inner function to test for the game folder and the parent Roaming folder. I am not sure what paths must be accepted by ForceDirectories though which might require the check in question.