|
1
|
|
|
<?php |
|
2
|
|
|
// src/VersionControl/GitCommandBundle/Entity/FileInfo.php |
|
3
|
|
|
|
|
4
|
|
|
/* |
|
5
|
|
|
* This file is part of the GitCommandBundle package. |
|
6
|
|
|
* |
|
7
|
|
|
* (c) Paul Schweppe <[email protected]> |
|
8
|
|
|
* |
|
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
10
|
|
|
* file that was distributed with this source code. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace VersionControl\GitCommandBundle\Entity; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Remote File Info. |
|
17
|
|
|
* |
|
18
|
|
|
* @author Paul Schweppe <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class RemoteFileInfo implements FileInfoInterface |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* Absolute path to file. |
|
24
|
|
|
* |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $fullPath; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* File Extension. |
|
31
|
|
|
* |
|
32
|
|
|
* @var string |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $extension; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* File name without any path information. |
|
38
|
|
|
* |
|
39
|
|
|
* @var string |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $filename; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Path without the filename. |
|
45
|
|
|
* |
|
46
|
|
|
* @var string |
|
47
|
|
|
*/ |
|
48
|
|
|
protected $path; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* File permissions. |
|
52
|
|
|
* |
|
53
|
|
|
* @var string |
|
54
|
|
|
*/ |
|
55
|
|
|
protected $perms; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Filesize in bytes. |
|
59
|
|
|
* |
|
60
|
|
|
* @var int |
|
61
|
|
|
*/ |
|
62
|
|
|
protected $size; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @var integer |
|
66
|
|
|
*/ |
|
67
|
|
|
protected $uid; |
|
68
|
|
|
|
|
69
|
|
|
protected $gid; |
|
70
|
|
|
|
|
71
|
|
|
protected $mode; |
|
72
|
|
|
|
|
73
|
|
|
protected $aTime; |
|
74
|
|
|
|
|
75
|
|
|
protected $mTime; |
|
76
|
|
|
|
|
77
|
|
|
protected $type; |
|
78
|
|
|
|
|
79
|
|
|
protected $fileTypes; |
|
80
|
|
|
|
|
81
|
|
|
protected $gitPath; |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Git log Entity. |
|
85
|
|
|
* |
|
86
|
|
|
* @var GitLog |
|
87
|
|
|
*/ |
|
88
|
|
|
protected $gitLog; |
|
89
|
|
|
|
|
90
|
|
|
public function __construct($fileData) |
|
91
|
|
|
{ |
|
92
|
|
|
foreach ($fileData as $key => $value) { |
|
93
|
|
|
$setMethod = 'set' . ucfirst($key); |
|
94
|
|
|
if (method_exists($this, $setMethod)) { |
|
95
|
|
|
$this->$setMethod($value); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
$this->fileTypes = array( |
|
100
|
|
|
1 => 'NET_SFTP_TYPE_REGULAR', |
|
101
|
|
|
2 => 'NET_SFTP_TYPE_DIRECTORY', |
|
102
|
|
|
3 => 'NET_SFTP_TYPE_SYMLINK', |
|
103
|
|
|
4 => 'NET_SFTP_TYPE_SPECIAL', |
|
104
|
|
|
5 => 'NET_SFTP_TYPE_UNKNOWN', |
|
105
|
|
|
// the followin types were first defined for use in SFTPv5+ |
|
106
|
|
|
// http://tools.ietf.org/html/draft-ietf-secsh-filexfer-05#section-5.2 |
|
107
|
|
|
6 => 'NET_SFTP_TYPE_SOCKET', |
|
108
|
|
|
7 => 'NET_SFTP_TYPE_CHAR_DEVICE', |
|
109
|
|
|
8 => 'NET_SFTP_TYPE_BLOCK_DEVICE', |
|
110
|
|
|
9 => 'NET_SFTP_TYPE_FIFO', |
|
111
|
|
|
); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
public function getFullPath() |
|
115
|
|
|
{ |
|
116
|
|
|
return $this->fullPath; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public function getExtension() |
|
120
|
|
|
{ |
|
121
|
|
|
return $this->extension; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
public function getFilename() |
|
125
|
|
|
{ |
|
126
|
|
|
return $this->filename; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
public function getPath() |
|
130
|
|
|
{ |
|
131
|
|
|
return $this->path; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
public function getPerms() |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->perms; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
public function getSize() |
|
140
|
|
|
{ |
|
141
|
|
|
return $this->size; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
public function getUid(): int |
|
145
|
|
|
{ |
|
146
|
|
|
return $this->uid; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
public function getGid() |
|
150
|
|
|
{ |
|
151
|
|
|
return $this->gid; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
public function getMode() |
|
155
|
|
|
{ |
|
156
|
|
|
return $this->mode; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
public function getATime() |
|
160
|
|
|
{ |
|
161
|
|
|
return $this->aTime; |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
public function getMTime() |
|
165
|
|
|
{ |
|
166
|
|
|
return $this->mTime; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
public function getType() |
|
170
|
|
|
{ |
|
171
|
|
|
return $this->type; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
public function setFullPath($fullPath) |
|
175
|
|
|
{ |
|
176
|
|
|
$this->fullPath = $fullPath; |
|
177
|
|
|
|
|
178
|
|
|
return $this; |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
public function setExtension($extension) |
|
182
|
|
|
{ |
|
183
|
|
|
$this->extension = $extension; |
|
184
|
|
|
|
|
185
|
|
|
return $this; |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
public function setFilename($filename) |
|
189
|
|
|
{ |
|
190
|
|
|
$this->filename = $filename; |
|
191
|
|
|
$pathParts = pathinfo($filename); |
|
192
|
|
|
if (array_key_exists('extension', $pathParts)) { |
|
193
|
|
|
$this->setExtension($pathParts['extension']); |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
return $this; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
public function setPath($path) |
|
200
|
|
|
{ |
|
201
|
|
|
$this->path = $path; |
|
202
|
|
|
|
|
203
|
|
|
return $this; |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
public function setPerms($perms) |
|
207
|
|
|
{ |
|
208
|
|
|
$this->perms = $perms; |
|
209
|
|
|
|
|
210
|
|
|
return $this; |
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
public function setPermissions($perms) |
|
214
|
|
|
{ |
|
215
|
|
|
return $this->setPerms($perms); |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
public function setSize($size) |
|
219
|
|
|
{ |
|
220
|
|
|
$this->size = $size; |
|
221
|
|
|
|
|
222
|
|
|
return $this; |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
public function setUid($uid) |
|
226
|
|
|
{ |
|
227
|
|
|
$this->uid = $uid; |
|
228
|
|
|
|
|
229
|
|
|
return $this; |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
public function setGid($gid) |
|
233
|
|
|
{ |
|
234
|
|
|
$this->gid = $gid; |
|
235
|
|
|
|
|
236
|
|
|
return $this; |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
public function setMode($mode) |
|
240
|
|
|
{ |
|
241
|
|
|
$this->mode = $mode; |
|
242
|
|
|
|
|
243
|
|
|
return $this; |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
public function setATime($aTime) |
|
247
|
|
|
{ |
|
248
|
|
|
$this->aTime = $aTime; |
|
249
|
|
|
|
|
250
|
|
|
return $this; |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
public function setMTime($mTime) |
|
254
|
|
|
{ |
|
255
|
|
|
$this->mTime = $mTime; |
|
256
|
|
|
|
|
257
|
|
|
return $this; |
|
258
|
|
|
} |
|
259
|
|
|
|
|
260
|
|
|
public function setType($type) |
|
261
|
|
|
{ |
|
262
|
|
|
$this->type = $type; |
|
263
|
|
|
|
|
264
|
|
|
return $this; |
|
265
|
|
|
} |
|
266
|
|
|
|
|
267
|
|
|
public function getGitPath() |
|
268
|
|
|
{ |
|
269
|
|
|
return $this->gitPath; |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
public function setGitPath($gitPath) |
|
273
|
|
|
{ |
|
274
|
|
|
$this->gitPath = $gitPath; |
|
275
|
|
|
|
|
276
|
|
|
return $this; |
|
277
|
|
|
} |
|
278
|
|
|
|
|
279
|
|
|
/** |
|
280
|
|
|
* @return GitLog |
|
281
|
|
|
*/ |
|
282
|
|
|
public function getGitLog() |
|
283
|
|
|
{ |
|
284
|
|
|
return $this->gitLog; |
|
285
|
|
|
} |
|
286
|
|
|
|
|
287
|
|
|
public function setGitLog(GitLog $gitLog) |
|
288
|
|
|
{ |
|
289
|
|
|
$this->gitLog = $gitLog; |
|
290
|
|
|
|
|
291
|
|
|
return $this; |
|
292
|
|
|
} |
|
293
|
|
|
|
|
294
|
|
|
public function isDir() |
|
295
|
|
|
{ |
|
296
|
|
|
return $this->type === 2; |
|
297
|
|
|
} |
|
298
|
|
|
|
|
299
|
|
|
public function isFile() |
|
300
|
|
|
{ |
|
301
|
|
|
return $this->type === 1; |
|
302
|
|
|
} |
|
303
|
|
|
|
|
304
|
|
|
public function isLink() |
|
305
|
|
|
{ |
|
306
|
|
|
return $this->type === 3; |
|
307
|
|
|
} |
|
308
|
|
|
} |
|
309
|
|
|
|