Recognizing the root dir in PHP
<p>I'm writing a PHP function that will delete all the files in the directory that's passed to it (and eventually, possibly expand it to a recursive delete).  To be safe, I want to make sure that, through a bug or something, I don't try to delete anything if the directory passed in is the root directory.</p>

<p>File permissions should protect me to a large extent, but just in case, and especially if I expand it to a recursive delete I just want to take that extra step.</p>

<p>As a complicating factor, this code may be run in a windows machine or a linux machine, so the root directory may look like 'C:\' or '/'.  I assume there are other ways that really refer to the root as well, possibly 'c:\temp..'</p>

<p>So, is there a reliable way in PHP to recognize that a dir spec resolves to the root of the file system?</p>

<p>Elaboration...</p>

<p>I'm writing PHPUnit tests for a web app and I'm trying to create a framework where the state of the app is backed up before the tests are run and restored afterwards.  The app allows users to upload files.  Depending on what the file is it is copied to one of several possible directories.</p>

<p>To save and restore the state of the app those directories need to be copied somewhere, the tests run, then the directories need to have their files deleted and retreived from the backup.</p>

<p>The location of these directories can vary from one machine to another and I know that some people put them outside of the web app.  There is a configuration file that can be read by the test that gives the location of those directories for the given machine.</p>

<p>If I don't restrict all these directories to a specific dir tree it's difficult to do the jailing.  If I do restrict these directories to a specific dir tree then some people will have to reconfigure their machines.</p>
