Summary
When building with the raylib PhysFS platform layer (PHYSFS_PLATFORM_RAYLIB / CMake option RAYLIB_PHYSFS_PLATFORM_RAYLIB), __PHYSFS_platformCalcPrefDir() builds the pref directory path but never creates the directory on disk. PhysFS's real platform backends (e.g. the POSIX and Windows implementations in physfs) create the org/app directories as part of PHYSFS_getPrefDir(). As a result, under the raylib platform, GetPrefDirectory("org", "app") returns a path like <application dir>/org/app/ that does not exist, so any subsequent SetPhysFSWriteDirectory() / file write into it fails.
Where
physfs_platform_raylib.c, __PHYSFS_platformCalcPrefDir() (around line 102): it allocates and formats base + org + "/" + app + "/" and returns it, with no MakeDirectory() calls. Compare with __PHYSFS_platformMkDir() in the same file (around line 150), which already wraps raylib's MakeDirectory().
Suggested Implementation
- In
__PHYSFS_platformCalcPrefDir(), after building the path, create the intermediate org directory and then the full org/app directory using raylib's MakeDirectory() (which succeeds if the directory already exists — but verify that; if it errors on existing dirs, guard with DirectoryExists() first).
- On creation failure, set
PHYSFS_setErrorCode(PHYSFS_ERR_OS_ERROR), free the buffer, and return NULL, matching PhysFS platform contract.
- Keep the trailing
/ on the returned path (PhysFS requires it).
QA
- With
RAYLIB_PHYSFS_PLATFORM_RAYLIB=ON, GetPrefDirectory("RobLoach", "raylib-physfs-test") returns a non-NULL path and DirectoryExists() on it is true.
SetPhysFSWriteDirectory(GetPrefDirectory(...)) followed by SaveFileTextToPhysFS() succeeds under the raylib platform.
- Existing test suite still passes with the platform layer both ON and OFF.
Context
Summary
When building with the raylib PhysFS platform layer (
PHYSFS_PLATFORM_RAYLIB/ CMake optionRAYLIB_PHYSFS_PLATFORM_RAYLIB),__PHYSFS_platformCalcPrefDir()builds the pref directory path but never creates the directory on disk. PhysFS's real platform backends (e.g. the POSIX and Windows implementations in physfs) create the org/app directories as part ofPHYSFS_getPrefDir(). As a result, under the raylib platform,GetPrefDirectory("org", "app")returns a path like<application dir>/org/app/that does not exist, so any subsequentSetPhysFSWriteDirectory()/ file write into it fails.Where
physfs_platform_raylib.c,__PHYSFS_platformCalcPrefDir()(around line 102): it allocates and formatsbase + org + "/" + app + "/"and returns it, with noMakeDirectory()calls. Compare with__PHYSFS_platformMkDir()in the same file (around line 150), which already wraps raylib'sMakeDirectory().Suggested Implementation
__PHYSFS_platformCalcPrefDir(), after building the path, create the intermediateorgdirectory and then the fullorg/appdirectory using raylib'sMakeDirectory()(which succeeds if the directory already exists — but verify that; if it errors on existing dirs, guard withDirectoryExists()first).PHYSFS_setErrorCode(PHYSFS_ERR_OS_ERROR), free the buffer, and returnNULL, matching PhysFS platform contract./on the returned path (PhysFS requires it).QA
RAYLIB_PHYSFS_PLATFORM_RAYLIB=ON,GetPrefDirectory("RobLoach", "raylib-physfs-test")returns a non-NULL path andDirectoryExists()on it is true.SetPhysFSWriteDirectory(GetPrefDirectory(...))followed bySaveFileTextToPhysFS()succeeds under the raylib platform.Context
physfs_platform_raylib.c(added in Docs: document PHYSFS_PLATFORM_RAYLIB limitations #46); the "No real user/pref directory" note there covers the location fallback, not this missing-creation defect.