using System; using System.IO; using Org.BouncyCastle.Utilities.Date; namespace Org.BouncyCastle.Bcpg.OpenPgp { /// Class for processing literal data objects. public class PgpLiteralData : PgpObject { public const char Binary = 'b'; public const char Text = 't'; public const char Utf8 = 'u'; /// The special name indicating a "for your eyes only" packet. public const string Console = "_CONSOLE"; private readonly LiteralDataPacket data; public PgpLiteralData(BcpgInputStream bcpgInput) { Packet packet = bcpgInput.ReadPacket(); if (!(packet is LiteralDataPacket literalDataPacket)) throw new IOException("unexpected packet in stream: " + packet); this.data = literalDataPacket; } /// The format of the data stream - Binary or Text public int Format { get { return data.Format; } } /// The file name that's associated with the data stream. public string FileName { get { return data.FileName; } } /// Return the file name as an unintrepreted byte array. public byte[] GetRawFileName() { return data.GetRawFileName(); } /// The modification time for the file. public DateTime ModificationTime { get { return DateTimeUtilities.UnixMsToDateTime(data.ModificationTime); } } /// The raw input stream for the data stream. public Stream GetInputStream() { return data.GetInputStream(); } /// The input stream representing the data stream. public Stream GetDataStream() { return GetInputStream(); } } }