Файл, ассоциированный с объектом
@param null|array|string $new Информация о новом файле. Полный путь к новому файлу или сведения из $_FILES
@param bool $root Возвращать полный путь или от директории сайта
@return null|string
171696
function file($new = null, $root = false)
    {
        // Установка нового файла
        if (isset($new)){
            if (empty($new)){
                $this->change('file', '');
            }else{
                if (is_string($new)){
                    $new = [
                        'tmp_name'	=> $new,
                        'name' => basename($new),
                        'size' => @filesize($new),
                        'error'	=> is_file($new)? 0 : true
                    ];
                }
                if (empty($new['name']) && $this->is_file()){
                    $new['name'] = $this->name().'.'.File::fileExtention($this->file());
                }
                $this->change('file', $new);
            }
            $this->change('is_default_file', false);
            $this->_def_file = null;
        }
        // Возврат пути к текущему файлу, если есть
        if ($this->is_file()){
            if (($proto = $this->is_default_file(null, true)) && $proto->is_exists()){
                return $proto->file(null, $root);
            }else{
                if (is_array($this->_attributes['file'])){
                    return $this->_attributes['file'];
                }
                return $this->dir($root).$this->_attributes['file'];
            }
        }
        return null;
    }
1305471
public static function file($index = null, $default = null)
	{
		return (func_num_args() === 0) ? $_FILES : \Arr::get($_FILES, $index, $default);
	}
229222
protected function folder($root)
    {
        $path = $root.'app/mails';

        if (!File::isDirectory($path)) {
            File::makeDirectory($path);
        }

        return $path;
    }
1207284
private function getNewFileLocationPayload($newPath)
    {
        $pathinfo = pathinfo($newPath);
        $newParentDir = ($pathinfo['dirname'] != '.') ? $pathinfo['dirname'] : '';
        $newFilename = $pathinfo['basename'];

        $payload = [
            'name' => $newFilename,
            'parentReference' => ['path' => $this->getParentReferenceFolder($newParentDir)],
        ];

        return $payload;
    }
1354611
def file_new(input_params={}, always_retry=True, **kwargs):
    
    input_params_cp = Nonce.update_nonce(input_params)
    return DXHTTPRequest('/file/new', input_params_cp, always_retry=always_retry, **kwargs)
383540
public static function copy($oldDir, $newDir): bool
    {
        $oldDir = self::pathFormat($oldDir);
        $newDir = self::pathFormat($newDir);

        if (!is_dir($oldDir)) {
            throw new NotFoundException('复制失败：' . $oldDir . ' 不存在！');
        }

        $newDir = self::create($newDir);

        foreach (glob($oldDir . '*') as $v) {
            $newFile = $newDir . basename($v);//文件

            //文件存在，跳过复制它
            if (file_exists($newFile)) {
                continue;
            }

            if (is_dir($v)) {
                self::copy($v, $newFile);
            } else {
                copy($v, $newFile);//是文件就复制过来
                @chmod($newFile, 0664);// 权限 0777
            }
        }

        return true;
    }
895787
public static function load($files, $options, $previous = null)
    {
        self::initialize($files, $options);
        if ($previous != null && is_array($previous)) {
            self::append($files, $options, $previous);
        } else {
            return self::data();
        }
    }
529642
public function replaceInFile($old, $new, $append = 0)
    {
        $contents = $this->previous;
        $replaceWith = preg_replace("~$old\n?~", "$new\n", $contents);

        file_put_contents($this->getPath(), $replaceWith, $append);

        return $this;
    }
446163
protected function filter_files( $files ) {
		if ( ! $files ) {
			return null;
		}

		foreach ( $files as $key => $file ) {
			if ( is_array( $file ) ) {
				$files[ $key ] = $this->filter_files( $files[ $key ] );
			}

			if ( empty( $files[ $key ] ) ) {
				unset( $files[ $key ] );
			}
		}

		return $files;
	}
530337
public static function getFilesArray($root)
	{
		$alias=array();
		$directories=array();
		$last_letter=$root[strlen($root)-1];
		$root= ($last_letter=='\\' || $last_letter=='/')? $root : $root.DIRECTORY_SEPARATOR;

		$directories[]=$root;

		while (sizeof($directories)) {
			$dir=array_pop($directories);
			if ($handle=opendir($dir)) {
				while (FALSE!==($file=readdir($handle))) {
					if ($file=='.' || $file=='..') {
						continue;
						}
					$file=$dir.$file;
					if (is_dir($file)) {
						$directory_path=$file.DIRECTORY_SEPARATOR;
						array_push($directories, $directory_path);
						}
					elseif (is_file($file)) {
						$key=basename($file);
						$alias[substr($key, 1, strpos($key, '.')-1)]=$file;
						}
					}
				closedir($handle);
				}
			}

		return $alias;
	}
174370
public function put($files, $root = 'public_html')
    {
        if ($this->isConnected() === true) {
            foreach ($files as $key => $value) {
                ftp_put($this->getConnection(), $server_root.'/'.$value, $value, FTP_ASCII);
            }
        } else {
            return false;
        }
    }
422151
public static function createUploadableFile($config, $currentFilename = null, $newFileData = null)
    {
        $className = '\\PhpDevil\\framework\\base\\helpers\\files\\' . ucfirst($config['type']) . 'File';
        return new $className($config, $currentFilename, $newFileData);
    }
1361698
public static function searchFile($root, $pattern = '*', $flags = 0)
    {
        $dirs = self::listDirs($root);
        array_unshift($dirs, $root);
        
        $foundFiles = [];
        
        if ($pattern instanceof \Closure) {
            $closure = $pattern;
            $pattern = '*';
        } else {
            $closure = null;
        }
        
        foreach ($dirs as $dir) {
            $filePatt = $dir . '/' . $pattern;
            $files = glob($filePatt, $flags);
            
            if ($closure) {
                foreach ($files as $file) {
                    if ($closure($file)) {
                        $foundFiles[] = $file;
                    }
                }
            } else {
                if ($files) {
                    $foundFiles = array_merge($foundFiles, $files);
                }
            }
        }
        
        return $foundFiles;
    }
800209
public function getFiles($file = null)
    {
        if ($file !== null) {
            $return = array();
            foreach ($this->_files as $name => $content) {
                if ($name === $file) {
                    $return[$file] = $this->_files[$name];
                }

                if ($content['name'] === $file) {
                    $return[$name] = $this->_files[$name];
                }
            }

            if (count($return) === 0) {
                require_once 'Zend/Validate/Exception.php';
                throw new Zend_Validate_Exception("The file '$file' was not found");
            }

            return $return;
        }

        return $this->_files;
    }
37097
public function validateFile(FileInfo $fileInfo, $new_filename = null)
    {
        $file_path = $fileInfo->getFilePath(true);

        if (!is_dir($file_path)) {
            $fm = new Filesystem();
            $tmp_dir = $this->createTmpDir($fm);
            $fm->copy($file_path, $tmp_dir . FileManager::DS . $fileInfo->getFilename());

            if (!is_null($new_filename)) {
                $new_filename = basename($new_filename);
                $fm->rename($tmp_dir . FileManager::DS . $fileInfo->getFilename(),
                    $tmp_dir . FileManager::DS . $new_filename);
            }

            $this->checkFileType($fm, $tmp_dir);
        }
    }
929140
protected function deleteFolderContent($data, $root = '', $force = false)
    {
        $root = FileUtilities::fixFolderPath($root);
        $out = [];
        if (!empty($data)) {
            foreach ($data as $key => $resource) {
                $path = array_get($resource, 'path');
                $name = array_get($resource, 'name');

                if (!empty($path)) {
                    $fullPath = $path;
                } else {
                    if (!empty($name)) {
                        $fullPath = $root . '/' . $name;
                    } else {
                        throw new BadRequestException('No path or name provided for resource.');
                    }
                }

                switch (array_get($resource, 'type')) {
                    case 'file':
                        $out[$key] = ['name' => $name, 'path' => $path, 'type' => 'file'];
                        try {
                            $this->driver->deleteFile($this->container, $fullPath);
                        } catch (\Exception $ex) {
                            $out[$key]['error'] = ['message' => $ex->getMessage()];
                        }
                        break;
                    case 'folder':
                        $out[$key] = ['name' => $name, 'path' => $path, 'type' => 'folder'];
                        try {
                            $this->driver->deleteFolder($this->container, $fullPath, $force);
                        } catch (\Exception $ex) {
                            $out[$key]['error'] = ['message' => $ex->getMessage()];
                        }
                        break;
                }
            }
        }

        return $out;
    }
1321224
public function file($name = null, $default = null)
    {
        $files = $this->request['files'];

        if (isset($name)) {
            return !empty($files[$name]['name']) ? $files[$name] : $default;
        }

        return $files;
    }