ID: 11062
User Update by: [EMAIL PROTECTED]
Old-Status: Feedback
Status: Open
Bug Type: Directory function related
Operating system: NT 4.0 SP6a
PHP Version: 4.0.5
Description: Sharing Violation Error Message

Yes it does.  :(   Does the folder need to have special permissions?  Right now I've 
got SYSTEM and CREATOR_OWNER with full controll, and a bunch of groups.

Previous Comments:

[2001-06-23 20:58:38] [EMAIL PROTECTED]
Does this happen with PHP 4.0.6 ?


[2001-06-04 01:27:47] [EMAIL PROTECTED]
In order to regain control over the directories, it is necessary to restart the entire 
"IIS Admin Service".  Restarting the "World Wide Web Publishing Service" alone does 
not fix the problem.


[2001-05-23 14:34:47] [EMAIL PROTECTED]
Hello, I've written a simple script which can recurse into subdirectories when needed, 
and print out an HTML table with with details about the files it finds.  The problem 
is that after I run this script, if I try and rename one of the folders it has 
recursed into, I get an error message which reads:

"Cannot rename [folder name]:  There has been a sharing violation.  The source or 
destination file may be in use."

Note that I can still rename files, just not folders.  If I stop and start IIS, I am 
able to rename folders until I run the script again.  I believe I'm using the 
closedir() function correctly, and have even echoed out when the directories are 
opened and closed to make sure I'm not messing up.  One last thing to note is that 
this script is being run on an NTFS partition.  A copy of the script follows:


// $hddir is the hard drive directory passed into this function from the calling page
// $mode can be either "single" or "recurse"
// $order is just ignored right now, but I would like it to be "alphabetical", "size", 

function list_dir($hddir, $mode, $order) {
        $webdir = ""; . str_replace("/inetpub/www_root", "", $hddir);
        $handle = opendir($hddir);

        // if there are files in the directory, print out the table header and set the 
        // once we find a file, don't run the test (and print out the table header) 
        while (($file = readdir($handle)) && ($file_count < 1)) {
                if ($file == '.' || $file== '..') 
                else if (is_file($file)) {
                        echo "<table border="0" cellpadding="2" cellspacing="2">";
                        echo "<tr><th></th><th class="high">Filename</th>";
                        echo "<th class="high">Size</th>";
                        echo "<th class="high">Modified</th></tr>";
                        $file_count += 1;

        rewinddir ($handle);                                    // start reading again 
from the beginning of the directory
        while ($file = readdir($handle)) {              // while we can read an entry 
from the directory (files and dirs)
                if ($file == '.' || $file== '..') 

                else if (($mode == "recurse") && (is_dir($file)) && (substr("$file", 
0, 1) != "_")) {   // don't recurse directories which begin with an underscore
                        $dir_count += 1;
                        $places_to_go[$dir_count] = "$file";

                else if (is_file($file)) {
                        $extension = ''; 
                        $parts = split('.', $file); 
                        if (count($parts) > 1) $extension = end($parts); 
                        if (!$extension && count($parts) > 2) $extension = 
                        if (($extension == "doc") || ($extension == "DOC") || 
($extension == "rtf"))
                                echo "<tr><td><img src="/pics/icons/word_sm.gif" 
width="20" height="19"></td>";
                                echo "<tr><td><img src="/pics/spacer.gif" width="20" 
                        echo "<td bgcolor="silver"><a href="" . $webdir . "/" . $file 
. "" target="_blank">" . $file . "</a></td>"; 
                        $j = 0; 
                        $ext = array(" Bytes", " KB", " MB", " GB", " TB"); 
                        $file_size = filesize($file); 
                        while ($file_size >= pow(1024,$j)) ++$j; 
                                $file_size = round($file_size / pow(1024,$j-1) * 100) 
/ 100 . $ext[$j-1];
                        echo "<td bgcolor="silver">" . $file_size .  "</td>";
                        $filemod = filemtime($file); 
                        $file_modtime = date("F j Y h:i:s A", $filemod); 
                        echo "<td bgcolor="silver">" . $file_modtime .  "</td></tr>";
        }       // end while we're reading files from the directory

        // if we printed out a table, header (and contents) we should cap it off
        if ($file_count >= 1)
                echo "</table>";

        // if there are other directories to recurse into that were stored in our 
        // print out the name of the directory, and call this function with the new 
directory name.
        if ($dir_count >= 1) {
                for ($x=1; $x<=$dir_count; $x++) {
                        echo "<h4>$places_to_go[$x]</h4>";
                        echo "<dir>";
                        $newdir = "$hddir" . "/$places_to_go[$x]";
                        list_dir($newdir, "recurse", "alpha");
                        echo "</dir>";

        chdir ("..");



Full Bug description available at:

PHP Development Mailing List <>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to