12
12
use OC \Files \Storage \Storage ;
13
13
use OC \Files \Storage \Wrapper \Wrapper ;
14
14
use OCP \Constants ;
15
+ use OCP \Files \Cache \ICache ;
15
16
use OCP \Files \ForbiddenException ;
16
17
use OCP \Files \Storage \IStorage ;
17
18
use OCP \Files \Storage \IWriteStreamStorage ;
@@ -54,7 +55,7 @@ protected function checkFileAccess(string $path, ?bool $isDir = null): void {
54
55
* @return bool
55
56
* @throws ForbiddenException
56
57
*/
57
- public function mkdir ($ path ) {
58
+ public function mkdir ($ path ): bool {
58
59
$ this ->checkFileAccess ($ path , true );
59
60
return $ this ->storage ->mkdir ($ path );
60
61
}
@@ -66,7 +67,7 @@ public function mkdir($path) {
66
67
* @return bool
67
68
* @throws ForbiddenException
68
69
*/
69
- public function rmdir ($ path ) {
70
+ public function rmdir ($ path ): bool {
70
71
$ this ->checkFileAccess ($ path , true );
71
72
return $ this ->storage ->rmdir ($ path );
72
73
}
@@ -77,7 +78,7 @@ public function rmdir($path) {
77
78
* @param string $path
78
79
* @return bool
79
80
*/
80
- public function isCreatable ($ path ) {
81
+ public function isCreatable ($ path ): bool {
81
82
try {
82
83
$ this ->checkFileAccess ($ path );
83
84
} catch (ForbiddenException $ e ) {
@@ -92,7 +93,7 @@ public function isCreatable($path) {
92
93
* @param string $path
93
94
* @return bool
94
95
*/
95
- public function isReadable ($ path ) {
96
+ public function isReadable ($ path ): bool {
96
97
try {
97
98
$ this ->checkFileAccess ($ path );
98
99
} catch (ForbiddenException $ e ) {
@@ -107,7 +108,7 @@ public function isReadable($path) {
107
108
* @param string $path
108
109
* @return bool
109
110
*/
110
- public function isUpdatable ($ path ) {
111
+ public function isUpdatable ($ path ): bool {
111
112
try {
112
113
$ this ->checkFileAccess ($ path );
113
114
} catch (ForbiddenException $ e ) {
@@ -122,7 +123,7 @@ public function isUpdatable($path) {
122
123
* @param string $path
123
124
* @return bool
124
125
*/
125
- public function isDeletable ($ path ) {
126
+ public function isDeletable ($ path ): bool {
126
127
try {
127
128
$ this ->checkFileAccess ($ path );
128
129
} catch (ForbiddenException $ e ) {
@@ -131,7 +132,7 @@ public function isDeletable($path) {
131
132
return $ this ->storage ->isDeletable ($ path );
132
133
}
133
134
134
- public function getPermissions ($ path ) {
135
+ public function getPermissions ($ path ): int {
135
136
try {
136
137
$ this ->checkFileAccess ($ path );
137
138
} catch (ForbiddenException $ e ) {
@@ -147,7 +148,7 @@ public function getPermissions($path) {
147
148
* @return string
148
149
* @throws ForbiddenException
149
150
*/
150
- public function file_get_contents ($ path ) {
151
+ public function file_get_contents ($ path ): string | false {
151
152
$ this ->checkFileAccess ($ path , false );
152
153
return $ this ->storage ->file_get_contents ($ path );
153
154
}
@@ -160,7 +161,7 @@ public function file_get_contents($path) {
160
161
* @return bool
161
162
* @throws ForbiddenException
162
163
*/
163
- public function file_put_contents ($ path , $ data ) {
164
+ public function file_put_contents ($ path , $ data ): int | float | false {
164
165
$ this ->checkFileAccess ($ path , false );
165
166
return $ this ->storage ->file_put_contents ($ path , $ data );
166
167
}
@@ -172,24 +173,24 @@ public function file_put_contents($path, $data) {
172
173
* @return bool
173
174
* @throws ForbiddenException
174
175
*/
175
- public function unlink ($ path ) {
176
+ public function unlink ($ path ): bool {
176
177
$ this ->checkFileAccess ($ path , false );
177
178
return $ this ->storage ->unlink ($ path );
178
179
}
179
180
180
181
/**
181
182
* see http://php.net/manual/en/function.rename.php
182
183
*
183
- * @param string $path1
184
- * @param string $path2
184
+ * @param string $source
185
+ * @param string $target
185
186
* @return bool
186
187
* @throws ForbiddenException
187
188
*/
188
- public function rename ($ path1 , $ path2 ) {
189
- $ isDir = $ this ->is_dir ($ path1 );
190
- $ this ->checkFileAccess ($ path1 , $ isDir );
191
- $ this ->checkFileAccess ($ path2 , $ isDir );
192
- return $ this ->storage ->rename ($ path1 , $ path2 );
189
+ public function rename ($ source , $ target ): bool {
190
+ $ isDir = $ this ->is_dir ($ source );
191
+ $ this ->checkFileAccess ($ source , $ isDir );
192
+ $ this ->checkFileAccess ($ target , $ isDir );
193
+ return $ this ->storage ->rename ($ source , $ target );
193
194
}
194
195
195
196
/**
@@ -200,11 +201,11 @@ public function rename($path1, $path2) {
200
201
* @return bool
201
202
* @throws ForbiddenException
202
203
*/
203
- public function copy ($ path1 , $ path2 ) {
204
- $ isDir = $ this ->is_dir ($ path1 );
205
- $ this ->checkFileAccess ($ path1 , $ isDir );
206
- $ this ->checkFileAccess ($ path2 , $ isDir );
207
- return $ this ->storage ->copy ($ path1 , $ path2 );
204
+ public function copy ($ source , $ target ): bool {
205
+ $ isDir = $ this ->is_dir ($ source );
206
+ $ this ->checkFileAccess ($ source , $ isDir );
207
+ $ this ->checkFileAccess ($ target , $ isDir );
208
+ return $ this ->storage ->copy ($ source , $ target );
208
209
}
209
210
210
211
/**
@@ -229,7 +230,7 @@ public function fopen($path, $mode) {
229
230
* @return bool
230
231
* @throws ForbiddenException
231
232
*/
232
- public function touch ($ path , $ mtime = null ) {
233
+ public function touch ($ path , $ mtime = null ): bool {
233
234
$ this ->checkFileAccess ($ path , false );
234
235
return $ this ->storage ->touch ($ path , $ mtime );
235
236
}
@@ -241,7 +242,7 @@ public function touch($path, $mtime = null) {
241
242
* @param Storage (optional) the storage to pass to the cache
242
243
* @return Cache
243
244
*/
244
- public function getCache ($ path = '' , $ storage = null ) {
245
+ public function getCache ($ path = '' , $ storage = null ): ICache {
245
246
if (!$ storage ) {
246
247
$ storage = $ this ;
247
248
}
@@ -258,7 +259,7 @@ public function getCache($path = '', $storage = null) {
258
259
* @return array
259
260
* @throws ForbiddenException
260
261
*/
261
- public function getDirectDownload ($ path ) {
262
+ public function getDirectDownload ($ path ): array | false {
262
263
$ this ->checkFileAccess ($ path , false );
263
264
return $ this ->storage ->getDirectDownload ($ path );
264
265
}
@@ -270,7 +271,7 @@ public function getDirectDownload($path) {
270
271
* @return bool
271
272
* @throws ForbiddenException
272
273
*/
273
- public function copyFromStorage (IStorage $ sourceStorage , $ sourceInternalPath , $ targetInternalPath ) {
274
+ public function copyFromStorage (IStorage $ sourceStorage , $ sourceInternalPath , $ targetInternalPath ): bool {
274
275
if ($ sourceStorage === $ this ) {
275
276
return $ this ->copy ($ sourceInternalPath , $ targetInternalPath );
276
277
}
@@ -286,7 +287,7 @@ public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
286
287
* @return bool
287
288
* @throws ForbiddenException
288
289
*/
289
- public function moveFromStorage (IStorage $ sourceStorage , $ sourceInternalPath , $ targetInternalPath ) {
290
+ public function moveFromStorage (IStorage $ sourceStorage , $ sourceInternalPath , $ targetInternalPath ): bool {
290
291
if ($ sourceStorage === $ this ) {
291
292
return $ this ->rename ($ sourceInternalPath , $ targetInternalPath );
292
293
}
0 commit comments