Bug #11062 Updated: Sharing Violation Error Message
| From: | rkenny at mke dot catalystwms dot com | Date: | Thu, 28 Jun 2001 11:58:57 +0000 |
| Subject: | Bug #11062 Updated: Sharing Violation Error Message | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-58318@lists.php.net to get a copy of this message | ||
ID: 11062
User Update by: rkenny@mke.catalystwms.com
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] sniper@php.net
Does this happen with PHP 4.0.6 ?
---------------------------------------------------------------------------
[2001-06-04 01:27:47] rkenny@mke.catalystwms.com
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] rkenny@mke.catalystwms.com
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:
<?php
// $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", etc.
function list_dir($hddir, $mode, $order) {
$webdir = "http://www.foo.com" .
str_replace("/inetpub/www_root", "", $hddir);
$handle = opendir($hddir);
chdir($hddir);
// if there are files in the directory, print out the table header and set the flag
// once we find a file, don't run the test (and print out the table header) again
while (($file = readdir($handle)) && ($file_count < 1)) {
if ($file == '.' || $file== '..')
continue;
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== '..')
continue;
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 = prev($parts);
if (($extension == "doc") || ($extension == "DOC") || ($extension ==
"rtf"))
echo "<tr><td><img src="/pics/icons/word_sm.gif"
width="20" height="19"></td>";
else
echo "<tr><td><img src="/pics/spacer.gif" width="20"
height="19"></td>";
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 array,
// 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 ("..");
closedir($handle);
}
?>
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=11062