hackedFileGroup.php in Hacked! 8.2
File
src/hackedFileGroup.php
View source
<?php
namespace Drupal\hacked;
use Drupal\Core\StringTranslation\StringTranslationTrait;
class hackedFileGroup {
use StringTranslationTrait;
var $base_path = '';
var $files = array();
var $files_hashes = array();
var $file_mtimes = array();
var $hasher;
function __construct($base_path) {
$this->base_path = $base_path;
$this->hasher = hacked_get_file_hasher();
}
static function fromDirectory($path) {
$filegroup = new hackedFileGroup($path);
$filegroup
->scan_base_path();
return $filegroup;
}
static function fromList($path, $files) {
$filegroup = new hackedFileGroup($path);
$filegroup->files = $files;
return $filegroup;
}
function scan_base_path() {
$files = hacked_file_scan_directory($this->base_path, '/.*/', array(
'.',
'..',
'CVS',
'.svn',
'.git',
));
foreach ($files as $file) {
$filename = str_replace($this->base_path . '/', '', $file->filename);
$this->files[] = $filename;
}
}
function compute_hashes() {
foreach ($this->files as $filename) {
$this->files_hashes[$filename] = $this->hasher
->hash($this->base_path . '/' . $filename);
}
}
function is_readable($file) {
return is_readable($this->base_path . '/' . $file);
}
function file_exists($file) {
return file_exists($this->base_path . '/' . $file);
}
function is_not_binary($file) {
return is_readable($this->base_path . '/' . $file) && !hacked_file_is_binary($this->base_path . '/' . $file);
}
function file_get_location($file) {
return $this->base_path . '/' . $file;
}
}