Last active
May 22, 2023 02:17
-
-
Save opa334/b14fa4a593bbb79f025cda6113e8b81b to your computer and use it in GitHub Desktop.
Macros to support rootless jailbreaks in your packages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#include <unistd.h> | |
// Use for NSString literals or variables | |
#define ROOT_PATH_NS(path)([[NSFileManager defaultManager] fileExistsAtPath:path] ? path : [@"/var/jb" stringByAppendingPathComponent:path]) | |
// Use for C string literals | |
#define ROOT_PATH_C(cPath) (access(cPath, F_OK) == 0) ? cPath : "/var/jb" cPath | |
// Use for C string variables | |
// The string returned by this will get freed when your function exits | |
// If you want to keep it, use strdup | |
#define ROOT_PATH_C_VAR(cPath)(ROOT_PATH_NS([NSString stringWithUTF8String:cPath]).fileSystemRepresentation) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment