summary refs log tree commit diff
path: root/crypto/src/openpgp/PgpLiteralData.cs
blob: d1b7b4a4dced3fe7283c237a84f36bdb7fff108c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.IO;

using Org.BouncyCastle.Utilities.Date;

namespace Org.BouncyCastle.Bcpg.OpenPgp
{
	/// <summary>Class for processing literal data objects.</summary>
    public class PgpLiteralData
		: PgpObject
    {
        public const char Binary = 'b';
        public const char Text = 't';
		public const char Utf8 = 'u';

		/// <summary>The special name indicating a "for your eyes only" packet.</summary>
        public const string Console = "_CONSOLE";

		private readonly LiteralDataPacket data;

		public PgpLiteralData(
            BcpgInputStream bcpgInput)
        {
            Packet packet = bcpgInput.ReadPacket();
            if (!(packet is LiteralDataPacket))
                throw new IOException("unexpected packet in stream: " + packet);

            this.data = (LiteralDataPacket)packet;
        }

		/// <summary>The format of the data stream - Binary or Text</summary>
        public int Format
        {
            get { return data.Format; }
        }

		/// <summary>The file name that's associated with the data stream.</summary>
        public string FileName
        {
			get { return data.FileName; }
        }

		/// Return the file name as an unintrepreted byte array.
		public byte[] GetRawFileName()
		{
			return data.GetRawFileName();
		}

		/// <summary>The modification time for the file.</summary>
        public DateTime ModificationTime
        {
			get { return DateTimeUtilities.UnixMsToDateTime(data.ModificationTime); }
        }

		/// <summary>The raw input stream for the data stream.</summary>
        public Stream GetInputStream()
        {
            return data.GetInputStream();
        }

		/// <summary>The input stream representing the data stream.</summary>
        public Stream GetDataStream()
        {
            return GetInputStream();
        }
    }
}