Guest User

Untitled

a guest
Dec 13th, 2022
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. NSString* getRootPath(void)
  2. {
  3.     static NSString* rootPath = nil;
  4.  
  5.     static dispatch_once_t onceToken;
  6.     dispatch_once(&onceToken, ^
  7.     {
  8.         NSFileManager* fileManager = [NSFileManager defaultManager];
  9.         NSDictionary* attributes = [fileManager attributesOfItemAtPath:@"/var/jb" error:nil];
  10.         if(attributes)
  11.         {
  12.             NSString* fileType = attributes[NSFileType];
  13.             if([fileType isEqualToString:NSFileTypeSymbolicLink])
  14.             {
  15.                 NSString* destination = [fileManager destinationOfSymbolicLinkAtPath:@"/var/jb" error:nil];
  16.                 if(![destination isEqualToString:@"/jb"] && ![destination isEqualToString:@"/jb/"])
  17.                 {
  18.                     rootPath = destination;
  19.                 }
  20.             }
  21.         }
  22.         if(!rootPath)
  23.         {
  24.             rootPath = @"/";
  25.         }
  26.     });
  27.  
  28.     return rootPath;
  29. }
  30.  
  31. NSString* rootifyPath(NSString* path)
  32. {
  33.     return [getRootPath() stringByAppendingPathComponent:path];
  34. }
  35.  
  36. const char* rootifyCPath(const char* cPath)
  37. {
  38.     NSString* path = [NSString stringWithUTF8String:cPath];
  39.     return rootifyPath(path).fileSystemRepresentation;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment