Skip to content

Commit

Permalink
[rootless] Provide macro definitions when !TARGET_OS_IPHONE (#97)
Browse files Browse the repository at this point in the history
These definitions should not rely on libroot which is currently
only available for iOS. This uses the definitions that were
previously used in a2a4086
  • Loading branch information
leptos-null authored Oct 30, 2024
1 parent 8194da1 commit 322c069
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions rootless.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#include <TargetConditionals.h>

#if TARGET_OS_IPHONE

#include <libroot/libroot.h>

#ifdef XINA_SUPPORT
Expand All @@ -9,3 +13,23 @@ _Pragma("message(\"'XINA_SUPPORT' is deprecated. libroot will now handle this fo

#define ROOT_PATH_NS(nsPath) JBROOT_PATH_NSSTRING(nsPath)
#define ROOT_PATH_NS_VAR(nsPath) JBROOT_PATH_NSSTRING(nsPath)

#else

// no libroot support

#include <sys/syslimits.h>
#include <string.h>

#define ROOT_PATH(cPath) THEOS_PACKAGE_INSTALL_PREFIX cPath
#define ROOT_PATH_NS(path) @THEOS_PACKAGE_INSTALL_PREFIX path

#define ROOT_PATH_NS_VAR(path) [@THEOS_PACKAGE_INSTALL_PREFIX stringByAppendingPathComponent:path]
#define ROOT_PATH_VAR(path) sizeof(THEOS_PACKAGE_INSTALL_PREFIX) > 1 ? ({ \
char outPath[PATH_MAX]; \
strlcpy(outPath, THEOS_PACKAGE_INSTALL_PREFIX, PATH_MAX); \
strlcat(outPath, path, PATH_MAX); \
outPath; \
}) : path

#endif

0 comments on commit 322c069

Please sign in to comment.