36
36
use OSjs \Core \VFSTransport ;
37
37
38
38
use Exception ;
39
+ use RecursiveIteratorIterator ;
40
+ use RecursiveDirectoryIterator ;
39
41
40
42
abstract class Filesystem
41
43
extends VFSTransport
@@ -268,7 +270,9 @@ final public static function mkdir(Request $request, Array $arguments = [])
268
270
269
271
final public static function find (Request $ request , Array $ arguments = [])
270
272
{
271
- $ path = self ::_getRealPath ($ arguments ['path ' ]);
273
+ $ dirname = $ arguments ['path ' ];
274
+ $ path = self ::_getRealPath ($ dirname );
275
+ $ root = dirname ($ path );
272
276
$ opts = $ arguments ['args ' ];
273
277
$ result = [];
274
278
@@ -284,7 +288,7 @@ final public static function find(Request $request, Array $arguments = [])
284
288
}
285
289
286
290
if (stristr ($ f , $ opts ['query ' ]) !== false ) {
287
- $ result [] = self ::_getFileMetadata ($ f , $ dirname , $ root );
291
+ $ result [] = self ::_getFileMetadata ($ f , $ dirname , $ root . ' / ' . $ f );
288
292
}
289
293
}
290
294
}
@@ -298,9 +302,18 @@ final public static function find(Request $request, Array $arguments = [])
298
302
new RecursiveDirectoryIterator ($ p ),
299
303
RecursiveIteratorIterator::SELF_FIRST );
300
304
301
- foreach ( array_keys ($ objects ) as $ name ) {
302
- if (stristr ($ name , $ opts ['query ' ]) !== false ) {
303
- $ result [] = self ::_getFileMetadata (substr ($ name , strlen ($ path )), $ dirname , $ root );
305
+ foreach ( $ objects as $ name => $ tmp ) {
306
+
307
+ $ filepath = substr ($ name , strlen ($ path ) - 1 );
308
+ $ filename = basename ($ filepath );
309
+
310
+ if (stristr ($ filename , $ opts ['query ' ]) !== false ) {
311
+ $ vpath = $ dirname ;
312
+ $ tmppath = dirname ($ filepath );
313
+ if ( $ tmppath === '. ' ) {
314
+ $ tmppath = '' ;
315
+ }
316
+ $ result [] = self ::_getFileMetadata ($ filename , $ vpath . $ tmppath , $ name );
304
317
}
305
318
306
319
if ($ limit && sizeof ($ result ) >= $ limit ) {
0 commit comments