note 55988 deleted from class.com by cmb
| From: | cmb@php.net | Date: | Tue, 05 Nov 2019 09:37:22 +0000 |
| Subject: | note 55988 deleted from class.com by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212899@lists.php.net to get a copy of this message | ||
Note Submitter: jbr at ya-right dot com
----
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