PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / trunk
JetBackup – Backup, Restore & Migrate vtrunk
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 / DestinationFile.php
backup / src / JetBackup / Destination Last commit date
Integration 1 year ago Vendors 1 month ago .htaccess 1 year ago Destination.php 1 month ago DestinationDiskUsage.php 1 year ago DestinationFile.php 1 year ago DestinationWrapper.php 1 year ago ScanDirIterator.php 1 year ago ScanDirIteratorFile.php 9 months ago Tree.php 1 year ago index.html 1 year ago web.config 1 year ago
DestinationFile.php
213 lines
1 <?php
2
3 namespace JetBackup\Destination;
4
5 use JetBackup\Data\ArrayData;
6 use JetBackup\Destination\Integration\DestinationFile as iDestinationFile;
7 use JetBackup\Entities\Util;
8
9 defined( '__JETBACKUP__' ) or die( 'Restricted access' );
10
11 class DestinationFile extends ArrayData implements iDestinationFile {
12
13 const FILE_ID = 'file_id';
14 const FILES_DIR = 'files_dir';
15 const PATH = 'path';
16 const NAME = 'name';
17 const TYPE = 'type';
18 const SIZE = 'size';
19 const MTIME = 'mtime';
20 const OWNER = 'owner';
21 const GROUP = 'group';
22 const FILE_DATA = 'file_data';
23 const PERMISSIONS = 'permissions';
24 const LINK_TARGET = 'link_target';
25
26 /**
27 * @return string
28 */
29 public function getPath(): string { return $this->get(self::PATH); }
30
31 /**
32 * @param string $path
33 *
34 * @return void
35 */
36 public function setPath(string $path):void { $this->set(self::PATH, $path); }
37
38 /**
39 * @return string
40 */
41 public function getName(): string { return $this->get(self::NAME); }
42
43 /**
44 * @param string $name
45 *
46 * @return void
47 */
48 public function setName(string $name):void { $this->set(self::NAME, $name); }
49
50 /**
51 * @return string
52 */
53 public function getFullPath(): string { return preg_replace("/^\/+/", "", $this->getPath() . '/' . $this->getName()); }
54
55 /**
56 * @return int
57 */
58 public function getType(): int { return (int) $this->get(self::TYPE, 0); }
59
60 /**
61 * @param int $type
62 *
63 * @return void
64 */
65 public function setType(int $type):void { $this->set(self::TYPE, $type); }
66
67 /**
68 * @return int
69 */
70 public function getSize(): int { return (int) $this->get(self::SIZE, 0); }
71
72 /**
73 * @param int $size
74 *
75 * @return void
76 */
77 public function setSize(int $size):void { $this->set(self::SIZE, $size); }
78
79 /**
80 * @return int
81 */
82 public function getModifyTime(): int { return (int) $this->get(self::MTIME, 0); }
83
84 /**
85 * @param int $time
86 *
87 * @return void
88 */
89 public function setModifyTime(int $time):void { $this->set(self::MTIME, $time); }
90
91 /**
92 * @return string
93 */
94 public function getOwner(): string { return $this->get(self::OWNER, 'root'); }
95
96 /**
97 * @param string $owner
98 *
99 * @return void
100 */
101 public function setOwner(string $owner):void { $this->set(self::OWNER, $owner); }
102
103 /**
104 * @return string
105 */
106 public function getGroup(): string { return $this->get(self::GROUP, 'root'); }
107
108 /**
109 * @param string $group
110 *
111 * @return void
112 */
113 public function setGroup(string $group):void { $this->set(self::GROUP, $group); }
114
115 /**
116 * @return int
117 */
118 public function getPermissions():int { return $this->get(self::PERMISSIONS, 0000); }
119
120 /**
121 * @param int $permissions
122 *
123 * @return void
124 */
125 public function setPermissions(int $permissions):void { $this->set(self::PERMISSIONS, $permissions); }
126
127 /**
128 * @return string
129 */
130 public function getLinkTarget():string { return $this->get(self::LINK_TARGET); }
131
132 /**
133 * @param string $target
134 *
135 * @return void
136 */
137 public function setLinkTarget(string $target):void { $this->set(self::LINK_TARGET, $target); }
138
139 /**
140 * @return string
141 */
142 public function getFileId():string { return $this->get(self::FILE_ID); }
143
144 /**
145 * @param string $id
146 *
147 * @return void
148 */
149 public function setFileId(string $id):void { $this->set(self::FILE_ID, $id); }
150
151 /**
152 * @return string
153 */
154 public function getFilesDir():string { return $this->get(self::FILES_DIR); }
155
156 /**
157 * @param string $dir
158 *
159 * @return void
160 */
161 public function setFilesDir(string $dir):void { $this->set(self::FILES_DIR, $dir); }
162
163 /**
164 * @return string
165 */
166 public function getFileData():string { return $this->get(self::FILE_DATA); }
167
168 /**
169 * @param string $data
170 *
171 * @return void
172 */
173 public function setFileData(string $data):void { $this->set(self::FILE_DATA, $data); }
174
175 /**
176 * @param array $file
177 *
178 * @return DestinationFile
179 */
180 public static function genFile(array $file):DestinationFile {
181
182 $item = new DestinationFile();
183
184 if(isset($file['path'])) {
185 $item->setPath(Util::mb_dirname($file['path']));
186 $item->setName(Util::mb_basename($file['path']));
187 }
188
189 if(isset($file['perms'])) {
190 $type = self::TYPE_UNKNOWN;
191 $item->setPermissions(/*sprintf("0%o", (0777 & $file['perms']))*/$file['perms']);
192 switch($file['perms'] & 0170000) {
193 case 0100000: $type = self::TYPE_FILE; break;
194 case 0120000: $type = self::TYPE_LINK; break;
195 case 0040000: $type = self::TYPE_DIRECTORY; break;
196 case 0060000: $type = self::TYPE_BLOCK; break;
197 case 0010000: $type = self::TYPE_FIFO; break;
198 }
199 $item->setType($type);
200 }
201
202 if(isset($file['size'])) $item->setSize($file['size']);
203 if(isset($file['mtime'])) $item->setModifyTime(intval($file['mtime']));
204 if(isset($file['user'])) $item->setOwner($file['user']);
205 if(isset($file['group'])) $item->setGroup($file['group']);
206 if(isset($file['link'])) $item->setLinkTarget($file['link']);
207 if(isset($file['file_id'])) $item->setFileId($file['file_id']);
208 if(isset($file['files_dir'])) $item->setFilesDir($file['files_dir']);
209 if(isset($file['data'])) $item->setFileData($file['data']);
210
211 return $item;
212 }
213 }