<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ### :-: File文件處理類**** ***** ` ~~~ <?php // +---------------------------------------------------------------------- // | Created by PHPstorm: JRKAdmin框架 [ JRKAdmin ] // +---------------------------------------------------------------------- // | Copyright (c) 2019~2022 [LuckyHHY] All rights reserved. // +---------------------------------------------------------------------- // | SiteUrl: http://www.luckyhhy.cn // +---------------------------------------------------------------------- // | Author: LuckyHhy <jackhhy520@qq.com> // +---------------------------------------------------------------------- // | Date: 2020/3/18-10:53 // +---------------------------------------------------------------------- // | Description: // +---------------------------------------------------------------------- namespace Jrk; class File { /** * @param $dir * @return bool * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/3/18 * @name: mk_dir * @describe:目錄名 */ public static function mk_dir($dir) { $dir = rtrim($dir, '/') . '/'; if (!is_dir($dir)) { if (mkdir($dir, 0700, true) == false) { return false; } return true; } return true; } /** * @param $filename * @return bool|false|string * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/3/18 * @name: read_file * @describe:讀取文件內容 */ public static function read_file($filename) { $content = ''; if (function_exists('file_get_contents')) { @$content = file_get_contents($filename); } else { if (@$fp = fopen($filename, 'r')) { @$content = fread($fp, filesize($filename)); @fclose($fp); } } return $content; } /** * @param $filename * @param $writetext * @param string $openmod * @return bool * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/3/18 * @name: write_file * @describe:寫文件 */ public static function write_file($filename, $writetext, $openmod = 'w') { if (@$fp = fopen($filename, $openmod)) { flock($fp, 2); fwrite($fp, $writetext); fclose($fp); return true; } else { return false; } } /** * @param $dirName * @return bool * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/3/18 * @name: del_dir * @describe:刪除目錄 */ public static function del_dir($dirName) { if (!file_exists($dirName)) { return false; } $dir = opendir($dirName); while ($fileName = readdir($dir)) { $file = $dirName . '/' . $fileName; if ($fileName != '.' && $fileName != '..') { if (is_dir($file)) { self::del_dir($file); } else { unlink($file); } } } closedir($dir); return rmdir($dirName); } /** * @param $surDir * @param $toDir * @return bool * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/3/18 * @name: copy_dir * @describe:復制目錄 */ public static function copy_dir($surDir, $toDir) { $surDir = rtrim($surDir, '/') . '/'; $toDir = rtrim($toDir, '/') . '/'; if (!file_exists($surDir)) { return false; } if (!file_exists($toDir)) { self::mk_dir($toDir); } $file = opendir($surDir); while ($fileName = readdir($file)) { $file1 = $surDir . '/' . $fileName; $file2 = $toDir . '/' . $fileName; if ($fileName != '.' && $fileName != '..') { if (is_dir($file1)) { self::copy_dir($file1, $file2); } else { copy($file1, $file2); } } } closedir($file); return true; } /** * @param $dir * @return array * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/3/18 * @name: get_dirs * @describe: 列出目錄 */ public static function get_dirs($dir) { $dir = rtrim($dir, '/') . '/'; $dirArray[][] = null; if (false != ($handle = opendir($dir))) { $i = 0; $j = 0; while (false !== ($file = readdir($handle))) { if (is_dir($dir . $file)) { //判斷是否文件夾 $dirArray['dir'][$i] = $file; $i++; } else { $dirArray['file'][$j] = $file; $j++; } } closedir($handle); } return $dirArray; } /** * @param $dir * @return false|int * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/3/18 * @name: get_size * @describe:統計文件夾大小 */ public static function get_size($dir) { $dirlist = opendir($dir); $dirsize = 0; while (false !== ($folderorfile = readdir($dirlist))) { if ($folderorfile != "." && $folderorfile != "..") { if (is_dir("$dir/$folderorfile")) { $dirsize += self::get_size("$dir/$folderorfile"); } else { $dirsize += filesize("$dir/$folderorfile"); } } } closedir($dirlist); return $dirsize; } /** * @param $dir * @return bool * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/3/18 * @name: empty_dir * @describe:檢測是否為空文件夾 */ public static function empty_dir($dir) { return (($files = @scandir($dir)) && count($files) <= 2); } /** * @param $name * @param string $value * @param $path * @param bool $cached * @return array|bool|int|mixed|string * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/3/18 * @name: cache * @describe:文件緩存與文件讀取 */ public function cache($name, $value = '', $path = RUNTIME_PATH, $cached = true) { static $_cache = array(); $filename = $path . $name . '.php'; if ('' !== $value) { if (is_null($value)) { // 刪除緩存 return false !== strpos($name, '*') ? array_map("unlink", glob($filename)) : unlink($filename); } else { // 緩存數據 $dir = dirname($filename); // 目錄不存在則創建 if (!is_dir($dir)) { mkdir($dir, 0755, true); } $_cache[$name] = $value; return file_put_contents($filename, strip_whitespace("<?php\treturn " . var_export($value, true) . ";?>")); } } if (isset($_cache[$name]) && $cached == true) { return $_cache[$name]; } // 獲取緩存數據 if (is_file($filename)) { $value = include $filename; $_cache[$name] = $value; } else { $value = false; } return $value; } } ~~~ `
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看