当前位置: 首页>>代码示例>>PHP>>正文


PHP COM::GetFolder方法代码示例

本文整理汇总了PHP中COM::GetFolder方法的典型用法代码示例。如果您正苦于以下问题:PHP COM::GetFolder方法的具体用法?PHP COM::GetFolder怎么用?PHP COM::GetFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在COM的用法示例。


在下文中一共展示了COM::GetFolder方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadDir

function loadDir($dir)
{
    global $SKIP_FOLDERS;
    $dirContent = array();
    // Dir content
    $dirContent['SIZE'] = 0;
    // Initialize structure
    $dirContent['DIRS'] = array();
    $dirContent['FILES'] = array();
    $fsobj = new COM('Scripting.FileSystemObject', null, CP_UTF8);
    // Requires extension=php_com_dotnet.dll
    try {
        // Try to write on the page
        $folderObj = $fsobj->GetFolder($dir);
    } catch (Exception $e) {
        // Some wiki error
        printLogAndDie("Error loading folder " . $dir . ": " . $e->getMessage());
    }
    foreach ($folderObj->Files as $fileObj) {
        // Check files in dir
        $dirContent['FILES'][$fileObj->Name] = $fileObj->Size;
        // Store file and it's size
        $dirContent['SIZE'] += $fileObj->Size;
        // Add file's size to total size
    }
    foreach ($folderObj->SubFolders as $subFolderObj) {
        // Check subdirectories
        if (in_array($subFolderObj->Name, $SKIP_FOLDERS)) {
            // Skip this folder
            continue;
        }
        $dirContent['DIRS'][$subFolderObj->Name] = array();
        // Init new dir structure
        $subDirContent = loadDir($dir . '/' . $subFolderObj->Name);
        // Load subdir data
        $dirContent['DIRS'][$subFolderObj->Name] = $subDirContent;
        // Store subdir data
        $dirContent['SIZE'] += $subDirContent['SIZE'];
        // Add subdir size to total size
    }
    return $dirContent;
    // Return Dir content
}
开发者ID:neocodesoftware,项目名称:Neocode-WikiBot,代码行数:43,代码来源:updatepage.php

示例2: _refreshLocalWindows

 protected function _refreshLocalWindows($myrole, $drivers)
 {
     $job = $this->_out->jobStart("traversing file system starting at {$this->_baseDir} using COM");
     //let create context for our closure
     /** @var $compare Compare_Interface */
     $compare = $drivers[Core_Engine::ROLE_COMPARE];
     $stat = $this->_fileStat;
     $baseDir = $this->_baseDir;
     $compare->updateFromLocalStart();
     $out = $this->_out;
     $root = true;
     $count = 0;
     $makePath = function ($path) use(&$baseDir) {
         return str_replace("\\", "/", substr($path, strlen($baseDir)));
     };
     //another closure for compare
     $c = function ($path) use(&$compare, &$stat, &$count, &$makePath) {
         /** @var $compare Compare_Interface */
         /** @var $stat Storage_Filesystem_FileStat */
         $obj = Core_FsObject::factoryFromStat($makePath($path), $stat->getStat($path));
         $compare->updateFromLocal($obj);
         $count++;
     };
     //currently regexp filter for windows is implemented in closure
     //for other platforms it should support Filter_Interface
     $options = $this->_options;
     $regExpFilter = function ($name, $isDir) use(&$options) {
         // TODO fix notification
         $filterConf = @$options['filter'][$options['filterType']];
         if ($isDir) {
             if (isset($filterConf['config']['dirnameFilter'])) {
                 if (preg_match($filterConf['config']['dirnameFilter'], $name)) {
                     return false;
                 }
             }
         } else {
             if (isset($filterConf['config']['filenameFilter'])) {
                 if (preg_match($filterConf['config']['filenameFilter'], $name)) {
                     return false;
                 }
             }
         }
         return true;
     };
     //empty closure will help
     $empty = function ($folder) use(&$regExpFilter) {
         //fix: without it folder that containes only files excluded by filter
         //will not be created, but it should be created as empty folder
         if ($folder->Files->Count > 0 && $folder->SubFolders->Count == 0) {
             foreach ($folder->Files as $file) {
                 /** @var $file SplFileObject */
                 if ($regExpFilter($file->Name, false)) {
                     return false;
                 }
             }
             return true;
         }
         if ($folder->Files->Count > 0 || $folder->SubFolders->Count > 0) {
             return false;
         }
         return true;
     };
     //this closure recursively iterates diretory, updating pathes with UTF8 support
     $magicScan = function ($dir) use(&$c, &$baseDir, &$root, &$magicScan, &$empty, &$out, &$regExpFilter) {
         //initialize windows's FileSystemObject
         /** @noinspection PhpUndefinedClassInspection, PhpUndefinedConstantInspection */
         $fso = new COM('Scripting.FileSystemObject', null, CP_UTF8);
         if ($root) {
             $curDir = $baseDir;
             $root = false;
         } else {
             $curDir = $dir;
         }
         //excluding folders
         //see Scripting.FileSystemObject on http://msdn.microsoft.com
         /** @noinspection PhpUndefinedMethodInspection */
         $folder = $fso->GetFolder($curDir);
         foreach ($folder->Files as $file) {
             //excluding files
             if (!$regExpFilter($file->Name, false)) {
                 continue;
             }
             $c($file->Path);
         }
         foreach ($folder->SubFolders as $folder) {
             if (!$regExpFilter($folder->Name, true)) {
                 continue;
             }
             if ($empty($folder)) {
                 //empty folders we update
                 $c($folder->Path . '/');
             } else {
                 //let's dig deeper :)
                 $magicScan($folder);
             }
         }
     };
     $magicScan($baseDir);
     $compare->updateFromLocalEnd();
     $this->_out->jobEnd($job, "done: updated info about {$count} files");
//.........这里部分代码省略.........
开发者ID:dannypenrose,项目名称:xtbackup,代码行数:101,代码来源:Filesystem.php

示例3: COM

<?php

header("Content-Type: text/plain");
$objFSO = new COM("Scripting.FileSystemObject");
$objFolder = $objFSO->GetFolder("C:\\\\Documents and Settings\\");
echo "Date created: " . $objFolder->DateCreated . "\r\n";
echo "Date last accessed: " . $objFolder->DateLastAccessed . "\r\n";
echo "Date last modified: " . $objFolder->DateLastModified . "\r\n";
echo "Drive: " . $objFolder->Drive . "\r\n";
echo "Is root folder: " . $objFolder->IsRootFolder . "\r\n";
echo "Name: " . $objFolder->Name . "\r\n";
echo "Parent folder: " . $objFolder->ParentFolder . "\r\n";
echo "Path: " . $objFolder->Path . "\r\n";
echo "Short name: " . $objFolder->ShortName . "\r\n";
echo "Short path: " . $objFolder->ShortPath . "\r\n";
echo "Size: " . $objFolder->Size . "\r\n";
echo "Type: " . $objFolder->Type . "\r\n";
echo "=======================";
开发者ID:JhunCabas,项目名称:avarice-nms,代码行数:18,代码来源:folder-size.php

示例4: defineMd5

 public function defineMd5($path)
 {
     //hack for windows encoding issue
     if ($this->_opsys == self::OPSYS_WIN) {
         $path = mb_convert_encoding($path, $this->_windowsEncoding, "auto");
         /** @noinspection PhpUndefinedClassInspection */
         $fsobj = new COM("Scripting.FileSystemObject");
         try {
             /** @noinspection PhpUndefinedMethodInspection */
             $fsobj->GetFolder($path);
             $f = true;
         } catch (Exception $e) {
             $f = false;
         }
         if ($f) {
             return md5("");
         }
         //exit("converted ".$path);
     }
     return md5_file($path);
 }
开发者ID:dannypenrose,项目名称:xtbackup,代码行数:21,代码来源:FileStat.php


注:本文中的COM::GetFolder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。