[physfs] Making PHYSFS_FILETYPE_* a bitmask

Indy Sams indy at driftsolutions.com
Tue May 1 18:16:15 EDT 2012

Hello Ryan,

	Probably a combination of the two would be good (filetype and PHYSFS_readlink). Either way they could get into an infinite loop if there is a symlink pointed to a symlink unfortunately.

	It looks like in the current Mercurial root the only archiver that actually will return PHYSFS_FILETYPE_SYMLINK is the ZIP archiver. The POSIX __PHYSFS_platformStat() uses lstat(), but doesn't check S_ISLNK() so it would be returning PHYSFS_FILETYPE_OTHER instead of PHYSFS_FILETYPE_SYMLINK currently (in theory, haven't tested it).

	At this point, my current thoughts would be (just for the simplicity of use for users):

	If you PHYSFS_stat() a symlink, it would do one of the following:
		1. If symlinks are disabled with PHYSFS_permitSymbolicLinks, returns error that the file doesn't exist. This matches the current PHYSFS_stat() documentation.
		2. Or, returns the information on the linked file (ie. an additional stat() after the lstat() with PHYSFS_FILETYPE_SYMLINK |'ed to the filetype).

	It seems like this would work well and be simple for people to use without having to worry much about symlinks if they don't need the nitty gritty.
Tuesday, May 1, 2012, 5:22:51 PM, you wrote:

>> So in the case a symlink that points to a file filetype would be set to

RCG> The original intention was to match what most OSes do: you get the entry 
RCG> from the filesystem, and if you want to resolve the symlink it reports, 
RCG> you have to do more filesystem accesses.

RCG> However: what do we set this to if the symlink is pointing to another 
RCG> symlink? If we resolve all the symlinks, what do we set this to if the 
RCG> final symlink points back to the first, causing an infinite loop? What 
RCG> do we set this to if it's not pointing to anything at all?

RCG> Granted, we don't offer a PHYSFS_readlink() API to report to the app 
RCG> what a symlink points to, and we probably should.

RCG> --ryan.

RCG> _______________________________________________
RCG> physfs mailing list
RCG> physfs at icculus.org
RCG> http://icculus.org/mailman/listinfo/physfs

Best regards,
 Indy Sams
 mailto:indy at driftsolutions.com

More information about the physfs mailing list