PHP 클래스 Piwik\Filesystem

파일 보기 프로젝트 열기: piwik/piwik 1 사용 예제들

공개 메소드들

메소드 설명
checkIfFileSystemIsNFS ( ) : boolean Checks if the filesystem Piwik stores sessions in is NFS or not. This check is done in order to avoid using file based sessions on NFS system, since on such a filesystem file locking can make file based sessions incredibly slow.
clearPhpCaches ( )
copy ( string $source, string $dest, boolean $excludePhp = false ) : true Copies a file from $source to $dest.
copyRecursive ( string $source, string $target, boolean $excludePhp = false ) Copies the contents of a directory recursively from $source to $target.
deleteAllCacheOnUpdate ( $pluginName = false ) Called on Core install, update, plugin enable/disable Will clear all cache that could be affected by the change in configuration being made
deleteFileIfExists ( string $pathToFile ) : boolean Deletes the given file if it exists.
directoryDiff ( $source, $target ) : string[] Computes the difference of directories. Compares $target against $source and returns a relative path to all files and directories in $target that are not present in $source.
getFileSize ( string $pathToFile, string $unit = 'B' ) : float | null Get the size of a file in the specified unit.
getPathToPiwikRoot ( ) : string ending WITHOUT slash
globr ( string $sDir, string $sPattern, integer $nFlags = null ) : array Recursively find pathnames that match a pattern.
isValidFilename ( string $filename ) : boolean Returns true if the string is a valid filename File names that start with a-Z or 0-9 and contain a-Z, 0-9, underscore(_), dash(-), and dot(.) will be accepted.
mkdir ( string $path ) Attempts to create a new directory. All errors are silenced.
realpath ( string $path ) : string Get canonicalized absolute path See http://php.net/realpath
remove ( string $file, boolean $silenceErrors = false ) Remove a file.
sortFilesDescByPathLength ( string[] $files ) : string[] Sort all given paths/filenames by its path length. Long path names will be listed first. This method can be useful if you have for instance a bunch of files/directories to delete. By sorting them by lengh you can make sure to delete all files within the folders before deleting the actual folder.
unlinkRecursive ( string $dir, boolean $deleteRootToo, Closure $beforeUnlink = null ) Recursively deletes a directory.
unlinkTargetFilesNotPresentInSource ( string $source, string $target ) Removes all files and directories that are present in the target directory but are not in the source directory.

비공개 메소드들

메소드 설명
createIndexFilesToPreventDirectoryListing ( $path ) in tmp/ (sub-)folder(s) we create empty index.htm|php files
getChmodForPath ( $path ) : integer
hasPHPExtension ( $file )
havePhpFilesSameContent ( $file1, $file2 )
isPathWithinTmpFolder ( $path ) : boolean
tryToCopyFileAndVerifyItWasCopied ( $source, $dest )

메소드 상세

checkIfFileSystemIsNFS() 공개 정적인 메소드

Note: In order to figure this out, we try to run the 'df' program. If the 'exec' or 'shell_exec' functions are not available, we can't do the check.
public static checkIfFileSystemIsNFS ( ) : boolean
리턴 boolean True if on an NFS filesystem, false if otherwise or if we can't use shell_exec or exec.

clearPhpCaches() 공개 정적인 메소드

public static clearPhpCaches ( )

copy() 공개 정적인 메소드

Copies a file from $source to $dest.
public static copy ( string $source, string $dest, boolean $excludePhp = false ) : true
$source string A path to a file, eg. './tmp/latest/index.php'. The file must exist.
$dest string A path to a file, eg. './index.php'. The file does not have to exist.
$excludePhp boolean Whether to avoid copying files if the file is related to PHP (includes .php, .tpl, .twig files).
리턴 true

copyRecursive() 공개 정적인 메소드

Copies the contents of a directory recursively from $source to $target.
public static copyRecursive ( string $source, string $target, boolean $excludePhp = false )
$source string A directory or file to copy, eg. './tmp/latest'.
$target string A directory to copy to, eg. '.'.
$excludePhp boolean Whether to avoid copying files if the file is related to PHP (includes .php, .tpl, .twig files).

deleteAllCacheOnUpdate() 공개 정적인 메소드

Called on Core install, update, plugin enable/disable Will clear all cache that could be affected by the change in configuration being made
public static deleteAllCacheOnUpdate ( $pluginName = false )

deleteFileIfExists() 공개 정적인 메소드

Deletes the given file if it exists.
public static deleteFileIfExists ( string $pathToFile ) : boolean
$pathToFile string
리턴 boolean true in case of success or if file does not exist, false otherwise. It might fail in case the file is not writeable.

directoryDiff() 공개 정적인 메소드

Computes the difference of directories. Compares $target against $source and returns a relative path to all files and directories in $target that are not present in $source.
public static directoryDiff ( $source, $target ) : string[]
$source
$target
리턴 string[]

getFileSize() 공개 정적인 메소드

Get the size of a file in the specified unit.
public static getFileSize ( string $pathToFile, string $unit = 'B' ) : float | null
$pathToFile string
$unit string eg 'B' for Byte, 'KB', 'MB', 'GB', 'TB'.
리턴 float | null Returns null if file does not exist or the size of the file in the specified unit

getPathToPiwikRoot() 공개 정적인 메소드

ending WITHOUT slash
public static getPathToPiwikRoot ( ) : string
리턴 string

globr() 공개 정적인 메소드

See {@link http://php.net/manual/en/function.glob.php glob} for more info.
public static globr ( string $sDir, string $sPattern, integer $nFlags = null ) : array
$sDir string directory The directory to glob in.
$sPattern string pattern The pattern to match paths against.
$nFlags integer `glob()` . See {@link http://php.net/manual/en/function.glob.php glob()}.
리턴 array The list of paths that match the pattern.

isValidFilename() 공개 정적인 메소드

File names beginning with anything but a-Z or 0-9 will be rejected (including .htaccess for example). File names containing anything other than above mentioned will also be rejected (file names with spaces won't be accepted).
public static isValidFilename ( string $filename ) : boolean
$filename string
리턴 boolean

mkdir() 공개 정적인 메소드

_Note: This function does **not** create directories recursively._
public static mkdir ( string $path )
$path string The path of the directory to create.

realpath() 공개 정적인 메소드

Get canonicalized absolute path See http://php.net/realpath
public static realpath ( string $path ) : string
$path string
리턴 string canonicalized absolute path

remove() 공개 정적인 메소드

Remove a file.
public static remove ( string $file, boolean $silenceErrors = false )
$file string
$silenceErrors boolean If true, no exception will be thrown in case removing fails.

sortFilesDescByPathLength() 공개 정적인 메소드

Sort all given paths/filenames by its path length. Long path names will be listed first. This method can be useful if you have for instance a bunch of files/directories to delete. By sorting them by lengh you can make sure to delete all files within the folders before deleting the actual folder.
public static sortFilesDescByPathLength ( string[] $files ) : string[]
$files string[]
리턴 string[]

unlinkRecursive() 공개 정적인 메소드

Recursively deletes a directory.
public static unlinkRecursive ( string $dir, boolean $deleteRootToo, Closure $beforeUnlink = null )
$dir string Path of the directory to delete.
$deleteRootToo boolean If true, `$dir` is deleted, otherwise just its contents.
$beforeUnlink Closure An optional closure to execute on a file path before unlinking.

unlinkTargetFilesNotPresentInSource() 공개 정적인 메소드

Removes all files and directories that are present in the target directory but are not in the source directory.
public static unlinkTargetFilesNotPresentInSource ( string $source, string $target )
$source string Path to the source directory
$target string Path to the target