Piwik\Filesystem::remove PHP Méthode

remove() public static méthode

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.
    public static function remove($file, $silenceErrors = false)
    {
        if (!file_exists($file)) {
            return;
        }
        $result = @unlink($file);
        // Testing if the file still exist avoids race conditions
        if (!$result && file_exists($file)) {
            if ($silenceErrors) {
                Log::warning('Failed to delete file ' . $file);
            } else {
                throw new \RuntimeException('Unable to delete file ' . $file);
            }
        }
    }

Usage Example

 public function delete()
 {
     if ($this->exists()) {
         try {
             Filesystem::remove($this->getAbsoluteLocation());
         } catch (Exception $e) {
             throw new Exception("Unable to delete merged file : " . $this->getAbsoluteLocation() . ". Please delete the file and refresh");
         }
         // try to remove compressed version of the merged file.
         Filesystem::remove($this->getAbsoluteLocation() . ".deflate", true);
         Filesystem::remove($this->getAbsoluteLocation() . ".gz", true);
     }
 }
All Usage Examples Of Piwik\Filesystem::remove