• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP fstat函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中fstat函数的典型用法代码示例。如果您正苦于以下问题:PHP fstat函数的具体用法?PHP fstat怎么用?PHP fstat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: testSizeReturnsStreamSize

 public function testSizeReturnsStreamSize()
 {
     $stream = Stream::make('Lorem ipsum dolor sit amet');
     $resource = $stream->getResource();
     $stat = fstat($resource);
     $this->assertEquals($stat['size'], $stream->getSize());
 }
开发者ID:easy-system,项目名称:es-http,代码行数:7,代码来源:StreamTest.php


示例2: multipartUpload

function multipartUpload($client, $bucket, $keyprefix)
{
    //初始化分开上传,获取uploadid
    $args = array("Bucket" => $bucket, "Key" => $keyprefix . "EOFile");
    $uploadid = $client->initMultipartUpload($args);
    $uploadid = $uploadid["UploadId"];
    //获取到uploadid
    //开始上传
    $file = "D://IMG.jpg";
    //要上传的文件
    $partsize = 1024 * 100;
    $resource = fopen($file, "r");
    $stat = fstat($resource);
    $total = $stat["size"];
    //获取文件的总大小
    fclose($resource);
    $count = (int) ($total / $partsize + 1);
    //计算文件需要分几块上传
    for ($i = 0; $i < $count; $i++) {
        //依次上传每一块
        echo "upload" . $i . "\r\n";
        $args = array("Bucket" => $bucket, "Key" => $keyprefix . "EOFile", "LastPart" => $i === $count - 1, "Options" => array("partNumber" => $i + 1, "uploadId" => $uploadid), "ObjectMeta" => array("Content-Length" => min($partsize, $total - $partsize * $i)), "Content" => array("content" => $file, "seek_position" => $partsize * $i));
        $etag = $client->uploadPart($args);
        $etag = $etag["ETag"];
    }
    $parts = $client->listParts(array("Bucket" => $bucket, "Key" => $keyprefix . "EOFile", "Options" => array("uploadId" => $uploadid)));
    //结束上传
    $args = array("Bucket" => $bucket, "Key" => $keyprefix . "EOFile", "Options" => array("uploadId" => $uploadid), "Parts" => $parts["Parts"]);
    $result = $client->completeMultipartUpload($args);
    rangeGetAndCheckMd5($client, $bucket, $keyprefix . "EOFile", "D://testdown/down", base64_encode(md5_file("D://IMG.jpg")));
}
开发者ID:leunico,项目名称:aliceBlog,代码行数:31,代码来源:TestEncryptionClientFile.php


示例3: parse

 protected function parse()
 {
     $streams = array();
     if (!$this->readHeader()) {
         throw new Exception('Unable to read header');
     }
     /* directories are aligned on 128 bytes */
     $stats = fstat($this->fd);
     for ($pos = 512 + $this->dir_start * $this->block_size; $pos < $stats[7]; $pos += 128) {
         fseek($this->fd, $pos);
         $name = fread($this->fd, 64);
         $name_length = $this->readUnsignedShort();
         $name = utf8_encode(str_replace("", '', substr($name, 0, $name_length - 2)));
         $type = $this->readByte();
         $color = $this->readByte();
         $left_sib = $this->readUnsignedLong();
         $right_sib = $this->readUnsignedLong();
         $child = $this->readUnsignedLong();
         fseek($this->fd, 36, SEEK_CUR);
         $stream_start = $this->readUnsignedLong();
         $stream_size = $this->readUnsignedLong();
         switch ($type) {
             case self::STGTY_STREAM:
                 debug('Found stream ' . $name . ' starting at sector ' . sprintf('0x%X', $stream_start) . ' of size ' . $stream_size);
                 $streams[] = new OLEStream($name, $this, $this->fd, $stream_start, $stream_size);
                 break;
             case self::STGTY_ROOT:
                 debug('Found root ' . $name);
                 break;
         }
     }
     $this->streams = $streams;
 }
开发者ID:beralt,项目名称:XLSReader,代码行数:33,代码来源:OLEReader.class.php


示例4: getSize

 /**
  * {@inheritdoc}
  *
  * @return int|null Returns the size in bytes if known, or null if unknown.
  */
 public function getSize()
 {
     if (null === $this->stream) {
         return null;
     }
     return fstat($this->stream)['size'];
 }
开发者ID:fyuze,项目名称:framework,代码行数:12,代码来源:Stream.php


示例5: eraseLastLineBreak

function eraseLastLineBreak($fileName)
{
    $file = fopen($fileName, 'r+') or die("can't open file");
    $stat = fstat($file);
    ftruncate($file, $stat['size'] - 2);
    fclose($file);
}
开发者ID:MtgMtg,项目名称:hebrewNotes,代码行数:7,代码来源:Trimmer.php


示例6: get

 /**
  * @brief Logs admin page.
  *
  * @return string
  */
 function get()
 {
     $log_choices = array(LOGGER_NORMAL => 'Normal', LOGGER_TRACE => 'Trace', LOGGER_DEBUG => 'Debug', LOGGER_DATA => 'Data', LOGGER_ALL => 'All');
     $t = get_markup_template('admin_logs.tpl');
     $f = get_config('system', 'logfile');
     $data = '';
     if (!file_exists($f)) {
         $data = t("Error trying to open <strong>{$f}</strong> log file.\r\n<br/>Check to see if file {$f} exist and is \n\treadable.");
     } else {
         $fp = fopen($f, 'r');
         if (!$fp) {
             $data = t("Couldn't open <strong>{$f}</strong> log file.\r\n<br/>Check to see if file {$f} is readable.");
         } else {
             $fstat = fstat($fp);
             $size = $fstat['size'];
             if ($size != 0) {
                 if ($size > 5000000 || $size < 0) {
                     $size = 5000000;
                 }
                 $seek = fseek($fp, 0 - $size, SEEK_END);
                 if ($seek === 0) {
                     $data = escape_tags(fread($fp, $size));
                     while (!feof($fp)) {
                         $data .= escape_tags(fread($fp, 4096));
                     }
                 }
             }
             fclose($fp);
         }
     }
     return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Logs'), '$submit' => t('Submit'), '$clear' => t('Clear'), '$data' => $data, '$baseurl' => z_root(), '$logname' => get_config('system', 'logfile'), '$debugging' => array('debugging', t("Debugging"), get_config('system', 'debugging'), ""), '$logfile' => array('logfile', t("Log file"), get_config('system', 'logfile'), t("Must be writable by web server. Relative to your top-level webserver directory.")), '$loglevel' => array('loglevel', t("Log level"), get_config('system', 'loglevel'), "", $log_choices), '$form_security_token' => get_form_security_token('admin_logs')));
 }
开发者ID:phellmes,项目名称:hubzilla,代码行数:37,代码来源:Logs.php


示例7: open

 public function open($filename, $mode = "w", $permissions = 0777)
 {
     $created = false;
     if ($this->resource !== false) {
         return false;
     }
     if (file_exists($filename) === false) {
         if ($mode == "r" || $mode == "r+") {
             return false;
         } else {
             $created = true;
             $directory = dirname($filename);
             if (is_dir($directory) === false) {
                 mkdir($directory, $permissions, true);
                 chmod($directory, $permissions);
             }
         }
     }
     $this->resource = fopen($filename, $mode);
     if ($this->resource !== false) {
         if ($created === true) {
             chmod($filename, $permissions);
         }
         $this->stats = fstat($this->resource);
     }
     return true;
 }
开发者ID:irwtdvoys,项目名称:bolt,代码行数:27,代码来源:Files.php


示例8: testGetSize

 public function testGetSize()
 {
     $resource = fopen(__FILE__, 'r');
     $expected = fstat($resource);
     $stream = new Stream($resource);
     $this->assertEquals($expected['size'], $stream->getSize());
 }
开发者ID:fabyscore,项目名称:fabyscore-lib,代码行数:7,代码来源:StreamTest.php


示例9: create_source_zip

function create_source_zip()
{
    // get the version
    $v_res = $GLOBALS['db']->query('select `version` from `version` limit 1')->fetch();
    $version = $v_res['version'];
    if (empty($version)) {
        $version = '';
    }
    $zip_filename = _DIR_ROOT . '/source/latest' . $version . '.zip';
    define('_SOURCE_ZIP_FILE', $zip_filename);
    if (file_exists($zip_filename)) {
        if (($fp = @fopen($zip_filename, 'r')) !== false) {
            $stats = fstat($fp);
            fclose($fp);
            // check if the source was created in the last hour
            if (time() - $stats['mtime'] <= 3600) {
                return;
            }
        }
        rename($zip_filename, _DIR_ROOT . '/source/latest' . time() . '.zip');
    }
    // Create the latest source of the application
    // in a ZIP archive
    $z = new ZipArchive();
    $z->open($zip_filename, ZipArchive::CREATE);
    add_directory_to_zip($z, _DIR_ROOT);
    // define a constant with the path to the file
    define('_SOURCE_ZIP_FILE', $zip_filename);
}
开发者ID:0unit,项目名称:online-php-ide,代码行数:29,代码来源:source.php


示例10: cacheAge

 function cacheAge($cacheName)
 {
     $fp = fopen($this->cacheFolder . $cacheName, 'r');
     $fstat = fstat($fp);
     fclose($fp);
     return time() - $fstat['mtime'];
 }
开发者ID:xpac27,项目名称:BBack,代码行数:7,代码来源:templateEngine.php


示例11: changed

 protected function changed()
 {
     clearstatcache();
     $fstat = fstat($this->fh);
     $this->currentSize = $fstat['size'];
     return $this->size != $this->currentSize;
 }
开发者ID:imomushi,项目名称:worker,代码行数:7,代码来源:FileHead.php


示例12: url_stat

 function url_stat($path, $flags)
 {
     if (isset($this->filehandle)) {
         return fstat($this->filehandle);
     }
     return null;
 }
开发者ID:zhaoshengloveqingqing,项目名称:Ci,代码行数:7,代码来源:Pinet_Controller.php


示例13: getFileSize

 function getFileSize()
 {
     if (false === ($stat = fstat($this->resource))) {
         throw new phpMorphy_Exception('Can`t invoke fstat for ' . $this->file_name . ' file');
     }
     return $stat['size'];
 }
开发者ID:Garcy111,项目名称:Garcy-Framework-2,代码行数:7,代码来源:File.php


示例14: __construct

 public function __construct($file)
 {
     $this->file = $file;
     $this->handle = fopen($this->file, self::MODE);
     $stats = fstat($this->handle);
     $this->size = $stats['size'];
 }
开发者ID:silvermine,项目名称:php-rtflex,代码行数:7,代码来源:StreamReader.php


示例15: isDirect

 /**
  * {@inheritdoc}
  */
 public function isDirect()
 {
     if ($this->isDirect === null) {
         $this->isDirect = 020000 === (fstat(STDOUT)['mode'] & 0170000);
     }
     return $this->isDirect;
 }
开发者ID:muhammetardayildiz,项目名称:framework,代码行数:10,代码来源:Standard.php


示例16: testStat

 public function testStat()
 {
     $this->assertEquals(0, fstat($this->resource)['size']);
     fwrite($this->resource, 'foo');
     fflush($this->resource);
     $this->assertGreaterThan(0, fstat($this->resource)['size']);
 }
开发者ID:ktroach,项目名称:openstack-sdk-php,代码行数:7,代码来源:StreamWrapperFSTest.php


示例17: stat

 static function stat($path)
 {
     $fp = fopen($path, "r");
     $fstat = fstat($fp);
     fclose($fp);
     return _hx_anonymous(array("gid" => $fstat['gid'], "uid" => $fstat['uid'], "atime" => Date::fromTime($fstat['atime'] * 1000), "mtime" => Date::fromTime($fstat['mtime'] * 1000), "ctime" => Date::fromTime($fstat['ctime'] * 1000), "dev" => $fstat['dev'], "ino" => $fstat['ino'], "nlink" => $fstat['nlink'], "rdev" => $fstat['rdev'], "size" => $fstat['size'], "mode" => $fstat['mode']));
 }
开发者ID:marcdraco,项目名称:Webrathea,代码行数:7,代码来源:FileSystem.class.php


示例18: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $this->stderrIsNotStdout = fstat(\STDERR)['dev'] != fstat(\STDOUT)['dev'];
     $this->stderrSupportsColors = Console::streamSupportsAnsiColors(\STDERR);
     $this->stdoutSupportsColors = Console::streamSupportsAnsiColors(\STDOUT);
 }
开发者ID:ivan-chkv,项目名称:yii2-boost,代码行数:10,代码来源:StdoutTarget.php


示例19: dump

 public function dump($var)
 {
     $result = array();
     $stream_vars = stream_get_meta_data($var);
     $fstat = fstat($var);
     $real_path = realpath($stream_vars['uri']);
     $result['file'] = $real_path;
     $result['mode'] = $fstat['mode'];
     $result['size'] = $this->_formatSize($fstat['size']);
     $permissions = array('read');
     if (is_writable($real_path)) {
         $permissions[] = 'write';
     }
     if (is_executable($real_path)) {
         $permissions[] = 'execute';
     }
     if (is_link($real_path)) {
         $permissions[] = 'link';
     }
     if (is_dir($real_path)) {
         $permissions[] = 'directory';
     }
     $result['permissions'] = implode(', ', $permissions);
     return $result;
 }
开发者ID:jjspider277,项目名称:weddings,代码行数:25,代码来源:File.php


示例20: get_poison_emails

function get_poison_emails($seed, $count)
{
    global $globals;
    $fd = fopen($globals->poison->file, 'r');
    $size = fstat($fd);
    $size = $size['size'];
    $seed = crc32($seed . date('m-Y')) % $size;
    if ($seed < 0) {
        $seed = $size + $seed;
    }
    fseek($fd, $seed);
    fgets($fd);
    $emails = array();
    $i = 0;
    while (!feof($fd) && $i < $count) {
        $line = trim(fgets($fd));
        if (strlen($line) > 0) {
            $emails[] = $line;
            ++$seed;
        }
        ++$i;
    }
    fclose($fd);
    return $emails;
}
开发者ID:Ekleog,项目名称:platal,代码行数:25,代码来源:poison.inc.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ft_backlinks函数代码示例发布时间:2022-05-15
下一篇:
PHP fsockopen函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap