1 #include <objc/runtime.h>
2 #include <Foundation/Foundation.h>
4 @interface MIFileManager
5 + (MIFileManager *) defaultManager;
6 - (NSURL *) destinationOfSymbolicLinkAtURL:(NSURL *)url error:(NSError *)error;
9 static Class $MIFileManager;
11 static NSArray *(*_MIFileManager$urlsForItemsInDirectoryAtURL$ignoringSymlinks$error$)(MIFileManager *self, SEL _cmd, NSURL *url, BOOL ignoring, NSError *error);
13 static NSArray *$MIFileManager$urlsForItemsInDirectoryAtURL$ignoringSymlinks$error$(MIFileManager *self, SEL _cmd, NSURL *url, BOOL ignoring, NSError *error) {
14 MIFileManager *manager(reinterpret_cast<MIFileManager *>([$MIFileManager defaultManager]));
15 NSURL *destiny([manager destinationOfSymbolicLinkAtURL:url error:NULL]);
17 return _MIFileManager$urlsForItemsInDirectoryAtURL$ignoringSymlinks$error$(self, _cmd, url, YES, error);
19 NSArray *prefix([url pathComponents]);
20 size_t skip([[destiny pathComponents] count]);
21 NSMutableArray *items([NSMutableArray array]);
22 for (NSURL *item in _MIFileManager$urlsForItemsInDirectoryAtURL$ignoringSymlinks$error$(self, _cmd, destiny, YES, error)) {
23 NSArray *components([item pathComponents]);
24 [items addObject:[NSURL fileURLWithPathComponents:[prefix arrayByAddingObjectsFromArray:[components subarrayWithRange:NSMakeRange(skip, [components count] - skip)]]]];
30 __attribute__((__constructor__))
31 static void initialize() {
32 $MIFileManager = objc_getClass("MIFileManager");
33 SEL sel(@selector(urlsForItemsInDirectoryAtURL:ignoringSymlinks:error:));
34 Method method(class_getInstanceMethod($MIFileManager, sel));
35 _MIFileManager$urlsForItemsInDirectoryAtURL$ignoringSymlinks$error$ = reinterpret_cast<NSArray *(*)(MIFileManager *, SEL, NSURL *, BOOL, NSError *)>(method_getImplementation(method));
36 method_setImplementation(method, reinterpret_cast<IMP>(&$MIFileManager$urlsForItemsInDirectoryAtURL$ignoringSymlinks$error$));