static void WriteXcent(PObject doc, string path) { var buf = doc.ToByteArray(false); using (var stream = new MemoryStream()) { stream.Write(buf, 0, buf.Length); var src = stream.ToArray(); bool save; // Note: if the destination file already exists, only re-write it if the content will change if (File.Exists(path)) { var dest = File.ReadAllBytes(path); save = !AreEqual(src, dest); } else { save = true; } if (save) { File.WriteAllBytes(path, src); } } }
static void WriteXcent(PObject doc, string path) { var buf = doc.ToByteArray(false); using (var stream = File.Open(path, FileMode.Create)) { if (AppleSdkSettings.XcodeVersion < new Version(4, 4, 1)) { // write the xcent file with the magic header, length, and the plist var length = Mono.DataConverter.BigEndian.GetBytes((uint)buf.Length + 8); // 8 = magic.length + magicLen.Length stream.Write(XcentMagic, 0, XcentMagic.Length); stream.Write(length, 0, length.Length); } stream.Write(buf, 0, buf.Length); } }
static void WriteXcent(PObject doc, string path) { var buf = doc.ToByteArray(false); using (var stream = new MemoryStream()) { if (AppleSdkSettings.XcodeVersion < new Version(4, 4, 1)) { // write the xcent file with the magic header, length, and the plist var length = Mono.DataConverter.BigEndian.GetBytes((uint)buf.Length + 8); // 8 = magic.length + magicLen.Length stream.Write(XcentMagic, 0, XcentMagic.Length); stream.Write(length, 0, length.Length); } stream.Write(buf, 0, buf.Length); var src = stream.ToArray(); bool save; // Note: if the destination file already exists, only re-write it if the content will change if (File.Exists(path)) { var dest = File.ReadAllBytes(path); save = !AreEqual(src, dest); } else { save = true; } if (save) { File.WriteAllBytes(path, src); } } }
static void WriteXcent(PObject doc, string path) { var buf = doc.ToByteArray (false); using (var stream = File.Open (path, FileMode.Create)) { if (AppleSdkSettings.XcodeVersion < new Version (4, 4, 1)) { // write the xcent file with the magic header, length, and the plist var length = Mono.DataConverter.BigEndian.GetBytes ((uint) buf.Length + 8); // 8 = magic.length + magicLen.Length stream.Write (XcentMagic, 0, XcentMagic.Length); stream.Write (length, 0, length.Length); } stream.Write (buf, 0, buf.Length); } }