Exemplo n.º 1
0
 public Item(string key, ByteVector value)
 {
     this.key = key;
     this.type = ItemType.Binary;
     this.data = value as ReadOnlyByteVector;
     if (this.data == null)
     {
         this.data = new ReadOnlyByteVector(value);
     }
 }
Exemplo n.º 2
0
 static FrameHeader()
 {
     ReadOnlyByteVector[] vectorArray1 = new ReadOnlyByteVector[,] { 
         { "BUF", "RBUF" }, { "CNT", "PCNT" }, { "COM", "COMM" }, { "CRA", "AENC" }, { "ETC", "ETCO" }, { "GEO", "GEOB" }, { "IPL", "TIPL" }, { "MCI", "MCDI" }, { "MLL", "MLLT" }, { "PIC", "APIC" }, { "POP", "POPM" }, { "REV", "RVRB" }, { "SLT", "SYLT" }, { "STC", "SYTC" }, { "TAL", "TALB" }, { "TBP", "TBPM" }, 
         { "TCM", "TCOM" }, { "TCO", "TCON" }, { "TCP", "TCMP" }, { "TCR", "TCOP" }, { "TDA", "TDAT" }, { "TIM", "TIME" }, { "TDY", "TDLY" }, { "TEN", "TENC" }, { "TFT", "TFLT" }, { "TKE", "TKEY" }, { "TLA", "TLAN" }, { "TLE", "TLEN" }, { "TMT", "TMED" }, { "TOA", "TOAL" }, { "TOF", "TOFN" }, { "TOL", "TOLY" }, 
         { "TOR", "TDOR" }, { "TOT", "TOAL" }, { "TP1", "TPE1" }, { "TP2", "TPE2" }, { "TP3", "TPE3" }, { "TP4", "TPE4" }, { "TPA", "TPOS" }, { "TPB", "TPUB" }, { "TRC", "TSRC" }, { "TRK", "TRCK" }, { "TSS", "TSSE" }, { "TT1", "TIT1" }, { "TT2", "TIT2" }, { "TT3", "TIT3" }, { "TXT", "TOLY" }, { "TXX", "TXXX" }, 
         { "TYE", "TDRC" }, { "UFI", "UFID" }, { "ULT", "USLT" }, { "WAF", "WOAF" }, { "WAR", "WOAR" }, { "WAS", "WOAS" }, { "WCM", "WCOM" }, { "WCP", "WCOP" }, { "WPB", "WPUB" }, { "WXX", "WXXX" }, { "XRV", "RVA2" }
      };
     version2_frames = vectorArray1;
     ReadOnlyByteVector[] vectorArray2 = new ReadOnlyByteVector[,] { { "TORY", "TDOR" }, { "TYER", "TDRC" }, { "XRVA", "RVA2" } };
     version3_frames = vectorArray2;
 }
Exemplo n.º 3
0
        public FrameHeader(ByteVector data, byte version)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            this.flags = FrameFlags.None;
            this.frame_size = 0;
            if ((version < 2) || (version > 4))
            {
                throw new CorruptFileException("Unsupported tag version.");
            }
            if (data.Count < ((version != 2) ? 4 : 3))
            {
                throw new CorruptFileException("Data must contain at least a frame ID.");
            }
            switch (version)
            {
                case 2:
                    this.frame_id = ConvertId(data.Mid(0, 3), version, false);
                    if (data.Count >= 6)
                    {
                        this.frame_size = data.Mid(3, 3).ToUInt();
                        return;
                    }
                    return;

                case 3:
                    this.frame_id = ConvertId(data.Mid(0, 4), version, false);
                    if (data.Count >= 10)
                    {
                        this.frame_size = data.Mid(4, 4).ToUInt();
                        this.flags = (FrameFlags) ((ushort) ((((data[8] << 7) & 0x7000) | ((data[9] >> 4) & 12)) | ((data[9] << 1) & 0x40)));
                        return;
                    }
                    return;

                case 4:
                    this.frame_id = new ReadOnlyByteVector(data.Mid(0, 4));
                    if (data.Count >= 10)
                    {
                        this.frame_size = SynchData.ToUInt(data.Mid(4, 4));
                        this.flags = (FrameFlags) data.Mid(8, 2).ToUShort();
                        return;
                    }
                    return;
            }
            throw new CorruptFileException("Unsupported tag version.");
        }
Exemplo n.º 4
0
 private Item(Item item)
 {
     this.type = item.type;
     this.key = item.key;
     if (item.data != null)
     {
         this.data = new ReadOnlyByteVector(item.data);
     }
     if (item.text != null)
     {
         this.text = (string[]) item.text.Clone();
     }
     this.read_only = item.read_only;
     this.size_on_disk = item.size_on_disk;
 }
Exemplo n.º 5
0
 static Footer()
 {
     FileIdentifier = "3DI";
 }
 static StreamHeader()
 {
     FileIdentifier = "MAC ";
 }
 static StreamHeader()
 {
     FileIdentifier = "COMM";
 }
Exemplo n.º 8
0
 static Header()
 {
     FileIdentifier = "ID3";
 }
Exemplo n.º 9
0
 protected void Parse(ByteVector data, int offset)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     if (offset < 0)
     {
         throw new ArgumentOutOfRangeException("offset");
     }
     if (data.Count < (offset + 11))
     {
         throw new CorruptFileException("Not enough data for APE Item");
     }
     uint num = data.Mid(offset, 4).ToUInt(false);
     uint num2 = data.Mid(offset + 4, 4).ToUInt(false);
     this.ReadOnly = (num2 & 1) == 1;
     this.Type = ((ItemType) (num2 >> 1)) & (ItemType.Locator | ItemType.Binary);
     int num3 = data.Find(ByteVector.TextDelimiter(StringType.UTF8), offset + 8);
     this.key = data.ToString(StringType.UTF8, offset + 8, (num3 - offset) - 8);
     if (num > ((data.Count - num3) - 1))
     {
         throw new CorruptFileException("Invalid data length.");
     }
     this.size_on_disk = ((num3 + 1) + ((int) num)) - offset;
     if (this.Type == ItemType.Binary)
     {
         this.data = new ReadOnlyByteVector(data.Mid(num3 + 1, (int) num));
     }
     else
     {
         this.text = data.Mid(num3 + 1, (int) num).ToStrings(StringType.UTF8, 0);
     }
 }
Exemplo n.º 10
0
 public ByteVector Render()
 {
     uint num = (uint) ((!this.ReadOnly ? 0 : 1) | (((int) this.Type) << 1));
     if (this.IsEmpty)
     {
         return new ByteVector();
     }
     ByteVector data = null;
     if (((this.type == ItemType.Binary) && (this.text == null)) && (this.data != null))
     {
         data = this.data;
     }
     if ((data == null) && (this.text != null))
     {
         data = new ByteVector();
         for (int i = 0; i < this.text.Length; i++)
         {
             if (i != 0)
             {
                 data.Add((byte) 0);
             }
             data.Add(ByteVector.FromString(this.text[i], StringType.UTF8));
         }
     }
     if ((data == null) || (data.Count == 0))
     {
         return new ByteVector();
     }
     ByteVector vector2 = new ByteVector();
     vector2.Add(ByteVector.FromUInt((uint) data.Count, false));
     vector2.Add(ByteVector.FromUInt(num, false));
     vector2.Add(ByteVector.FromString(this.key, StringType.UTF8));
     vector2.Add((byte) 0);
     vector2.Add(data);
     this.size_on_disk = vector2.Count;
     return vector2;
 }
Exemplo n.º 11
0
 static StreamHeader()
 {
     sftable = new ushort[] { 0xac44, 0xbb80, 0x93a8, 0x7d00 };
     FileIdentifier = "MP+";
 }
Exemplo n.º 12
0
 static XingHeader()
 {
     FileIdentifier = "Xing";
     Unknown = new XingHeader(0, 0);
 }
Exemplo n.º 13
0
 static VBRIHeader()
 {
     FileIdentifier = "VBRI";
     Unknown = new VBRIHeader(0, 0);
 }