當前位置: 首頁>>代碼示例>>PHP>>正文


PHP lstat函數代碼示例

本文整理匯總了PHP中lstat函數的典型用法代碼示例。如果您正苦於以下問題:PHP lstat函數的具體用法?PHP lstat怎麽用?PHP lstat使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了lstat函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: failureDescription

 /**
  * {@inheritdoc}
  */
 protected function failureDescription($other)
 {
     if (!is_string($other)) {
         if (is_object($other)) {
             $type = sprintf('%s#%s', get_class($other), method_exists($other, '__toString') ? $other->__toString() : '');
         } elseif (null === $other) {
             $type = 'null';
         } else {
             $type = gettype($other) . '#' . $other;
         }
         return $type . ' ' . $this->toString();
     }
     if (!file_exists($other)) {
         return 'not file or directory#' . $other . ' ' . $this->toString();
     }
     if (is_link($other)) {
         $type = 'link';
         $perms = lstat($other);
         $perms = $perms['mode'];
     } else {
         $type = is_file($other) ? 'file' : (is_dir($other) ? 'directory' : 'other');
         $perms = fileperms($other);
     }
     return sprintf('%s#%s %o %s %o', $type, $other, $perms, $this->toString(), $this->mask);
 }
開發者ID:GeckoPackages,項目名稱:GeckoPHPUnit,代碼行數:28,代碼來源:FilePermissionsMaskConstraint.php

示例2: getRuntimeDir

 public function getRuntimeDir($strict = true)
 {
     if ($runtimeDir = getenv('XDG_RUNTIME_DIR')) {
         return $runtimeDir;
     }
     if ($strict) {
         throw new \RuntimeException('XDG_RUNTIME_DIR was not set');
     }
     $fallback = sys_get_temp_dir() . DIRECTORY_SEPARATOR . self::RUNTIME_DIR_FALLBACK . getenv('USER');
     $create = false;
     if (!is_dir($fallback)) {
         mkdir($fallback, 0700, true);
     }
     $st = lstat($fallback);
     # The fallback must be a directory
     if (!$st['mode'] & self::S_IFDIR) {
         rmdir($fallback);
         $create = true;
     } elseif ($st['uid'] != getmyuid() || $st['mode'] & (self::S_IRWXG | self::S_IRWXO)) {
         rmdir($fallback);
         $create = true;
     }
     if ($create) {
         mkdir($fallback, 0700, true);
     }
     return $fallback;
 }
開發者ID:a53ali,項目名稱:CakePhP,代碼行數:27,代碼來源:Xdg.php

示例3: __construct

 public function __construct()
 {
     parent::__construct('filePermissions', function ($string) {
         if (is_string($string)) {
             if (ctype_digit($string)) {
                 $permissions = octdec($string);
             } elseif (is_link($string)) {
                 $permissions = lstat($string)['mode'];
             } elseif (file_exists($string)) {
                 $permissions = fileperms($string);
             } else {
                 throw new \Twig_Error_Runtime(sprintf('Cannot determine permissions for "%s".', $string));
             }
         } else {
             $permissions = octdec($string);
         }
         if (($permissions & 0xc000) === 0xc000) {
             // Socket
             $info = 's';
         } elseif (($permissions & 0xa000) === 0xa000) {
             // Symbolic Link
             $info = 'l';
         } elseif (($permissions & 0x8000) === 0x8000) {
             // Regular
             $info = '-';
         } elseif (($permissions & 0x6000) === 0x6000) {
             // Block special
             $info = 'b';
         } elseif (($permissions & 0x4000) === 0x4000) {
             // Directory
             $info = 'd';
         } elseif (($permissions & 0x2000) === 0x2000) {
             // Character special
             $info = 'c';
         } elseif (($permissions & 0x1000) === 0x1000) {
             // FIFO pipe
             $info = 'p';
         } else {
             // Unknown
             $info = 'u';
         }
         // Owner
         $info .= $permissions & 0x100 ? 'r' : '-';
         $info .= $permissions & 0x80 ? 'w' : '-';
         $info .= $permissions & 0x40 ? $permissions & 0x800 ? 's' : 'x' : ($permissions & 0x800 ? 'S' : '-');
         // Group
         $info .= $permissions & 0x20 ? 'r' : '-';
         $info .= $permissions & 0x10 ? 'w' : '-';
         $info .= $permissions & 0x8 ? $permissions & 0x400 ? 's' : 'x' : ($permissions & 0x400 ? 'S' : '-');
         // World
         $info .= $permissions & 0x4 ? 'r' : '-';
         $info .= $permissions & 0x2 ? 'w' : '-';
         $info .= $permissions & 0x1 ? $permissions & 0x200 ? 't' : 'x' : ($permissions & 0x200 ? 'T' : '-');
         return $info;
     });
 }
開發者ID:GeckoPackages,項目名稱:GeckoTwig,代碼行數:56,代碼來源:FilePermissionsFilter.php

示例4: buildDirModel

function buildDirModel($dir, $model, $rootname, $user_id, $db)
{
    ##Remove from $dir to output the part until s3db root;
    $dirFiles = scandir($dir);
    #echo '<pre>';print_r($dirFiles);exit;
    #foreach ($dirFiles as $ind)
    for ($i = 0; $i < count($dirFiles); $i++) {
        $ind = $dirFiles[$i];
        if (is_file($dir . '/' . $ind) && !ereg('^(s3id|config.inc.php|treeitem.*.js|.*.tmp|.*[0-9]{8}$)', $ind)) {
            $fstat = lstat($dir . '/' . $ind);
            $lastModified = date('Y-m-d H:i:s', $fstat['mtime']);
            $path = str_replace($rootname, '', $dir);
            $path = $path == '' ? $ind : substr($path, 1, strlen($path)) . '/' . $ind;
            $path = addslashes($path);
            ###
            #Is there an item with this path value on path rule?
            #$item_id = findFileItemId($path,$user_id,$db);
            ###
            #Find the statement_id of this file on the local s3db
            $allFileIds = @file_get_contents('fileIds.tmp');
            $allFileIds = @unserialize($allFileIds);
            $file_id = @array_search($path, $allFileIds);
            if ($file_id == '') {
                echo "Finding ID of file " . $path . chr(10);
                $sql = "select statement_id from s3db_statement where rule_id = '" . $GLOBALS['update_project']['file']['rule_id'] . "' and file_name = '" . $path . "' order by created_on desc limit 1";
                $db->query($sql, __LINE__, __FILE__);
                if ($db->next_record()) {
                    $file_id = $db->f('statement_id');
                    $allFileIds[$file_id] = $path;
                }
            }
            if ($file_id == '') {
                $updated = fileUpdate($path, $user_id, $db);
                $file_id = $updated;
            }
            if ($file_id != '') {
                file_put_contents('fileIds.tmp', serialize($allFileIds));
                echo "writting item " . $path . " " . $file_id . chr(10);
                $subjResources = new Resource($GLOBALS['s3db_info']['deployment']['URI'] . 's3dbfiles.php?file_id=' . $file_id);
                $statement = new Statement($subjResources, new Resource('http://purl.org/dc/elements/1.1/date'), new Literal($lastModified));
                $path = new Statement($subjResources, new Resource('http://s3db.org/scripts'), new Literal($path));
                $model->add($statement);
                $model->add($path);
            } else {
                @file_put_contents('update_error_log.txt', "Could not find a file_id for " . $path . chr(10));
            }
        } elseif (is_dir($dir . '/' . $ind) && !ereg('^(.|..|extras)$', $ind)) {
            $newDir = $dir . '/' . $ind;
            $submodel = ModelFactory::getDefaultModel();
            $submodel = buildDirModel($newDir, $submodel, $rootname, $user_id, $db);
            $model->addModel($submodel);
        }
    }
    return $model;
}
開發者ID:helenadeus,項目名稱:s3db.map,代碼行數:55,代碼來源:updates.php

示例5: writeHeader

 /**
  * @param $real_path
  * @param $new_path
  * @return bool
  */
 protected function writeHeader($real_path, $new_path)
 {
     if (strlen($new_path) > 99) {
         $this->writeLongHeader($new_path);
     }
     $v_info = lstat($real_path);
     $v_uid = sprintf("%6s ", DecOct($v_info[4]));
     $v_gid = sprintf("%6s ", DecOct($v_info[5]));
     $v_perms = sprintf("%6s ", DecOct($v_info['mode']));
     $v_mtime = sprintf("%11s", DecOct($v_info['mtime']));
     $v_linkname = '';
     if (@is_link($real_path)) {
         $v_typeflag = '2';
         $v_linkname = readlink($real_path);
         $v_size = sprintf("%11s ", DecOct(0));
     } elseif (@is_dir($real_path)) {
         $v_typeflag = "5";
         $v_size = sprintf("%11s ", DecOct(0));
     } else {
         $v_typeflag = '';
         clearstatcache(TRUE, $real_path);
         $v_size = sprintf("%11s ", DecOct($v_info['size']));
     }
     $v_magic = '';
     $v_version = '';
     $v_uname = '';
     $v_gname = '';
     $v_devmajor = '';
     $v_devminor = '';
     $v_prefix = '';
     $v_binary_data_first = pack("a100a8a8a8a12A12", $new_path, $v_perms, $v_uid, $v_gid, $v_size, $v_mtime);
     $v_binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12", $v_typeflag, $v_linkname, $v_magic, $v_version, $v_uname, $v_gname, $v_devmajor, $v_devminor, $v_prefix, '');
     // ----- Calculate the checksum
     $v_checksum = 0;
     // ..... First part of the header
     for ($i = 0; $i < 148; $i++) {
         $v_checksum += ord(substr($v_binary_data_first, $i, 1));
     }
     // ..... Ignore the checksum value and replace it by ' ' (space)
     for ($i = 148; $i < 156; $i++) {
         $v_checksum += ord(' ');
     }
     // ..... Last part of the header
     for ($i = 156, $j = 0; $i < 512; $i++, $j++) {
         $v_checksum += ord(substr($v_binary_data_last, $j, 1));
     }
     // ----- Write the first 148 bytes of the header in the archive
     $this->archive->write($v_binary_data_first, 148);
     // ----- Write the calculated checksum
     $v_checksum = sprintf("%6s ", DecOct($v_checksum));
     $v_binary_data = pack("a8", $v_checksum);
     $this->archive->write($v_binary_data, 8);
     // ----- Write the last 356 bytes of the header in the archive
     $this->archive->write($v_binary_data_last, 356);
 }
開發者ID:Wylbur,項目名稱:gj,代碼行數:60,代碼來源:TarArchiveWriter.php

示例6: lstat

 /**
  * {@inheritdoc}
  */
 public function lstat($path)
 {
     if ($stat = @\lstat($path)) {
         $stat["isfile"] = (bool) \is_file($path);
         $stat["isdir"] = empty($stat["isfile"]);
         \clearstatcache(true, $path);
     } else {
         $stat = null;
     }
     return new Success($stat);
 }
開發者ID:staabm,項目名稱:file,代碼行數:14,代碼來源:BlockingDriver.php

示例7: writeLog

 /**
  * Manage log file.
  *
  * @param string $filePath
  * @param string $callStart
  * @param string $resource
  * @param string $duration
  */
 protected function writeLog($filePath, $callStart, $resource, $duration)
 {
     $log = fopen($filePath, "a+");
     clearstatcache();
     $fileStats = lstat($filePath);
     if ($fileStats && 0 === $fileStats['size']) {
         fwrite($log, "datetime;soap_call_resource;duration (s)\n");
     }
     fwrite($log, sprintf("%s;%s;%s\n", $callStart, $resource, $duration));
     fclose($log);
 }
開發者ID:mejdoubimeriem,項目名稱:prestashopconnector,代碼行數:19,代碼來源:PrestashopSoapClientProfiler.php

示例8: httpfs_getattr

function httpfs_getattr($data)
{
    $path = explode("", $data, 2)[0];
    $s = lstat($path);
    if ($s) {
        dump_ok();
        echo pack('NNNNNNNNNNNNN', $s['dev'], $s['ino'], $s['mode'], $s['nlink'], $s['uid'], $s['gid'], $s['rdev'], $s['size'], $s['atime'], $s['mtime'], $s['ctime'], $s['blksize'], $s['blocks']);
    } else {
        dump_error(ENTRY_NOT_FOUND);
    }
}
開發者ID:ksmaheshkumar,項目名稱:httpfs,代碼行數:11,代碼來源:template.php

示例9: getTempDir

 /**
  * This function retrieves the path to a directory where temporary files can be saved.
  *
  * @return string Path to a temporary directory, without a trailing directory separator.
  * @throws \SimpleSAML_Error_Exception If the temporary directory cannot be created or it exists and does not belong
  * to the current user.
  *
  * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no>
  * @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
  * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no>
  */
 public static function getTempDir()
 {
     $globalConfig = \SimpleSAML_Configuration::getInstance();
     $tempDir = rtrim($globalConfig->getString('tempdir', sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'simplesaml'), DIRECTORY_SEPARATOR);
     if (!is_dir($tempDir)) {
         if (!mkdir($tempDir, 0700, true)) {
             $error = error_get_last();
             throw new \SimpleSAML_Error_Exception('Error creating temporary directory "' . $tempDir . '": ' . $error['message']);
         }
     } elseif (function_exists('posix_getuid')) {
         // check that the owner of the temp directory is the current user
         $stat = lstat($tempDir);
         if ($stat['uid'] !== posix_getuid()) {
             throw new \SimpleSAML_Error_Exception('Temporary directory "' . $tempDir . '" does not belong to the current user.');
         }
     }
     return $tempDir;
 }
開發者ID:SysBind,項目名稱:simplesamlphp,代碼行數:29,代碼來源:System.php

示例10: getStatRaw

 /**
  * Gives information about a file
  * 
  * Stat from regular file (stat()) and symbolic link (lstat())
  * 
  * @param string $findkey Find a key from stat value as 'dev'
  * @return array|string
  */
 public function getStatRaw($findkey = '')
 {
     if (is_link($this->source)) {
         if ($findkey !== '') {
             $stat = lstat($this->source);
             return $stat[$findkey];
         }
         if ($findkey === '') {
             return lstat($this->source);
         } else {
             $stat = lstat($this->source);
             if ($stat) {
                 foreach (array_keys($stat) as $key) {
                     if (is_string($key)) {
                         $statResponse[$key] = $stat[$key];
                     }
                 }
                 return $statResponse;
             }
             return $stat;
         }
     }
     if (file_exists($this->source) || is_dir($this->source)) {
         if ($findkey !== '') {
             $stat = stat($this->source);
             return $stat[$findkey];
         }
         if ($findkey === '') {
             return stat($this->source);
         } else {
             $stat = stat($this->source);
             if ($stat) {
                 foreach (array_keys($stat) as $key) {
                     if (is_string($key)) {
                         $statResponse[$key] = $stat[$key];
                     }
                 }
                 return $statResponse;
             }
             return $stat;
         }
     }
     return false;
 }
開發者ID:ionitium,項目名稱:filesystem,代碼行數:52,代碼來源:Filesysteminfo.php

示例11: header

 /**
  * Print report header
  *
  * @param array $targets List of target directories
  * @param array $argv Command line arguments
  */
 public function header($targets, $argv)
 {
     $header = !empty($this->format) ? $this->getRowFormatHeader($this->format) : $this->getRowHeader();
     echo "date: " . date('r (U)') . "\n";
     echo "getenv(TZ): " . getenv('TZ') . "\n";
     echo "date_default_timezone_get: " . date_default_timezone_get() . "\n";
     if (defined('DIRSCAN_VERSION')) {
         echo "dirscan version: " . DIRSCAN_VERSION . "\n";
     }
     echo "php version: " . phpversion() . "\n";
     echo "uname: " . php_uname() . "\n";
     echo "cwd: " . getcwd() . "\n";
     echo "settings: " . json_encode($this->settings) . "\n";
     echo "argv: " . json_encode($argv) . "\n";
     echo "target" . (count($targets) > 1 ? "s" : "") . ": " . "\n";
     foreach ($targets as $key => $target) {
         $targetStat = lstat($target);
         $targetStat['realpath'] = realpath($target);
         echo sprintf(" - %s (realpath: %s, device: %s)\n", $target, $targetStat['realpath'], $targetStat['dev']);
     }
     echo "=====================================\n";
     echo implode("\t", $header) . "\n";
 }
開發者ID:vincepare,項目名稱:dirscan,代碼行數:29,代碼來源:CliReporter.php

示例12: cached

 public function cached()
 {
     // Check for non-existant cache file
     if (!file_exists('data/cache/language_registry')) {
         return false;
     }
     // Get directory modification date
     clearstatcache();
     $dir_modified = array_element(lstat('./locale/'), 9);
     // Get cache modification date
     clearstatcache();
     $cache_modified = array_element(lstat('data/cache/language_registry'), 9);
     // If the cache is older than the directory
     if ($cache_modified < $dir_modified) {
         //print "rebuild<br/>\n";
         // Rebuild cache
         return false;
     } else {
         // Otherwise cache is up to date
         //print "fine<br/>\n";
         return true;
     }
 }
開發者ID:rrsc,項目名稱:freemed,代碼行數:23,代碼來源:LanguageRegistry.class.php

示例13: getdirfiles

function getdirfiles($dir, $exts)
{
    $path = $_SERVER['DOCUMENT_ROOT'];
    $path = PathBckSlash($path);
    $result = array();
    if (is_dir($path . $dir)) {
        $dp = dir($path . $dir);
        while (($file = $dp->read()) !== false) {
            if ($file != '.' && $file != '..') {
                if (!is_dir($path . $dir . "/" . $file)) {
                    if (in_array(strtolower(pathinfo($file, PATHINFO_EXTENSION)), $exts)) {
                        $fpropert = lstat($path . $dir . "/" . $file);
                        if ($fpropert) {
                            $result[] = array("fname" => $file, "url" => $dir . "/" . $file, "ctime" => date("Y-m-d H:i:s", $fpropert[10]), "size" => round($fpropert[7] / 1024) . "k");
                        }
                    }
                }
            }
        }
        $dp->close();
    }
    return $result;
}
開發者ID:TheProjecter,項目名稱:webfmt,代碼行數:23,代碼來源:core.php

示例14: buildDirModel

function buildDirModel($dir, $model, $rootname)
{
    ##Remove from $dir to output the part until s3db root;
    $dirFiles = scandir($dir);
    foreach ($dirFiles as $ind) {
        if (is_file($dir . '/' . $ind) && !ereg('^(s3id|config.inc.php|treeitem.*.js)', $ind)) {
            $fstat = lstat($dir . '/' . $ind);
            $lastModified = date('Y-m-d H:i:s', $fstat['mtime']);
            $path = str_replace($rootname, '', $dir);
            $path = $path == '' ? $ind : substr($path, 1, strlen($path)) . '/' . $ind;
            $subjResources = new Resource('http://www.s3db.org/central/s3dbfiles.php?file=' . $path);
            $statement = new Statement($subjResources, new Resource('http://purl.org/dc/elements/1.1/date'), new Literal($lastModified));
            $path = new Statement($subjResources, new Resource('http://s3db.org/scripts'), new Literal($path));
            $model->add($statement);
            $model->add($path);
        } elseif (is_dir($dir . '/' . $ind) && !ereg('^(.|..|extras)$', $ind)) {
            $newDir = $dir . '/' . $ind;
            $submodel = ModelFactory::getDefaultModel();
            $submodel = buildDirModel($newDir, $submodel, $rootname);
            $model->addModel($submodel);
        }
    }
    return $model;
}
開發者ID:helenadeus,項目名稱:s3db.map,代碼行數:24,代碼來源:RSS.php

示例15: _stat

 /**
  * Return stat for given path.
  * Stat contains following fields:
  * - (int)    size    file size in b. required
  * - (int)    ts      file modification time in unix time. required
  * - (string) mime    mimetype. required for folders, others - optionally
  * - (bool)   read    read permissions. required
  * - (bool)   write   write permissions. required
  * - (bool)   locked  is object locked. optionally
  * - (bool)   hidden  is object hidden. optionally
  * - (string) alias   for symlinks - link target path relative to root path. optionally
  * - (string) target  for symlinks - link target path. optionally
  *
  * If file does not exists - returns empty array or false.
  *
  * @param  string  $path    file path 
  * @return array|false
  * @author Dmitry (dio) Levashov
  **/
 protected function _stat($path)
 {
     $stat = array();
     if (!file_exists($path)) {
         return $stat;
     }
     //Verifies the given path is the root or is inside the root. Prevents directory traveral.
     if (!$this->aroot) {
         // for Inheritance class ( not calling parent::configure() )
         $this->aroot = realpath($this->root);
     }
     if (!$this->_inpath($path, $this->aroot)) {
         return $stat;
     }
     if ($path != $this->root && is_link($path)) {
         if (($target = $this->readlink($path)) == false || $target == $path) {
             $stat['mime'] = 'symlink-broken';
             $stat['read'] = false;
             $stat['write'] = false;
             $stat['size'] = 0;
             return $stat;
         }
         $stat['alias'] = $this->_path($target);
         $stat['target'] = $target;
         $path = $target;
         $lstat = lstat($path);
         $size = $lstat['size'];
     } else {
         $size = @filesize($path);
     }
     $dir = is_dir($path);
     $stat['mime'] = $dir ? 'directory' : $this->mimetype($path);
     $stat['ts'] = filemtime($path);
     $stat['read'] = is_readable($path);
     $stat['write'] = is_writable($path);
     if ($stat['read']) {
         $stat['size'] = $dir ? 0 : $size;
     }
     return $stat;
 }
開發者ID:scorpionx,項目名稱:vtt-bundle,代碼行數:59,代碼來源:elFinderVolumeLocalFileSystem.php


注:本文中的lstat函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。