public void SaveText(string data) { if (Zip.ContainsEntry(m_normaPath)) { Zip.RemoveEntry(m_normaPath); } Zip.AddEntry(m_normaPath, Encoding.UTF8.GetBytes(data)); }
protected virtual void EmitVersion() { using (var stream = new MemoryStream()) { using (var writer = new StreamWriter(stream, Encoding.UTF8)) { writer.Write("10.00.000000.000000"); } Zip.AddEntry("installer/version", stream.ToArray()); } }
public virtual void EmitFile([NotNull] IEmitContext context, [NotNull] File file) { var sourceFileAbsoluteFileName = file.Snapshot.SourceFile.AbsoluteFileName; var fileName = PathHelper.NormalizeFilePath(file.FilePath); if (fileName.StartsWith("~\\")) { fileName = fileName.Mid(2); } _files.Add('/' + fileName); Trace.TraceInformation(Msg.I1011, "Publishing", "~\\" + fileName); Zip.AddEntry("addedfiles/" + NormalizeZipPath(fileName), sourceFileAbsoluteFileName); using (var stream = new MemoryStream()) { using (var writer = new StreamWriter(stream, Encoding.UTF8)) { var sb = new StringBuilder(); var settings = new XmlWriterSettings { OmitXmlDeclaration = false, Encoding = Encoding.UTF8 }; using (var output = XmlWriter.Create(sb, settings)) { output.WriteProcessingInstruction("xml", "version=\"1.0\""); output.WriteStartElement("addFile"); output.WriteFullElementString("collisionbehavior", string.Empty); output.WriteFullElementString("path", PathHelper.NormalizeFilePath("\\" + fileName)); output.WriteFullElementString("id", PathHelper.NormalizeFilePath("\\" + fileName)); output.WriteFullElementString("parent", string.Empty); output.WriteFullElementString("file", string.Empty); output.WriteFullElementString("hashCode", string.Empty); output.WriteEndElement(); } writer.WriteLine("version=2.0"); writer.WriteLine("xml=" + sb); } Zip.AddEntry("properties/addedfiles/" + NormalizeZipPath(fileName), stream.ToArray()); } }
public virtual void EmitItem([NotNull] IEmitContext context, [NotNull] Item item) { _items.Add(item); Trace.TraceInformation(Msg.I1011, "Publishing", item.ItemIdOrPath); var fileName = item.DatabaseName + PathHelper.NormalizeFilePath(item.ItemIdOrPath) + "_" + item.Uri.Guid.ToString("B"); using (var stream = new MemoryStream()) { using (var writer = new StreamWriter(stream)) { item.WriteAsUpdatePackageXml(writer); } Zip.AddEntry("addeditems/" + NormalizeZipPath(fileName), stream.ToArray()); } }
public void SaveBinary(byte[] data) { Zip.AddEntry(m_normaPath, data); }
protected virtual void EmitMetaData() { using (var stream = new MemoryStream()) { using (var writer = new StreamWriter(stream, Encoding.UTF8)) { writer.Write(Configuration.GetString(Constants.Configuration.Author, string.Empty)); } Zip.AddEntry("metadata/sc_author.txt", stream.ToArray()); } using (var stream = new MemoryStream()) { using (var writer = new StreamWriter(stream, Encoding.UTF8)) { writer.Write(string.Empty); } Zip.AddEntry("metadata/sc_comment.txt", stream.ToArray()); } using (var stream = new MemoryStream()) { using (var writer = new StreamWriter(stream, Encoding.UTF8)) { writer.Write(Configuration.GetString(Constants.Configuration.License, string.Empty)); } Zip.AddEntry("metadata/sc_license.txt", stream.ToArray()); } using (var stream = new MemoryStream()) { using (var writer = new StreamWriter(stream, Encoding.UTF8)) { var name = Configuration.GetString(Constants.Configuration.Name, string.Empty); if (string.IsNullOrEmpty(name)) { name = "Sitecore Pathfinder Package"; } writer.Write(name); } Zip.AddEntry("metadata/sc_name.txt", stream.ToArray()); } using (var stream = new MemoryStream()) { using (var writer = new StreamWriter(stream, Encoding.UTF8)) { writer.Write(string.Empty); } Zip.AddEntry("metadata/sc_poststep.txt", stream.ToArray()); } using (var stream = new MemoryStream()) { using (var writer = new StreamWriter(stream, Encoding.UTF8)) { writer.Write(Configuration.GetString(Constants.Configuration.Publisher, string.Empty)); } Zip.AddEntry("metadata/sc_publisher.txt", stream.ToArray()); } using (var stream = new MemoryStream()) { using (var writer = new StreamWriter(stream, Encoding.UTF8)) { writer.Write(Configuration.GetString(Constants.Configuration.Description, string.Empty)); } Zip.AddEntry("metadata/sc_readme.txt", stream.ToArray()); } using (var stream = new MemoryStream()) { using (var writer = new StreamWriter(stream, Encoding.UTF8)) { writer.Write(Configuration.GetString(Constants.Configuration.Version, string.Empty)); } Zip.AddEntry("metadata/sc_version.txt", stream.ToArray()); } }