[physfs] Question regarding PHYSFS_getRealDir and PHYSFS_isDirectory

Indy Sams indy at driftsolutions.com
Sun Feb 28 23:57:52 EST 2010

Hello Eric,

	One thing I notice is you aren't including the directory in your call to PHYSFS_isDirectory in get_dir_listing().

	For example, you are using:
	instead of:

	The 2nd version should give you the results you are looking for.

Sunday, February 28, 2010, 11:14:14 PM, you wrote:

ES> PHYSFS_getRealDir:
ES> I understand that calling this with a fake directory will result
ES> in returning the first archive mounted to the fake directory's
ES> location. My question is if I've mounted a real directory as a
ES> fake VFS directory, like mounting /home/user to VFS:/myusr, why
ES> shouldn't it return the real directory of /myusr as /home/usr? If
ES> I create a file inside /myuser, the file is real and not just in the VFS.

ES> PHYSFS_isDirectory:
ES> Using the /myuser example above, if I call this on /myuser I get
ES> a list of nothing but files, instead of a mix of files and
ES> directories as I would expect. Even if this was a fake directory
ES> instead of a real file system I would think that directories would
ES> show up correctly. Is this the correct behavior?

ES> This is all using 2.0 stable. Here's some test code and the
ES> output, in case I'm just being thick - nothing new  

ES> #include "physfs.h"
ES> #include <stdio.h>

ES> void get_dir_listing(const char* path)
ES> {
ES>   char** rc;
ES>   char** i;
ES>   rc = PHYSFS_enumerateFiles(path);
ES>   for (i = rc; *i != NULL; i++)
ES>   {
ES>      if (PHYSFS_isDirectory(*i))
ES>         printf("Directory [%s]\n", *i);
ES>      else
ES>         printf("File      [%s]\n", *i);
ES>   }
ES>   PHYSFS_freeList(rc);
ES> }

ES> int main(int argc, char** argv)
ES> {
ES>   PHYSFS_init(argv[0]);
ES>   PHYSFS_mount("/home/estevens/games/tome3", NULL, 0);
ES>   PHYSFS_mount("/home/estevens/.t-engine/3.0", "/userdir", 1);
ES>   printf("\nreal dir of /userdir/log: %s\n",
ES> PHYSFS_getRealDir("/userdir/log"));

ES>   printf("\nContents of '/'\n");
ES>   get_dir_listing("/");

ES>   printf("\nContents of '/userdir'\n");
ES>   get_dir_listing("/userdir");
ES>   PHYSFS_deinit();
ES>   return 0;
ES> }

ES> The output:
ES> real dir of /userdir/log: /home/estevens/.t-engine/3.0

ES> Contents of '/'
ES> Directory [game]
ES> Directory [game.mod1]
ES> File      [tome.cfg]
ES> File      [tree.txt]
ES> Directory [userdir]

ES> Contents of '/userdir' (all are directories)
ES> File      [log]
ES> File      [modules]
ES> File      [settings]
ES> File      [tmp]

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

 P.S. This is what part of the alphabet would look like if Q & R were eliminated.

More information about the physfs mailing list