From 4e4fc389d2dacebf347c1d6e95fff91d6e8c2f31 Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Thu, 15 Aug 2013 10:21:37 -0400 Subject: [PATCH] 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. --- Tools/nib2cib/Converter.j | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Tools/nib2cib/Converter.j b/Tools/nib2cib/Converter.j index 549a32bdf..bd38f1886 100644 --- a/Tools/nib2cib/Converter.j +++ b/Tools/nib2cib/Converter.j @@ -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(/\\s*CF\$UID\s*\<\/key\>/g, "CP$UID"); @@ -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];