Ejemplo n.º 1
0
        public override TJCRDIR Dir(string file)
        {
            var         ret = new TJCRDIR();
            QuickStream bt  = null;

            try {
                bt = QuickStream.ReadFile(file);
                if (bt.ReadString(header.Length) != header)
                {
                    throw new Exception("AR archive with incorrect header");
                }
                while (!bt.EOF)
                {
                    var e = new TJCREntry();
                    e.Entry = bt.ReadNullTerminatedString(16).Trim(); if (qstr.Suffixed(e.Entry, "/"))
                    {
                        e.Entry = qstr.Left(e.Entry, e.Entry.Length - 1);
                    }
                    Chat($"File: \"{e.Entry}\"");
                    e.dataint["__TimeStamp"] = qstr.ToInt(bt.ReadNullTerminatedString(12)); Chat($"TimeStamp: {e.dataint["__TimeStamp"]}!");
                    Chat($"OwnerID:  {bt.ReadNullTerminatedString(6)}"); // OwnerID -- Not relevant or supported by JCR6 (yet)
                    Chat($"GroupID:  {bt.ReadNullTerminatedString(6)}"); // GroupID -- Not relevant or supported by JCR6 (yet)
                    Chat($"FileMode: {bt.ReadNullTerminatedString(8)}"); // Permisisons -- Not yet relevant, but might be added later!
                    e.Size           = qstr.ToInt(bt.ReadNullTerminatedString(10)); Chat($"Size: {e.Size}");
                    e.CompressedSize = e.Size;
                    e.Storage        = "Store";
                    e.MainFile       = file;
                    //if (bt.ReadString(2) != ending) throw new Exception("End of file record is not 600A");
                    var e1 = bt.ReadByte();
                    var e2 = bt.ReadByte();
                    if (e1 != 0x60)
                    {
                        throw new Exception($"0x60 expected, but got {e1.ToString("X2")}");
                    }
                    if (e2 != 0x0a)
                    {
                        throw new Exception($"0x0a expected, but got {e1.ToString("X2")}");
                    }
                    ret.Entries[e.Entry.ToUpper()] = e;
                    e.Offset     = (int)bt.Position;
                    bt.Position += e.Size;
                    byte b;
                    do
                    {
                        b = bt.ReadByte();
                    } while (b == 10);
                    bt.Position--;
                }
                return(ret);
            } catch (Exception NETERROR) {
#if DEBUG
                JCR6.JERROR = $"{NETERROR.Message}\n{NETERROR.StackTrace}";
#else
                JCR6.JERROR = NETERROR.Message;
#endif
                return(null);
            } finally {
                if (bt != null)
                {
                    bt.Close();
                }
            }
        }