Свойство | Тип | Описание | |
---|---|---|---|
$mimeMagicFile | the path (or alias) of a PHP file containing MIME type information. |
Метод | Описание | |
---|---|---|
copyDirectory ( string $src, string $dst, array $options = [] ) | Copies a whole directory as another one. | |
createDirectory ( string $path, integer $mode = 509, boolean $recursive = true ) : boolean | Creates a new directory. | |
filterPath ( string $path, array $options ) : boolean | Checks if the given file path satisfies the filtering options. | |
findFiles ( string $dir, array $options = [] ) : array | Returns the files found under the specified directory and subdirectories. | |
getExtensionsByMimeType ( string $mimeType, string $magicFile = null ) : array | Determines the extensions by given MIME type. | |
getMimeType ( string $file, string $magicFile = null, boolean $checkExtension = true ) : string | Determines the MIME type of the specified file. | |
getMimeTypeByExtension ( string $file, string $magicFile = null ) : string | Determines the MIME type based on the extension name of the specified file. | |
localize ( string $file, string $language = null, string $sourceLanguage = null ) : string | Returns the localized version of a specified file. | |
normalizePath ( string $path, string $ds = DIRECTORY_SEPARATOR ) : string | Normalizes a file/directory path. | |
removeDirectory ( string $dir, array $options = [] ) | Removes a directory (and all its content) recursively. |
Метод | Описание | |
---|---|---|
loadMimeTypes ( string $magicFile ) : array | Loads MIME types from the specified file. |
Метод | Описание | |
---|---|---|
firstWildcardInPattern ( string $pattern ) : integer | boolean | Searches for the first wildcard character in the pattern. | |
lastExcludeMatchingFromList ( string $basePath, string $path, array $excludes ) : string | Scan the given exclude list in reverse to see whether pathname should be ignored. The first match (i.e. the last on the list), if any, determines the fate. Returns the element which matched, or null for undecided. | |
matchBasename ( string $baseName, string $pattern, integer | boolean $firstWildcard, integer $flags ) : boolean | Performs a simple comparison of file or directory names. | |
matchPathname ( string $path, string $basePath, string $pattern, integer | boolean $firstWildcard, integer $flags ) : boolean | Compares a path part against a pattern with optional wildcards. | |
normalizeOptions ( array $options ) : array | ||
parseExcludePattern ( string $pattern, boolean $caseSensitive ) : array | Processes the pattern, stripping special characters like / and ! from the beginning and settings flags instead. |
public static copyDirectory ( string $src, string $dst, array $options = [] ) | ||
$src | string | the source directory |
$dst | string | the destination directory |
$options | array | options for directory copy. Valid options are: - dirMode: integer, the permission to be set for newly copied directories. Defaults to 0775. - fileMode: integer, the permission to be set for newly copied files. Defaults to the current environment setting. - filter: callback, a PHP callback that is called for each directory or file. The signature of the callback should be: `function ($path)`, where `$path` refers the full path to be filtered. The callback can return one of the following values: * true: the directory or file will be copied (the "only" and "except" options will be ignored) * false: the directory or file will NOT be copied (the "only" and "except" options will be ignored) * null: the "only" and "except" options will determine whether the directory or file should be copied - only: array, list of patterns that the file paths should match if they want to be copied. A path matches a pattern if it contains the pattern string at its end. For example, '.php' matches all file paths ending with '.php'. Note, the '/' characters in a pattern matches both '/' and '\' in the paths. If a file path matches a pattern in both "only" and "except", it will NOT be copied. - except: array, list of patterns that the files or directories should match if they want to be excluded from being copied. A path matches a pattern if it contains the pattern string at its end. Patterns ending with '/' apply to directory paths only, and patterns not ending with '/' apply to file paths only. For example, '/a/b' matches all file paths ending with '/a/b'; and '.svn/' matches directory paths ending with '.svn'. Note, the '/' characters in a pattern matches both '/' and '\' in the paths. - caseSensitive: boolean, whether patterns specified at "only" or "except" should be case sensitive. Defaults to true. - recursive: boolean, whether the files under the subdirectories should also be copied. Defaults to true. - beforeCopy: callback, a PHP callback that is called before copying each sub-directory or file. If the callback returns false, the copy operation for the sub-directory or file will be cancelled. The signature of the callback should be: `function ($from, $to)`, where `$from` is the sub-directory or file to be copied from, while `$to` is the copy target. - afterCopy: callback, a PHP callback that is called after each sub-directory or file is successfully copied. The signature of the callback should be: `function ($from, $to)`, where `$from` is the sub-directory or file copied from, while `$to` is the copy target. |
public static createDirectory ( string $path, integer $mode = 509, boolean $recursive = true ) : boolean | ||
$path | string | path of the directory to be created. |
$mode | integer | the permission to be set for the created directory. |
$recursive | boolean | whether to create parent directories if they do not exist. |
Результат | boolean | whether the directory is created successfully |
public static filterPath ( string $path, array $options ) : boolean | ||
$path | string | the path of the file or directory to be checked |
$options | array | the filtering options. See [[findFiles()]] for explanations of the supported options. |
Результат | boolean | whether the file or directory satisfies the filtering options. |
public static findFiles ( string $dir, array $options = [] ) : array | ||
$dir | string | the directory under which the files will be looked for. |
$options | array | options for file searching. Valid options are: - `filter`: callback, a PHP callback that is called for each directory or file. The signature of the callback should be: `function ($path)`, where `$path` refers the full path to be filtered. The callback can return one of the following values: * `true`: the directory or file will be returned (the `only` and `except` options will be ignored) * `false`: the directory or file will NOT be returned (the `only` and `except` options will be ignored) * `null`: the `only` and `except` options will determine whether the directory or file should be returned - `except`: array, list of patterns excluding from the results matching file or directory paths. Patterns ending with slash ('/') apply to directory paths only, and patterns not ending with '/' apply to file paths only. For example, '/a/b' matches all file paths ending with '/a/b'; and `.svn/` matches directory paths ending with `.svn`. If the pattern does not contain a slash (`/`), it is treated as a shell glob pattern and checked for a match against the pathname relative to `$dir`. Otherwise, the pattern is treated as a shell glob suitable for consumption by `fnmatch(3)` `with the `FNM_PATHNAME` flag: wildcards in the pattern will not match a `/` in the pathname. For example, `views/*.php` matches `views/index.php` but not `views/controller/index.php`. A leading slash matches the beginning of the pathname. For example, `/*.php` matches `index.php` but not `views/start/index.php`. An optional prefix `!` which negates the pattern; any matching file excluded by a previous pattern will become included again. If a negated pattern matches, this will override lower precedence patterns sources. Put a backslash (`\`) in front of the first `!` for patterns that begin with a literal `!`, for example, `\!important!.txt`. Note, the '/' characters in a pattern matches both '/' and '\' in the paths. - `only`: array, list of patterns that the file paths should match if they are to be returned. Directory paths are not checked against them. Same pattern matching rules as in the `except` option are used. If a file path matches a pattern in both `only` and `except`, it will NOT be returned. - `caseSensitive`: boolean, whether patterns specified at `only` or `except` should be case sensitive. Defaults to `true`. - `recursive`: boolean, whether the files under the subdirectories should also be looked for. Defaults to `true`. |
Результат | array | files found under the directory, in no particular order. Ordering depends on the files system used. |
public static getExtensionsByMimeType ( string $mimeType, string $magicFile = null ) : array | ||
$mimeType | string | file MIME type. |
$magicFile | string | the path (or alias) of the file that contains all available MIME type information. If this is not set, the file specified by [[mimeMagicFile]] will be used. |
Результат | array | the extensions corresponding to the specified MIME type |
public static getMimeType ( string $file, string $magicFile = null, boolean $checkExtension = true ) : string | ||
$file | string | the file name. |
$magicFile | string | name of the optional magic database file (or alias), usually something like `/path/to/magic.mime`. This will be passed as the second parameter to [finfo_open()](http://php.net/manual/en/function.finfo-open.php) when the `fileinfo` extension is installed. If the MIME type is being determined based via [[getMimeTypeByExtension()]] and this is null, it will use the file specified by [[mimeMagicFile]]. |
$checkExtension | boolean | whether to use the file extension to determine the MIME type in case `finfo_open()` cannot determine it. |
Результат | string | the MIME type (e.g. `text/plain`). Null is returned if the MIME type cannot be determined. |
public static getMimeTypeByExtension ( string $file, string $magicFile = null ) : string | ||
$file | string | the file name. |
$magicFile | string | the path (or alias) of the file that contains all available MIME type information. If this is not set, the file specified by [[mimeMagicFile]] will be used. |
Результат | string | the MIME type. Null is returned if the MIME type cannot be determined. |
protected static loadMimeTypes ( string $magicFile ) : array | ||
$magicFile | string | the path (or alias) of the file that contains all available MIME type information. If this is not set, the file specified by [[mimeMagicFile]] will be used. |
Результат | array | the mapping from file extensions to MIME types |
public static localize ( string $file, string $language = null, string $sourceLanguage = null ) : string | ||
$file | string | the original file |
$language | string | the target language that the file should be localized to. If not set, the value of [[\yii\base\Application::language]] will be used. |
$sourceLanguage | string | the language that the original file is in. If not set, the value of [[\yii\base\Application::sourceLanguage]] will be used. |
Результат | string | the matching localized file, or the original file if the localized version is not found. If the target and the source language codes are the same, the original file will be returned. |
public static normalizePath ( string $path, string $ds = DIRECTORY_SEPARATOR ) : string | ||
$path | string | the file/directory path to be normalized |
$ds | string | the directory separator to be used in the normalized result. Defaults to `DIRECTORY_SEPARATOR`. |
Результат | string | the normalized file/directory path |
public static removeDirectory ( string $dir, array $options = [] ) | ||
$dir | string | the directory to be deleted recursively. |
$options | array | options for directory remove. Valid options are: - traverseSymlinks: boolean, whether symlinks to the directories should be traversed too. Defaults to `false`, meaning the content of the symlinked directory would not be deleted. Only symlink would be removed in that default case. |