use of com.dd.plist.NSDictionary in project robovm by robovm.
the class SDK method create.
public static SDK create(File root) throws Exception {
File sdkSettingsFile = new File(root, "SDKSettings.plist");
File sdkSysVersionFile = new File(root, "System/Library/CoreServices/SystemVersion.plist");
File platformVersionFile = new File(root, "../../../version.plist");
File platformInfoFile = new File(root, "../../../Info.plist");
if (sdkSettingsFile.exists() && platformInfoFile.exists()) {
NSDictionary sdkSettingsDict = (NSDictionary) PropertyListParser.parse(sdkSettingsFile);
NSDictionary sdkSysVersionDict = (NSDictionary) PropertyListParser.parse(sdkSysVersionFile);
NSDictionary platformInfoDict = (NSDictionary) PropertyListParser.parse(platformInfoFile);
SDK sdk = new SDK();
sdk.root = root;
sdk.displayName = toString(sdkSettingsDict.objectForKey("DisplayName"));
sdk.minimalDisplayName = toString(sdkSettingsDict.objectForKey("MinimalDisplayName"));
sdk.canonicalName = toString(sdkSettingsDict.objectForKey("CanonicalName"));
sdk.version = toString(sdkSettingsDict.objectForKey("Version"));
sdk.defaultProperties = (NSDictionary) sdkSettingsDict.objectForKey("DefaultProperties");
sdk.build = toString(sdkSysVersionDict.objectForKey("ProductBuildVersion"));
if (platformVersionFile.exists()) {
NSDictionary platformVersionDict = (NSDictionary) PropertyListParser.parse(platformVersionFile);
sdk.platformBuild = toString(platformVersionDict.objectForKey("ProductBuildVersion"));
} else {
// iOS 9 and above, there's no version.plist file anymore
// however, the ProductBuildVersion in SystemVersion.plist
// seems to always be the same as the ProductBuildVersion
// in the now missing version.plist file
sdk.platformBuild = sdk.build;
}
NSDictionary additionalInfo = (NSDictionary) platformInfoDict.objectForKey("AdditionalInfo");
sdk.platformVersion = toString(additionalInfo.objectForKey("DTPlatformVersion"));
sdk.platformName = toString(additionalInfo.objectForKey("DTPlatformName"));
String[] parts = StringUtils.split(sdk.version, ".");
sdk.major = Integer.parseInt(parts[0]);
sdk.minor = parts.length >= 2 ? Integer.parseInt(parts[1]) : 0;
sdk.revision = parts.length >= 3 ? Integer.parseInt(parts[2]) : 0;
return sdk;
}
throw new IllegalArgumentException(root.getAbsolutePath() + " is not an SDK root path");
}
use of com.dd.plist.NSDictionary in project robovm by robovm.
the class RamDiskTools method setupRamDisk.
/**
* Checks if a RAM disk is available and prunes it if necessary.
*/
public void setupRamDisk(Config config, File cacheDir, File tmpDir) {
this.newCacheDir = cacheDir;
this.newTmpDir = tmpDir;
if (OS.getDefaultOS() != OS.macosx) {
return;
}
File volume = new File(ROBOVM_RAM_DISK_PATH);
if (!volume.exists()) {
try {
FileStore store = Files.getFileStore(new File(System.getProperty("user.home")).toPath());
String plist = new Executor(Logger.NULL_LOGGER, "diskutil").args("info", "-plist", store.name()).execCapture();
NSDictionary dict = (NSDictionary) PropertyListParser.parse(plist.getBytes("UTF-8"));
NSObject value = dict.objectForKey("SolidState");
if (value == null || (value instanceof NSNumber && !((NSNumber) value).boolValue())) {
// @formatter:off
config.getLogger().warn("RoboVM has detected that you are running on a slow HDD. Please consider mounting a RAM disk.\n" + "To create a 2GB RAM disk, run this in your terminal:\n" + "SIZE=2048 ; diskutil erasevolume HFS+ 'RoboVM RAM Disk' `hdiutil attach -nomount ram://$((SIZE * 2048))`\n" + "See http://docs.robovm.com/ for more info");
// @formatter:on
}
} catch (Throwable t) {
// nothing to do here, can't decide if we are on a SSD or HDD
t.printStackTrace();
}
return;
}
try {
FileStore store = Files.getFileStore(volume.toPath());
if (store.getUsableSpace() < MIN_FREE_SPACE) {
cleanRamDisk(store, volume, config);
if (store.getUsableSpace() < MIN_FREE_SPACE) {
config.getLogger().info("Couldn't free enough space on RAM disk, using hard drive");
return;
}
}
File newCacheDir = new File(volume, "cache");
if (!newCacheDir.exists() && !newCacheDir.mkdirs()) {
config.getLogger().info("Couldn't create cache directory on RAM disk, using hard drive");
return;
}
File newTmpDir = new File(volume, "tmp");
if (!newTmpDir.exists() && !newTmpDir.mkdirs()) {
config.getLogger().info("Couldn't create tmp directory on RAM disk, using hard drive");
return;
}
newTmpDir = new File(newTmpDir, tmpDir.getAbsolutePath());
config.getLogger().info("Using RAM disk at %s for cache and tmp directory", ROBOVM_RAM_DISK_PATH);
this.newCacheDir = newCacheDir;
this.newTmpDir = newTmpDir;
} catch (Throwable t) {
config.getLogger().error("Couldn't setup RAM disk, using hard drive, %s", t.getMessage());
this.newCacheDir = cacheDir;
this.newTmpDir = tmpDir;
}
}
Aggregations