icculus / physfs

A portable, flexible file i/o abstraction.
https://icculus.org/physfs/
zlib License
559 stars 98 forks source link

PHYSFS_mkdir / doMkdir fails to create folder on iOS #47

Closed stribor closed 2 years ago

stribor commented 2 years ago

PHYSFS_mkdir is called to create path in Application Support folder

Path passed is like "/var/mobile/Containers/Data/Application/A493CCAC-6FEE-434B-A5D4-1131850578C1/Library/Application Support/savegame".

I traced the problem to the doMkdir https://github.com/icculus/physfs/blob/main/src/physfs.c#L2237

It exits loop at first iteration because statbuf.filetype is PHYSFS_FILETYPE_SYMLINK for /var.

Not sure what the correct fix would be. Maybe to call stat with path ending with / like /var/ in this case statbuf.filetype is set correctly toPHYSFS_FILETYPE_DIRECTORY and rest works.

Also, (statbuf.filetype == PHYSFS_FILETYPE_DIRECTORY || statbuf.filetype == PHYSFS_FILETYPE_SYMLINK) can work around the problem in this case and the folder gets created at the end.