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


PHP COM::GetFile方法代码示例

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


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

示例1: filesize64

 public static function filesize64($file)
 {
     static $iswin;
     if (!isset($iswin)) {
         $iswin = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN';
     }
     static $exec_works;
     if (!isset($exec_works)) {
         $exec_works = function_exists('exec') && !ini_get('safe_mode') && @exec('echo EXEC') == 'EXEC';
     }
     // try a shell command
     if ($exec_works) {
         $cmd = $iswin ? "for %F in (\"{$file}\") do @echo %~zF" : "stat -c%s \"{$file}\"";
         @exec($cmd, $output);
         if (is_array($output) && ctype_digit($size = trim(implode("\n", $output)))) {
             return intval($size);
         }
     }
     // try the Windows COM interface
     if ($iswin && class_exists("COM")) {
         try {
             $fsobj = new COM('Scripting.FileSystemObject');
             $f = $fsobj->GetFile(realpath($file));
             $size = $f->Size;
         } catch (Exception $e) {
             $size = null;
         }
         if (ctype_digit($size)) {
             return intval($size);
         }
     }
     // if all else fails
     return filesize($file);
 }
开发者ID:joshhodgson,项目名称:Website,代码行数:34,代码来源:FileHelpers.php

示例2: getSize

function getSize($file)
{
    $size = filesize($file);
    if ($size < 0) {
        if (!(strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')) {
            $size = trim(`stat -c%s {$file}`);
        } else {
            $fsobj = new COM("Scripting.FileSystemObject");
            $f = $fsobj->GetFile($file);
            $size = $file->Size;
        }
    }
    if ($size > 1000000000) {
        $size = number_format($size / 1000000000, 2, '.', '');
        $size = $size . " GB";
    } else {
        if ($size > 1000000) {
            $size = number_format($size / 1000000, 2, '.', '');
            $size = $size . " MB";
        } else {
            if ($size > 4000) {
                $size = number_format($size / 1000, 2, '.', '');
                $size = $size . " kb";
            } else {
                $size = $size . " bytes";
            }
        }
    }
    return $size;
}
开发者ID:joeyfromspace,项目名称:hdtracks-metadata,代码行数:30,代码来源:metadata_util.php

示例3: getFileSize

 public function getFileSize($filePath)
 {
     if (!file_exists($filePath)) {
         throw new Exception("source file (" . $filePath . ")is not exist");
     }
     $fs = new COM("Scripting.FileSystemObject");
     $size = $fs->GetFile($filePath)->Size;
     return $size;
 }
开发者ID:eSDK,项目名称:esdk_obs_native_php,代码行数:9,代码来源:SetObjectHead.php

示例4: getFileSize

 /**
  * Returns file size by using Windows COM interface
  * @inheritdoc
  * @link http://stackoverflow.com/questions/5501451/php-x86-how-to-get-filesize-of-2gb-file-without-external-program/5502328#5502328
  */
 public function getFileSize($path)
 {
     // Use the Windows COM interface
     $fsobj = new \COM('Scripting.FileSystemObject');
     if (dirname($path) == '.') {
         $this->path = substr(getcwd(), -1) == DIRECTORY_SEPARATOR ? getcwd() . basename($path) : getcwd() . DIRECTORY_SEPARATOR . basename($path);
     }
     $f = $fsobj->GetFile($path);
     return BigInteger::of($f->Size);
 }
开发者ID:gitter-badger,项目名称:BigFileTools,代码行数:15,代码来源:ComDriver.php

示例5: getSize

 /**
  * Return the filesize of the file
  * handle big files (filesize() doesn't)
  * @see http://us3.php.net/manual/fr/function.filesize.php#80959
  * 
  * @param string $file Path to the file
  *
  * @return int the size of the file $file
  */
 public static function getSize($file)
 {
     if (DIRECTORY_SEPARATOR === '/') {
         $filename = escapeshellarg($file);
         $size = trim(`stat -c%s {$filename}`);
     } else {
         $fsobj = new COM("Scripting.FileSystemObject");
         $f = $fsobj->GetFile($file);
         $size = $file->Size;
     }
     return $size;
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:21,代码来源:PHP_BigFile.class.php

示例6: getSize

 /**
  * Return the filesize of the file
  * handle big files (filesize() doesn't)
  * @see http://us3.php.net/manual/fr/function.filesize.php#80959
  * 
  * @param string $file Path to the file
  *
  * @return int the size of the file $file
  */
 public static function getSize($file)
 {
     $size = @filesize($file);
     if ($size === false) {
         if (!(strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')) {
             $size = trim(`stat -c%s {$file}`);
         } else {
             $fsobj = new COM("Scripting.FileSystemObject");
             $f = $fsobj->GetFile($file);
             $size = $file->Size;
         }
     }
     return $size;
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:23,代码来源:Codendi_File.class.php

示例7: fileSize64

function fileSize64($file)
{
    //Le système d'exploitation est-il un windows?
    static $isWindows;
    if (!isset($isWindows)) {
        $isWindows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN';
    }
    //La commande exec est-elle disponible?
    static $execWorks;
    if (!isset($execWorks)) {
        $execWorks = function_exists('exec') && !ini_get('safe_mode') && @exec('echo EXEC') == 'EXEC';
    }
    //Essaye une commande shell
    if ($execWorks) {
        $cmd = $isWindows ? "for %F in (\"{$file}\") do @echo %~zF" : "stat -c%s \"{$file}\"";
        @exec($cmd, $output);
        /*
         * ctype_digit vérifie si tous les caractères de la chaîne sont des chiffres
         * @link https://php.net/manual/fr/function.ctype-digit.php
         */
        if (is_array($output) && ctype_digit($size = trim(implode("\n", $output)))) {
            return round($size / 1024, 0);
        }
        //conversion en Kb
    }
    //Essaye l'interface Windows COM
    if ($isWindows && class_exists("COM")) {
        try {
            //@link https://php.net/manual/fr/class.com.php
            $fileSystemObject = new COM('Scripting.FileSystemObject');
            //accès au système de fichier de l'ordinateur
            //retourne un objet fichier
            $fileObject = $fileSystemObject->GetFile(realpath($file));
            //retourne la taille du fichier en octets
            $size = $fileObject->Size;
        } catch (Exception $e) {
            $size = null;
        }
        if (ctype_digit($size)) {
            return round($size / 1024, 0);
        }
        //conversion en Kb
    }
    //En dernier recours utilise filesize (qui ne fonctionne pas correctement pour des fichiers de plus de 2 Go.
    return round(filesize($file) / 1024, 0);
}
开发者ID:at69,项目名称:beta-OwlEyes,代码行数:46,代码来源:functions.php

示例8: file_utils_get_size

function file_utils_get_size($file)
{
    //Uncomment when limitation is fixed
    //return filesize($file);
    if (!(strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')) {
        //if filename containing spaces
        $filename = escapeshellarg($file);
        $size = trim(`stat -c%s {$filename}`);
        //$size = filesize($file);
    } else {
        // Not tested...
        $fsobj = new COM("Scripting.FileSystemObject");
        $f = $fsobj->GetFile($file);
        $size = $file->Size;
    }
    return $size;
}
开发者ID:rinodung,项目名称:tuleap,代码行数:17,代码来源:file_utils.php

示例9: filesize

 function true_filesize($file, $f = false)
 {
     global $config;
     static $cache;
     static $fsobj = false;
     if (isset($cache[$file])) {
         return $cache[$file];
     }
     if (is_dir($file)) {
         return 0;
     }
     if (PHP_INT_SIZE > 4 || @$config['disable_4gb_support']) {
         $size = filesize($file);
     } else {
         if (OS_ISWINDOWS) {
             if (class_exists("COM")) {
                 if ($fsobj === FALSE) {
                     $fsobj = new COM("Scripting.FileSystemObject");
                 }
                 $ofile = $fsobj->GetFile($file);
                 $size = $ofile->Size + 1 - 1;
                 $cache[$file] = $size;
             } else {
                 $size = filesize($file);
             }
         } else {
             $dir = dirname($file);
             $list = array();
             exec("ls -l " . escapeshellarg($dir) . '/', $list);
             $files = $this->ParseUnixList($list, @$config['ls_dateformat_in_iso8601']);
             foreach ($files as $v) {
                 $cache[$dir . "/" . $v['name']] = $v['size'];
             }
             if (isset($config['follow_symlink']) && $config['follow_symlink']) {
                 foreach ($files as $v) {
                     if ($v['is_link']) {
                         $cache[$dir . "/" . $v['name']] = $this->true_filesize($v['link'], true);
                     }
                 }
             }
             $size = $cache[$file];
         }
     }
     return $size;
 }
开发者ID:nagyistoce,项目名称:lanmediaservice-lms-video-ce-1.x,代码行数:45,代码来源:storages.php

示例10: getFileSize

 /**
  * Get the size of a file
  * Works for large files too (>2GB)
  * @param string $path File's path
  * @param double File's size
  */
 public static function getFileSize(string $path)
 {
     if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
         if (class_exists('COM')) {
             $fsobj = new COM('Scripting.FileSystemObject');
             $f = $fsobj->GetFile(realpath($path));
             $size = $f->Size;
         } else {
             $size = trim(exec("for %F in (\"" . $path . "\") do @echo %~zF"));
         }
     } elseif (PHP_OS == 'Darwin') {
         $size = trim(shell_exec("stat -f %z " . escapeshellarg($path)));
     } elseif (in_array(PHP_OS, ['Linux', 'FreeBSD', 'Unix', 'SunOS'])) {
         $size = trim(shell_exec("stat -c%s " . escapeshellarg($path)));
     } else {
         $size = filesize($path);
     }
     return doubleval($size);
 }
开发者ID:phramework,项目名称:util,代码行数:25,代码来源:File.php

示例11: relocateShortcut

 private static function relocateShortcut()
 {
     $WshShell = new COM('WScript.Shell', null, CP_UTF8);
     $FSO = new COM('Scripting.FileSystemObject', null, CP_UTF8);
     $desktop = $WshShell->SpecialFolders('Desktop');
     $startmenu = $WshShell->SpecialFolders('Programs');
     $startmenu = $FSO->BuildPath($startmenu, utf8_encode('XAMPP for Windows'));
     $xampppath = utf8_encode(self::$xampppath);
     $links = array();
     $links[$FSO->BuildPath($desktop, utf8_encode('XAMPP Control Panel.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'Description' => utf8_encode('XAMPP Control Panel'));
     $links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Control Panel.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'Description' => utf8_encode('XAMPP Control Panel'));
     $links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Setup.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp_setup.bat')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp_cli.exe')), 'Description' => utf8_encode('XAMPP Setup'));
     $links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Shell.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp_shell.bat')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp_cli.exe')), 'Description' => utf8_encode('XAMPP Shell'));
     $links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Uninstall.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('uninstall_xampp.bat')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp_cli.exe')), 'Description' => utf8_encode('XAMPP Uninstall'));
     foreach ($links as $shortcut => $value) {
         if (!$FSO->FileExists($shortcut)) {
             continue;
         }
         try {
             $shortcut_file = $FSO->GetFile($shortcut);
             $oldfileperm = $shortcut_file->attributes;
             if (($oldfileperm & 1) == 1) {
                 $shortcut_file->attributes += -1;
             }
         } catch (Exception $e) {
             throw new XAMPPException('File \'' . utf8_decode($shortcut) . '\' is not writable.');
         }
         $ShellLink = $WshShell->CreateShortcut($shortcut);
         $ShellLink->TargetPath = $value['TargetPath'];
         $ShellLink->WorkingDirectory = $value['WorkingDirectory'];
         $ShellLink->WindowStyle = $value['WindowStyle'];
         $ShellLink->IconLocation = $value['IconLocation'];
         $ShellLink->Description = $value['Description'];
         $ShellLink->Save();
         $ShellLink = null;
         $shortcut_file->attributes = $oldfileperm;
         $shortcut_file = null;
     }
     $FSO = null;
     $WshShell = null;
     return;
 }
开发者ID:join1603,项目名称:wme2a,代码行数:42,代码来源:package__xampp.php

示例12: getSize

 /**
  * get file size
  *
  * @access public
  * @param  string  $file
  * @param  boolean $convert - call byte_convert(); default: false
  * @return string
  **/
 public static function getSize($file, $convert = false)
 {
     $file = self::sanitizePath($file);
     if (is_dir($file)) {
         return false;
     }
     if (!file_exists($file)) {
         return false;
     }
     $size = @filesize($file);
     if ($size < 0) {
         if (!(strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')) {
             $size = trim(`stat -c%s {$file}`);
         } else {
             if (extension_loaded('COM')) {
                 $fsobj = new COM("Scripting.FileSystemObject");
                 $f = $fsobj->GetFile($file);
                 $size = $file->Size;
             }
         }
     }
     if ($size && $convert) {
         $size = self::byte_convert($size);
     }
     return $size;
 }
开发者ID:ircoco,项目名称:BlackCatCMS,代码行数:34,代码来源:Directory.php

示例13: getTrueSize

 function getTrueSize($file)
 {
     if (!(strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')) {
         $cmd = "stat -L -c%s \"" . $file . "\"";
         $val = trim(`{$cmd}`);
         if (strlen($val) == 0 || floatval($val) == 0) {
             // No stat on system
             $cmd = "ls -1s --block-size=1 \"" . $file . "\"";
             $val = trim(`{$cmd}`);
         }
         if (strlen($val) == 0 || floatval($val) == 0) {
             // No block-size on system (probably busybox), try long output
             $cmd = "ls -l \"" . $file . "\"";
             $arr = explode("/[\\s]+/", `{$cmd}`);
             $val = trim($arr[4]);
         }
         if (strlen($val) == 0 || floatval($val) == 0) {
             // Still not working, get a value at least, not 0...
             $val = sprintf("%u", filesize($file));
         }
         return floatval($val);
     } else {
         if (class_exists("COM")) {
             $fsobj = new COM("Scripting.FileSystemObject");
             $f = $fsobj->GetFile($file);
             return floatval($f->Size);
         } else {
             if (is_file($file)) {
                 return exec('FOR %A IN ("' . $file . '") DO @ECHO %~zA');
             } else {
                 return sprintf("%u", filesize($file));
             }
         }
     }
 }
开发者ID:projectesIF,项目名称:Ateneu,代码行数:35,代码来源:class.fsAccessDriver.php

示例14: get_real_size

/**
 * Since filesize() was giving trouble with files larger
 * than 2gb, I looked for a solution and found this great
 * function by Alessandro Marinuzzi from www.alecos.it on
 * http://stackoverflow.com/questions/5501451/php-x86-how-
 * to-get-filesize-of-2gb-file-without-external-program
 *
 * I changed the name of the function and split it in 2,
 * because I do not want to display it directly.
 */
function get_real_size($file)
{
    clearstatcache();
    if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
        if (class_exists("COM")) {
            $fsobj = new COM('Scripting.FileSystemObject');
            $f = $fsobj->GetFile(realpath($file));
            $ff = $f->Size;
        } else {
            $ff = trim(exec("for %F in (\"" . $file . "\") do @echo %~zF"));
        }
    } elseif (PHP_OS == 'Darwin') {
        $ff = trim(shell_exec("stat -f %z " . escapeshellarg($file)));
    } elseif (PHP_OS == 'Linux' || PHP_OS == 'FreeBSD' || PHP_OS == 'Unix' || PHP_OS == 'SunOS') {
        $ff = trim(shell_exec("stat -c%s " . escapeshellarg($file)));
    } else {
        $ff = filesize($file);
    }
    /** Fix for 0kb downloads by AlanReiblein */
    if (!ctype_digit($ff)) {
        /* returned value not a number so try filesize() */
        $ff = filesize($file);
    }
    return $ff;
}
开发者ID:BastienDurel,项目名称:ProjectSend,代码行数:35,代码来源:functions.php

示例15: fileSize

 /**
  * Get size in bytes of the file. This also supports files over 2GB in Windows,
  * which is not supported by PHP's filesize().
  *
  * @param string $path path of the file to check
  * @return int
  */
 public static function fileSize($path)
 {
     if (strpos(strtolower(PHP_OS), 'win') === 0) {
         $filesystem = new COM('Scripting.FileSystemObject');
         $file = $filesystem->GetFile($path);
         return $file->Size();
     } else {
         return filesize($path);
     }
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:17,代码来源:UtilityComponent.php


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