PluginProbe
JetBackup – Backup, Restore & Migrate / 3.1.21.3
JetBackup – Backup, Restore & Migrate v3.1.21.3
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 All 82 releases
backup / src / JetBackup / Archive / Scan / ScanFile.php
ScanFile.php
79 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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\Archive\Scan;
12
13 use JetBackup\Entities\Util;
14 use JetBackup\Exception\ArchiveException;
15 use JetBackup\JetBackup;
16
17 class ScanFile {
18
19 const IFMT = 0170000;
20 const IFDIR = 0040000;
21 const IFCHR = 0020000;
22 const IFBLK = 0060000;
23 const IFREG = 0100000;
24 const IFIFO = 0010000;
25 const IFLNK = 0120000;
26 const IFSOCK = 0140000;
27
28 private $_filename;
29 private $_path;
30 private $_clean_path;
31 private $_source;
32 private $_stat;
33
34 public function __construct($directory, $filename, $source) {
35 $this->_path = $directory;
36 $this->_filename = $filename;
37 $this->_source = $source;
38 clearstatcache(true, $directory . JetBackup::SEP . $filename);
39 $this->_stat = @lstat($directory . JetBackup::SEP . $filename);
40 if($this->_stat === false) throw new ArchiveException("Failed fetching information for file '$directory/$filename'");
41 }
42
43 public function getFilename() { return $this->_filename; }
44 public function getPath() { return $this->_path; }
45 public function getFullPath() {
46
47 if (!isset($this->_clean_path)) {
48 $dirSeparator = preg_quote(JetBackup::SEP, '#');
49 $this->_clean_path = preg_replace("#" . $dirSeparator . "+#", JetBackup::SEP, $this->getPath() . JetBackup::SEP . $this->getFilename());
50 }
51
52 return $this->_clean_path;
53 }
54 public function getCleanPath() { return substr($this->getFullPath(), strlen($this->_source)); }
55 public function getStat() { return $this->_stat; }
56 public function getMode() { return $this->_stat['mode']; }
57 public function getSize() { return $this->_stat['size']; }
58 public function getModifyTime() { return $this->_stat['mtime']; }
59 public function getGroupId() { return $this->_stat['gid']; }
60 public function getOwnerId() { return $this->_stat['uid']; }
61 public function getGroup() {
62 $group = Util::getgrgid($this->getGroupId());
63 return $group ? $group['name'] : '';
64 }
65 public function getOwner() {
66 $user = Util::getpwuid($this->getOwnerId());
67 return $user ? $user['name'] : '';
68 }
69
70 public function isDir() { return ($this->getMode() & self::IFMT) == self::IFDIR; }
71 public function isFile() { return ($this->getMode() & self::IFMT) == self::IFREG; }
72 public function isLink() { return ($this->getMode() & self::IFMT) == self::IFLNK; }
73 public function isBlockDevice() { return ($this->getMode() & self::IFMT) == self::IFBLK; }
74 public function isCharacterDevice() { return ($this->getMode() & self::IFMT) == self::IFCHR; }
75 public function isFifo() { return ($this->getMode() & self::IFMT) == self::IFIFO; }
76 public function isSocket() { return ($this->getMode() & self::IFMT) == self::IFSOCK; }
77
78 }
79