note 55988 added to class.com
| From: | jbr at ya-right dot com | Date: | Fri, 19 Aug 2005 20:07:17 +0000 |
| Subject: | note 55988 added to class.com | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93926@lists.php.net to get a copy of this message | ||
Getting * directory * permissions ( attributes ) with COM
PHP (5) example...
<?
$dir = 'e:/www/docs/www/docs/junk/';
define ( 'READ_ONLY', 1 );
define ( 'IS_HIDDEN', 2 );
define ( 'IS_SYSTEM', 4 );
$hold = array ();
$obj = new COM ( 'scripting.filesystemobject' );
if ( is_object ( $obj ) )
{
$all = $obj->getfolder ( $dir );
foreach ( $all->subfolders AS $directory )
{
if ( substr ( $directory->name, - 3 ) != 'cnf' )
{
$hold[$dir . $directory->name . '/'] = array ( 'read_only' => ( (
$directory->Attributes & READ_ONLY ) <> 0 ? 1 : 0 ), 'is_hidden' => ( (
$directory->Attributes & IS_HIDDEN ) <> 0 ? 1 : 0 ), 'is_system' => ( (
$directory->Attributes & IS_SYSTEM ) <> 0 ? 1 : 0 ) );
}
}
$obj = null;
}
else
{
echo 'sorry can not crate object: file_system_object';
}
print_r ( $hold );
?>
To do the same thing for * files * with in the directory named in $dir, change above ( foreach() )
to what is below...
foreach ( $all->files AS $file )
{
$hold[$file->name] = array ( 'read_only' => ( ( $file->Attributes &
READ_ONLY ) <> 0 ? 1 : 0 ), 'is_hidden' => ( ( $file->Attributes &
IS_HIDDEN ) <> 0 ? 1 : 0 ), 'is_system' => ( ( $file->Attributes &
IS_SYSTEM ) <> 0 ? 1 : 0 ) );
}
pretty much anything you could think of doing in windows can be done using PHP and COM...
John
----
Manual Page -- http://www.php.net/manual/en/class.com.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55988
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55988&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55988&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55988&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55988&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55988&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55988&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55988&report=yes
Search -- http://master.php.net/manage/user-notes.php