Ejemplo n.º 1
0
        /*
         *  The XTag function is need to add extra functionality to JCR Dir and is called by JCR_Dir if these extra functions are actually used.
         *
         *  (Well, the need of this XTag function lead to JCR5 becoming really really ugly, and that eventually lead to me realizing that if JCR5 would ever be able to do more a more flexible format was needed, hence the birth of JCR6. ;)
         *
         */
        void XTag(QuickStream BT, TJCRDIR JCR, bool LoadComments, string JCRFile)
        {
            string XTC;  // Stands for 'XTag Command'. I'm not promoting any sorts of stuff here(in fact I recommend not to use that) :P
            var    Length = BT.ReadInt();

            XTC = BT.ReadString(Length).ToUpper();
            string  F;
            TJCRDIR J;
            var     D = System.IO.Path.GetDirectoryName(JCRFile).Replace(@"\", "/"); //Replace(ExtractDir(JCRFile),"\","/"); If D And Right(D,1)<>"/" D:+"/"

            if (D != "" && qstr.Right(D, 1) != "/")
            {
                D += "/";
            }
            //'JCRD_Print "XTag: "+XTC
            switch (XTC)
            {
            case "IMP":
            case "IMPORT":
                Length = BT.ReadInt();
                F      = BT.ReadString(Length).Replace("\\", "/");
                if (qstr.Left(F, 1) != "/" && qstr.Mid(F, 2, 1) != ":" && System.IO.File.Exists(D + F))
                {
                    F = D + F;       //' If the required file to import is found in the same directory than hit that file.
                }
                J = JCR6.Dir(F);     //' ,LoadComments)
                if (J == null)
                {
                    //'JCRD_Print "WARNING! Could not import "+F+"~n= Report: "+JCRD_DumpError
                }
                else
                {
                    //'JCRD_Print "Importing: "+F
                    //'For Local K$=EachIn MapKeys(J)
                    //'   MapInsert JCR,K,MapValueForKey(J,K)
                    //'   Next
                    JCR.Patch(J);
                }
                break;

            default:
                JCR_JAMERR("WARNING! Unknown XTag in JCR file!", "?", "?", "XTAG");
                break;
            }
        }
Ejemplo n.º 2
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();
                }
            }
        }