note 68679 added to function.is-dir
| From: | locataweb at hotmail dot com | Date: | Sun, 06 Aug 2006 22:59:58 +0000 |
| Subject: | note 68679 added to function.is-dir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115599@lists.php.net to get a copy of this message | ||
NOTE on Windows Shares (based on tests using PHP 5.1.1):
After many hours of head scratching and wondering why a script worked sometimes but not others, I
discovered this revelation.
Be aware that base Windows shares are not recognised as dirs, so the following test will return
false even if \\COMPUTER_NAME\SHARENAME exists.
<?php
if (is_dir('\\\\COMPUTER_NAME\\SHARENAME')) {
echo "TRUE\n";
}
else {
echo "FALSE\n";
}
//will return FALSE;
// However testing a subdir of the same base share
// using test below will return TRUE,
// despite the fact the parent base Windows share
// returns false when tested by is_dir()
is_dir('\\\\COMPUTER_NAME\\SHARENAME\\SUBDIR') {
echo "TRUE\n";
} else {
echo "FALSE\n";
}
//will return TRUE.
?>
As a work round I replaced is_dir with is_readable() instead, which identifies if the share is
readable and so must exist, but this is clearly dependent on whether the share is readable.
I hope this helps someone. If there is a better work round or other purpose built solution to this
problem with base windows shares, please post them so I'll know the next time.
----
Server IP: 83.138.144.80
Probable Submitter: 84.92.85.167
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.is-dir.php
Edit -- https://master.php.net/note/edit/68679
Del: integrated -- https://master.php.net/note/delete/68679/integrated
Del: useless -- https://master.php.net/note/delete/68679/useless
Del: bad code -- https://master.php.net/note/delete/68679/bad+code
Del: spam -- https://master.php.net/note/delete/68679/spam
Del: non-english -- https://master.php.net/note/delete/68679/non-english
Del: in docs -- https://master.php.net/note/delete/68679/in+docs
Del: other reasons-- https://master.php.net/note/delete/68679
Reject -- https://master.php.net/note/reject/68679
Search -- https://master.php.net/manage/user-notes.php