1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace kalanis\RemoteRequest\Protocols\Fsp\Answer; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use kalanis\RemoteRequest\Protocols\Fsp; |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class Protection |
11
|
|
|
* @package kalanis\RemoteRequest\Protocols\Fsp\Answer |
12
|
|
|
* Process protection answer |
13
|
|
|
*/ |
14
|
|
|
class Protection extends AAnswer |
15
|
|
|
{ |
16
|
|
|
protected string $directory = ''; |
17
|
|
|
protected ?bool $isOwnedByMe = null; |
18
|
|
|
protected ?bool $canListDir = null; |
19
|
|
|
protected ?bool $canReadOnlyOwner = null; |
20
|
|
|
protected ?bool $canCreateFileHere = null; |
21
|
|
|
protected ?bool $canRenameFileHere = null; |
22
|
|
|
protected ?bool $canDeleteFileHere = null; |
23
|
|
|
protected ?bool $canCreateDirHere = null; |
24
|
|
|
protected ?bool $containsReadme = null; |
25
|
|
|
|
26
|
1 |
|
public function process(): parent |
27
|
|
|
{ |
28
|
1 |
|
$this->directory = substr($this->answer->getContent(), 0, -1); |
29
|
1 |
|
$extraData = $this->answer->getExtraData(); |
30
|
1 |
|
$settings = Fsp\Strings::mb_ord($extraData[0]); |
31
|
1 |
|
$this->isOwnedByMe = $this->parseBit($settings, 0x01); |
32
|
1 |
|
$this->canDeleteFileHere = $this->parseBit($settings, 0x02); |
33
|
1 |
|
$this->canCreateFileHere = $this->parseBit($settings, 0x04); |
34
|
1 |
|
$this->canCreateDirHere = $this->parseBit($settings, 0x08); |
35
|
1 |
|
$this->canReadOnlyOwner = $this->parseBit($settings, 0x10); |
36
|
1 |
|
$this->containsReadme = $this->parseBit($settings, 0x20); |
37
|
1 |
|
$this->canListDir = $this->parseBit($settings, 0x40); |
38
|
1 |
|
$this->canRenameFileHere = $this->parseBit($settings, 0x80); |
39
|
1 |
|
return $this; |
|
|
|
|
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param int $input |
44
|
|
|
* @param int $bitPosition |
45
|
|
|
* @return bool |
46
|
|
|
*/ |
47
|
1 |
|
protected function parseBit($input, $bitPosition): bool |
48
|
|
|
{ |
49
|
1 |
|
return boolval($input & $bitPosition); |
50
|
|
|
} |
51
|
|
|
|
52
|
1 |
|
public function getDirectory(): string |
53
|
|
|
{ |
54
|
1 |
|
return $this->directory; |
55
|
|
|
} |
56
|
|
|
|
57
|
1 |
|
public function isMy(): ?bool |
58
|
|
|
{ |
59
|
1 |
|
return $this->isOwnedByMe; |
60
|
|
|
} |
61
|
|
|
|
62
|
1 |
|
public function canList(): ?bool |
63
|
|
|
{ |
64
|
1 |
|
return $this->canListDir; |
65
|
|
|
} |
66
|
|
|
|
67
|
1 |
|
public function canReadOnlyOwner(): ?bool |
68
|
|
|
{ |
69
|
1 |
|
return $this->canReadOnlyOwner; |
70
|
|
|
} |
71
|
|
|
|
72
|
1 |
|
public function canCreateFile(): ?bool |
73
|
|
|
{ |
74
|
1 |
|
return $this->canCreateFileHere; |
75
|
|
|
} |
76
|
|
|
|
77
|
1 |
|
public function canRenameFile(): ?bool |
78
|
|
|
{ |
79
|
1 |
|
return $this->canRenameFileHere; |
80
|
|
|
} |
81
|
|
|
|
82
|
1 |
|
public function canDeleteFile(): ?bool |
83
|
|
|
{ |
84
|
1 |
|
return $this->canDeleteFileHere; |
85
|
|
|
} |
86
|
|
|
|
87
|
1 |
|
public function canCreateDir(): ?bool |
88
|
|
|
{ |
89
|
1 |
|
return $this->canCreateDirHere; |
90
|
|
|
} |
91
|
|
|
|
92
|
1 |
|
public function containsReadme(): ?bool |
93
|
|
|
{ |
94
|
1 |
|
return $this->containsReadme; |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|