Piwik\Filesystem::deleteFileIfExists PHP Méthode

deleteFileIfExists() public static méthode

Deletes the given file if it exists.
public static deleteFileIfExists ( string $pathToFile ) : boolean
$pathToFile string
Résultat boolean true in case of success or if file does not exist, false otherwise. It might fail in case the file is not writeable.
    public static function deleteFileIfExists($pathToFile)
    {
        if (!file_exists($pathToFile)) {
            return true;
        }
        return @unlink($pathToFile);
    }

Usage Example

 private static function deleteIfLastModifiedBefore14August2014($path)
 {
     $modifiedTime = filemtime($path);
     if ($modifiedTime && $modifiedTime < 1408000000) {
         Filesystem::deleteFileIfExists($path);
     }
 }
All Usage Examples Of Piwik\Filesystem::deleteFileIfExists