PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 3.1.11.1
JetBackup – Backup, Restore & Migrate v3.1.11.1
3.1.23.6 3.1.23.5 3.1.23.3 3.1.22.4 3.1.22.3 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.8.1 1.4.9 1.5.0 1.5.1 1.5.1.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.10 1.6.11 1.6.12 1.6.13 1.6.15 1.6.5.1 1.6.8.8 1.6.9 1.6.9.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7.5 2.0.8.7 2.0.9.11 2.0.9.14 2.0.9.15 2.0.9.6 2.0.9.7 2.0.9.9 3.1.10.7 3.1.11.1 3.1.12.3 3.1.13.4 3.1.14.17 3.1.15.4 3.1.16.1 3.1.17.5 3.1.18.10 3.1.18.8 3.1.18.9 3.1.19.8 3.1.20.3 3.1.21.3 3.1.7.9 3.1.9.2 trunk 1.1.90 1.1.91 1.2.0 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2
backup / src / JetBackup / Destination / ScanDirIteratorFile.php
backup / src / JetBackup / Destination Last commit date
Integration 1 year ago Vendors 1 year ago .htaccess 1 year ago Destination.php 1 year ago DestinationDiskUsage.php 1 year ago DestinationFile.php 1 year ago DestinationWrapper.php 1 year ago ScanDirIterator.php 1 year ago ScanDirIteratorFile.php 1 year ago Tree.php 1 year ago index.html 1 year ago web.config 1 year ago
ScanDirIteratorFile.php
170 lines
1 <?php
2 /*
3 *
4 * JetBackup @ package
5 * Created By Idan Ben-Ezra
6 *
7 * Copyrights @ JetApps
8 * https://www.jetapps.com
9 *
10 **/
11 namespace JetBackup\Destination;
12
13 use JetBackup\Destination\Integration\DestinationFile;
14 use JetBackup\Exception\IOVanishedException;
15
16 if (!defined( '__JETBACKUP__')) die('Direct access is not allowed');
17
18 class ScanDirIteratorFile {
19
20 const IFMT = 0170000;
21 const IFDIR = 0040000;
22 const IFCHR = 0020000;
23 const IFBLK = 0060000;
24 const IFREG = 0100000;
25 const IFIFO = 0010000;
26 const IFLNK = 0120000;
27 const IFSOCK = 0140000;
28
29 private string $_path;
30 private string $_clean_path;
31 private array $_stat;
32 private bool $_pulled=false;
33
34 /**
35 * @param string $path
36 *
37 * @throws IOVanishedException
38 */
39 public function __construct(string $path) {
40 $this->_path = $path;
41 clearstatcache(true, $path);
42 $stat = @lstat($path);
43 if(!$stat) throw new IOVanishedException(sprintf("The file %s has vanished", $path));
44 $this->_stat = $stat;
45 }
46
47 /**
48 * @return string
49 */
50 public function getPath():string { return $this->_path; }
51
52 /**
53 * @return string
54 */
55 public function getFullPath():string {
56 if(!isset($this->_clean_path)) $this->_clean_path = preg_replace("#/+#", "/", $this->getPath());
57 return $this->_clean_path;
58 }
59
60 /**
61 * @return array
62 */
63 public function getStat():array { return $this->_stat; }
64
65 /**
66 * @return int
67 */
68 public function getMode():int { return (int) $this->_stat['mode']; }
69
70 /**
71 * @return int
72 */
73 public function getSize():int { return (int) $this->_stat['size']; }
74
75 /**
76 * @return int
77 */
78 public function getModifyTime():int { return (int) $this->_stat['mtime']; }
79
80 /**
81 * @return int
82 */
83 public function getGroupId():int { return (int) $this->_stat['gid']; }
84
85 /**
86 * @return int
87 */
88 public function getOwnerId():int { return (int) $this->_stat['uid']; }
89
90 /**
91 * @return string
92 */
93 public function getGroup():string {
94 $group = posix_getgrgid($this->getGroupId());
95 return $group ? $group['name'] : '';
96 }
97
98 /**
99 * @return string
100 */
101 public function getOwner():string {
102 $user = posix_getpwuid($this->getOwnerId());
103 return $user ? $user['name'] : '';
104 }
105
106 /**
107 * @return int
108 */
109 public function getType():int {
110 switch(($this->getMode() & self::IFMT)) {
111 case self::IFDIR: return DestinationFile::TYPE_DIRECTORY;
112 case self::IFCHR: return DestinationFile::TYPE_CHAR;
113 case self::IFBLK: return DestinationFile::TYPE_BLOCK;
114 case self::IFREG: return DestinationFile::TYPE_FILE;
115 case self::IFIFO: return DestinationFile::TYPE_FIFO;
116 case self::IFLNK: return DestinationFile::TYPE_LINK;
117 case self::IFSOCK: return DestinationFile::TYPE_SOCKET;
118 default: return DestinationFile::TYPE_UNKNOWN;
119 }
120 }
121
122 public function setPulled():void { $this->_pulled = true; }
123 public function isPulled():bool { return $this->_pulled; }
124
125 /**
126 * @return string
127 */
128 public function getLinkTarget():string { return $this->isLink() ? readlink($this->getFullPath()) : ''; }
129
130 /**
131 * @return bool
132 */
133 public function isDir():bool { return ($this->getMode() & self::IFMT) == self::IFDIR; }
134
135 /**
136 * @return bool
137 */
138 public function isLinkDir():bool { return $this->isLink() && is_dir(realpath($this->getFullPath())); }
139
140 /**
141 * @return bool
142 */
143 public function isFile():bool { return ($this->getMode() & self::IFMT) == self::IFREG; }
144
145 /**
146 * @return bool
147 */
148 public function isLink():bool { return ($this->getMode() & self::IFMT) == self::IFLNK; }
149
150 /**
151 * @return bool
152 */
153 public function isBlockDevice():bool { return ($this->getMode() & self::IFMT) == self::IFBLK; }
154
155 /**
156 * @return bool
157 */
158 public function isCharacterDevice():bool { return ($this->getMode() & self::IFMT) == self::IFCHR; }
159
160 /**
161 * @return bool
162 */
163 public function isFifo():bool { return ($this->getMode() & self::IFMT) == self::IFIFO; }
164
165 /**
166 * @return bool
167 */
168 public function isSocket():bool { return ($this->getMode() & self::IFMT) == self::IFSOCK; }
169 }
170