Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSString* getRootPath(void)
- {
- static NSString* rootPath = nil;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^
- {
- NSFileManager* fileManager = [NSFileManager defaultManager];
- NSDictionary* attributes = [fileManager attributesOfItemAtPath:@"/var/jb" error:nil];
- if(attributes)
- {
- NSString* fileType = attributes[NSFileType];
- if([fileType isEqualToString:NSFileTypeSymbolicLink])
- {
- NSString* destination = [fileManager destinationOfSymbolicLinkAtPath:@"/var/jb" error:nil];
- if(![destination isEqualToString:@"/jb"] && ![destination isEqualToString:@"/jb/"])
- {
- rootPath = destination;
- }
- }
- }
- if(!rootPath)
- {
- rootPath = @"/";
- }
- });
- return rootPath;
- }
- NSString* rootifyPath(NSString* path)
- {
- return [getRootPath() stringByAppendingPathComponent:path];
- }
- const char* rootifyCPath(const char* cPath)
- {
- NSString* path = [NSString stringWithUTF8String:cPath];
- return rootifyPath(path).fileSystemRepresentation;
- }
Advertisement
Add Comment
Please, Sign In to add comment