Pathologic was missing because of a .git folder inside.
[yaffs-website] / web / modules / contrib / hacked / src / hackedFileGroup.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\hacked\hackedFileGroup.
6  */
7
8 namespace Drupal\hacked;
9
10 use Drupal\Core\StringTranslation\StringTranslationTrait;
11
12 /**
13  * Represents a group of files on the local filesystem.
14  */
15 class hackedFileGroup {
16   use StringTranslationTrait;
17
18   var $base_path = '';
19   var $files = array();
20   var $files_hashes = array();
21   var $file_mtimes = array();
22
23   var $hasher;
24
25   /**
26    * Constructor.
27    */
28   function __construct($base_path) {
29     $this->base_path = $base_path;
30     $this->hasher = hacked_get_file_hasher();
31   }
32
33   /**
34    * Return a new hackedFileGroup listing all files inside the given $path.
35    */
36   static function fromDirectory($path) {
37     $filegroup = new hackedFileGroup($path);
38     // Find all the files in the path, and add them to the file group.
39     $filegroup->scan_base_path();
40     return $filegroup;
41   }
42
43   /**
44    * Return a new hackedFileGroup listing all files specified.
45    */
46   static function fromList($path, $files) {
47     $filegroup = new hackedFileGroup($path);
48     // Find all the files in the path, and add them to the file group.
49     $filegroup->files = $files;
50     return $filegroup;
51   }
52
53   /**
54    * Locate all sensible files at the base path of the file group.
55    */
56   function scan_base_path() {
57     $files = hacked_file_scan_directory($this->base_path, '/.*/', array(
58       '.',
59       '..',
60       'CVS',
61       '.svn',
62       '.git'
63     ));
64     foreach ($files as $file) {
65       $filename = str_replace($this->base_path . '/', '', $file->filename);
66       $this->files[] = $filename;
67     }
68   }
69
70   /**
71    * Hash all files listed in the file group.
72    */
73   function compute_hashes() {
74     foreach ($this->files as $filename) {
75       $this->files_hashes[$filename] = $this->hasher->hash($this->base_path . '/' . $filename);
76     }
77   }
78
79   /**
80    * Determine if the given file is readable.
81    */
82   function is_readable($file) {
83     return is_readable($this->base_path . '/' . $file);
84   }
85
86   /**
87    * Determine if a file exists.
88    */
89   function file_exists($file) {
90     return file_exists($this->base_path . '/' . $file);
91   }
92
93   /**
94    * Determine if the given file is binary.
95    */
96   function is_not_binary($file) {
97     return is_readable($this->base_path . '/' . $file) && !hacked_file_is_binary($this->base_path . '/' . $file);
98   }
99
100   function file_get_location($file) {
101     return $this->base_path . '/' . $file;
102   }
103
104 }