Skip to content

Platform: pref directory is never created on disk #56

Description

@RobLoach

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions