[physfs] Mounting files & CD checking

Ryan C. Gordon icculus at icculus.org
Mon Jul 6 16:06:32 EDT 2009

> I mean, can I use it from a different thread to create a "non-blocking" 
> listing - so that the program doesn't get blocked while the CD unit spins up

GetCdRomDirs() doesn't hold a mutex, and it _should_ be thread safe, 
presuming the OS-specific APIs are, as well...so it probably won't block.

I can't say with certainty, but I'm pretty sure most platforms don't 
access the CD-ROM during this call...at least Linux, Mac OS X, and 
Windows already know what discs are mounted, and provide this 
information to the application without having to go back to the hardware.

I suppose that Windows _might_ block if you put a disc in the drive at 
the exact moment you called getCdRomDirs(), but I think that's probably 
acceptable to the end-user. It shouldn't block when the drive definitely 
does or does not have a disc, though, as Windows spun it up already 
before you asked. Mac OS X and Linux should be safe at any rate.


More information about the physfs mailing list