Fixed: nib2cib used a temp file for plutil output instead of using stdout.

Previously, nib2cib sent the output of plutil to a temp file, then read that file. plutil supports writing to stdout, which avoids the temp file completely, so that is what we do now.
This commit is contained in:
Aparajita Fishman
2013-08-15 10:21:45 -04:00
parent fa86c54fff
commit 4e4fc389d2
+6 -12
View File
@@ -109,8 +109,7 @@ ConverterConversionException = @"ConverterConversionException";
- (CPData)CPCompliantNibDataAtFilePath:(CPString)aFilePath
{
var temporaryNibFilePath = "",
temporaryPlistFilePath = "";
var temporaryNibFilePath = "";
try
{
@@ -128,16 +127,14 @@ ConverterConversionException = @"ConverterConversionException";
}
// Convert from binary plist to XML plist
var temporaryPlistFilePath = FILE.join("/tmp", FILE.basename(aFilePath) + ".tmp.plist");
var p = OS.popen(["/usr/bin/plutil", "-convert", "xml1", temporaryNibFilePath, "-o", "-"]),
plistContents;
if (OS.popen(["/usr/bin/plutil", "-convert", "xml1", temporaryNibFilePath, "-o", temporaryPlistFilePath]).wait() === 1)
if (p.wait() === 0)
plistContents = p.stdout.read()
else
[CPException raise:ConverterConversionException reason:@"Could not convert to xml plist for file: " + aFilePath];
if (!FILE.isReadable(temporaryPlistFilePath))
[CPException raise:ConverterConversionException reason:@"Unable to convert nib file."];
var plistContents = FILE.read(temporaryPlistFilePath, { charset: "UTF-8" });
// Minor NS keyed archive to CP keyed archive conversion.
// Use Java directly because rhino's string.replace is *so slow*. 4 seconds vs. 1 millisecond.
// plistContents = plistContents.replace(/\<key\>\s*CF\$UID\s*\<\/key\>/g, "<key>CP$UID</key>");
@@ -156,9 +153,6 @@ ConverterConversionException = @"ConverterConversionException";
{
if (temporaryNibFilePath !== "" && FILE.isWritable(temporaryNibFilePath))
FILE.remove(temporaryNibFilePath);
if (temporaryPlistFilePath !== "" && FILE.isWritable(temporaryPlistFilePath))
FILE.remove(temporaryPlistFilePath);
}
return [CPData dataWithRawString:plistContents];