Exemplo n.º 1
0
/**
 * Change the $dest_file's extension to $source_file's extension
 * @author Wilson Zeng
*/
function copy_fileext($source_file, $dest_file)
{
    return remove_fileext($dest_file) . '.' . get_fileext($source_file);
}
Exemplo n.º 2
0
/**
 * @todo   pathinfo()
 * @param  string $path
 * @return string
 */
function get_pathinfo($path)
{
    $info = array('dirname' => get_dirname($path), 'basename' => get_basename($path), 'filename' => get_filename($path), 'extension' => get_fileext($path));
    return $info;
}
 /**
  * 返回给定目录的文件 列表详单
  *
  * @param unknown_type $path
  * @param unknown_type $deep
  * @return unknown
  */
 public function nlist($path, &$list = array())
 {
     $list = array('dirs' => array(), 'files' => array());
     $path2 = $this->get_gpath($path);
     if (!is_dir($path2)) {
         $this->error = '文件系统错误,目录不存在';
         return false;
     } else {
         if (!is_readable($path2)) {
             $this->error = '文件系统错误,没有访问权限';
             return false;
         }
     }
     $tlist = glob($path2 . '{,.}*', GLOB_MARK | GLOB_BRACE) or array();
     foreach ($tlist as $file2) {
         if ('.' == basename($file2) || '..' == basename($file2)) {
             continue;
         }
         $file = str_replace('\\', '/', $file2);
         $file = $this->get_upath($file);
         $stat = stat($file2);
         if (!$stat) {
             $stat = array('size' => 0, 'atime' => 0, 'ctime' => 0, 'mtime' => 0);
         }
         $stat['name'] = get_basename($file);
         $stat['path'] = $path . $stat['name'];
         $stat['fsize'] = get_deal_size($stat['size']);
         $stat['chmod'] = get_deal_chmod($file2, false);
         $stat['fchmod'] = get_deal_chmod($file2, true);
         $stat['fatime'] = date('Y-m-d H:i:s', $stat['atime']);
         $stat['fctime'] = date('Y-m-d H:i:s', $stat['ctime']);
         $stat['fmtime'] = date('Y-m-d H:i:s', $stat['mtime']);
         if ('/' == substr($file, -1, 1)) {
             $stat['path'] .= '/';
             $stat['type'] = 'dir';
             $stat['ext'] = '_dir';
         } else {
             $stat['type'] = 'file';
             $stat['ext'] = get_fileext($file);
         }
         $list["{$stat['type']}s"][] = $stat;
     }
     unset($tlist, $stat, $path, $path2, $file, $file2);
     return true;
 }