|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the "php-ipfs" package. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Robert Schönthal <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace IPFS\Api; |
|
15
|
|
|
|
|
16
|
|
|
use IPFS\Annotation\Api as Endpoint; |
|
17
|
|
|
use IPFS\Command\Command; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @author Robert Schönthal <[email protected]> |
|
21
|
|
|
* @autogenerated |
|
22
|
|
|
* @codeCoverageIgnore |
|
23
|
|
|
*/ |
|
24
|
|
|
final class Files implements Api |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* Change the cid version or hash function of the root node of a given path. |
|
28
|
|
|
* |
|
29
|
|
|
* @Endpoint(name="files:chcid") |
|
30
|
|
|
* |
|
31
|
|
|
* @param string $arg path to change |
|
32
|
|
|
* @param int $cidVersion cid version to use |
|
33
|
|
|
* @param string $hash hash function to use |
|
34
|
|
|
* |
|
35
|
|
|
* @return Command |
|
36
|
|
|
*/ |
|
37
|
|
|
public function chcid(string $arg = '/', int $cidVersion = 0, string $hash = null): Command |
|
38
|
|
|
{ |
|
39
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Copy files into mfs. |
|
44
|
|
|
* |
|
45
|
|
|
* @Endpoint(name="files:cp") |
|
46
|
|
|
* |
|
47
|
|
|
* @param string $arg source object to copy |
|
48
|
|
|
* @param string $arg1 destination to copy object to |
|
49
|
|
|
* |
|
50
|
|
|
* @return Command |
|
51
|
|
|
*/ |
|
52
|
|
|
public function cp(string $arg, string $arg1): Command |
|
53
|
|
|
{ |
|
54
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Flush a given path’s data to disk. |
|
59
|
|
|
* |
|
60
|
|
|
* @Endpoint(name="files:flush") |
|
61
|
|
|
* |
|
62
|
|
|
* @param string $arg path to flush |
|
63
|
|
|
* |
|
64
|
|
|
* @return Command |
|
65
|
|
|
*/ |
|
66
|
|
|
public function flush(string $arg = '/'): Command |
|
67
|
|
|
{ |
|
68
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* List directories in the local mutable namespace. |
|
73
|
|
|
* |
|
74
|
|
|
* @Endpoint(name="files:ls") |
|
75
|
|
|
* |
|
76
|
|
|
* @param string $arg path to show listing for |
|
77
|
|
|
* @param bool $l use long listing format |
|
78
|
|
|
* |
|
79
|
|
|
* @return Command |
|
80
|
|
|
*/ |
|
81
|
|
|
public function ls(string $arg = '/', bool $l = false): Command |
|
82
|
|
|
{ |
|
83
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Make directories. |
|
88
|
|
|
* |
|
89
|
|
|
* @Endpoint(name="files:mkdir") |
|
90
|
|
|
* |
|
91
|
|
|
* @param string $arg path to dir to make |
|
92
|
|
|
* @param bool $parents no error if existing, make parent directories as needed |
|
93
|
|
|
* @param int $cidVersion cid version to use |
|
94
|
|
|
* @param string $hash hash function to use |
|
95
|
|
|
* |
|
96
|
|
|
* @return Command |
|
97
|
|
|
*/ |
|
98
|
|
|
public function mkdir(string $arg, bool $parents = false, int $cidVersion = 0, string $hash = null): Command |
|
99
|
|
|
{ |
|
100
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* Move files. |
|
105
|
|
|
* |
|
106
|
|
|
* @Endpoint(name="files:mv") |
|
107
|
|
|
* |
|
108
|
|
|
* @param string $arg source file to move |
|
109
|
|
|
* @param string $arg1 destination path for file to be moved to |
|
110
|
|
|
* |
|
111
|
|
|
* @return Command |
|
112
|
|
|
*/ |
|
113
|
|
|
public function mv(string $arg, string $arg1): Command |
|
114
|
|
|
{ |
|
115
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* Read a file in a given mfs. |
|
120
|
|
|
* |
|
121
|
|
|
* @Endpoint(name="files:read") |
|
122
|
|
|
* |
|
123
|
|
|
* @param string $arg path to file to be read |
|
124
|
|
|
* @param int $offset byte offset to begin reading from |
|
125
|
|
|
* @param int $count maximum number of bytes to read |
|
126
|
|
|
* |
|
127
|
|
|
* @return Command |
|
128
|
|
|
*/ |
|
129
|
|
|
public function read(string $arg, int $offset = 0, int $count = 0): Command |
|
130
|
|
|
{ |
|
131
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* Remove a file. |
|
136
|
|
|
* |
|
137
|
|
|
* @Endpoint(name="files:rm") |
|
138
|
|
|
* |
|
139
|
|
|
* @param string $arg file to remove |
|
140
|
|
|
* @param bool $recursive recursively remove directories |
|
141
|
|
|
* |
|
142
|
|
|
* @return Command |
|
143
|
|
|
*/ |
|
144
|
|
|
public function rm(string $arg, bool $recursive = false): Command |
|
145
|
|
|
{ |
|
146
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* Display file status. |
|
151
|
|
|
* |
|
152
|
|
|
* @Endpoint(name="files:stat") |
|
153
|
|
|
* |
|
154
|
|
|
* @param string $arg path to node to stat |
|
155
|
|
|
* @param string $format print statistics in given format |
|
156
|
|
|
* @param bool $hash print only hash |
|
157
|
|
|
* @param bool $size print only size |
|
158
|
|
|
* @param bool $withLocal compute the amount of the dag that is local, and if possible the total size |
|
159
|
|
|
* |
|
160
|
|
|
* @return Command |
|
161
|
|
|
*/ |
|
162
|
|
|
public function stat(string $arg, string $format = null, bool $hash = false, bool $size = false, bool $withLocal = false): Command |
|
163
|
|
|
{ |
|
164
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* Write to a mutable file in a given filesystem. |
|
169
|
|
|
* |
|
170
|
|
|
* @Endpoint(name="files:write") |
|
171
|
|
|
* |
|
172
|
|
|
* @param string $arg path to write to |
|
173
|
|
|
* @param string $file data to write |
|
174
|
|
|
* @param int $offset byte offset to begin writing at |
|
175
|
|
|
* @param bool $create create the file if it does not exist |
|
176
|
|
|
* @param bool $truncate truncate the file to size zero before writing |
|
177
|
|
|
* @param int $count maximum number of bytes to read |
|
178
|
|
|
* @param bool $rawLeaves use raw blocks for newly created leaf nodes |
|
179
|
|
|
* @param int $cidVersion cid version to use |
|
180
|
|
|
* @param string $hash hash function to use |
|
181
|
|
|
* |
|
182
|
|
|
* @return Command |
|
183
|
|
|
*/ |
|
184
|
|
|
public function write(string $arg, string $file, int $offset = 0, bool $create = false, bool $truncate = false, int $count = 0, bool $rawLeaves = false, int $cidVersion = 0, string $hash = null): Command |
|
185
|
|
|
{ |
|
186
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
|
187
|
|
|
} |
|
188
|
|
|
} |
|
189
|
|
|
|