Ejemplo n.º 1
0
        void UpdateMe()
        {
            if (!DoUpdate)
            {
                return;
            }
            var newindex = new dvIndex();

            newindex.id = RecID;
            var bt    = new QuickStream(System.IO.File.OpenWrite($"{project.PrjFile}.Content"));          // Does this append?
            var start = bt.Size;

            bt.Position = bt.Size;
            foreach (string k in core.Keys)
            {
                bt.WriteByte(0);
                bt.WriteString(k);
                bt.WriteString(core[k]);
            }
            var einde = bt.Position;

            bt.Close();
            newindex.size          = einde - start;
            newindex.offset        = start;
            project.Indexes[RecID] = newindex;
            project.SaveIndexes();
        }
Ejemplo n.º 2
0
 public void DataWrite(QuickStream f)
 {
     foreach (string key in D.Keys)
     {
         f.WriteByte(0);
         f.WriteString(key);
         f.WriteString(D[key]);
         //Console.WriteLine($"Writing string {key} => {D[key]}");
     }
 }
Ejemplo n.º 3
0
 public TJCRCreate(string OutputFile, string FTStorage = "Store", string Signature = "")
 {
     JCR6.JERROR = "";
     // TODO: Make "Brute" always pass if asked for it in FT storage.
     if (!JCR6.CompDrivers.ContainsKey(FTStorage))
     {
         JCR6.JERROR = $"Storage method {FTStorage} not present!"; return;
     }
     mystream         = QuickStream.WriteFile(OutputFile, QuickStream.LittleEndian);
     FileTableStorage = FTStorage;
     mystream.WriteString("JCR6" + (char)26, true);
     ftoffint = (int)mystream.Position;
     MainFile = OutputFile;
     mystream.WriteInt(0);
     mystream.WriteByte(1);
     mystream.WriteString("__Signature");
     mystream.WriteString(Signature);
     mystream.WriteByte(2);
     mystream.WriteString("__CaseSensitive");
     mystream.WriteByte(0);
     mystream.WriteByte(255);
 }
Ejemplo n.º 4
0
 static public void WriteLine(string msg, byte r = 255, byte g = 255, byte b = 255)
 {
     foreach (string txt in msg.Split('\n'))
     {
         var line = new BCLine();
         line.txt = txt;
         line.r   = r;
         line.g   = g;
         line.b   = b;
         Debug.WriteLine($"Bubble Console:> {msg}");
         Line.Add(line);
         if (Line.Count > MaxLines)
         {
             Line.RemoveAt(0);
         }
         if (WrLog != null)
         {
             WrLog.WriteString($"<span style=\"color: #{r.ToString("X2")}{g.ToString("X2")}{b.ToString("X2")};\">{msg.Replace("\n","<br />")}</span><br />\n", true);
         }
     }
 }
Ejemplo n.º 5
0
        static BubConsole()
        {
            if (AllowWriteLog)
            {
                try {
                    WriteLine($"Output will be written to {WriteLogFile}", 255, 180, 0);
                    System.IO.Directory.CreateDirectory(qstr.ExtractDir(WriteLogFile));
                    WrLog = QuickStream.WriteFile(WriteLogFile);
                    WrLog.WriteString("<html>\n<head><title>Log from Bubble!</title></head><style>body{ color: white; background-color: black; font-family: courier; font-size:20pt; }</style>\n\n", true);
                } catch (Exception EX) {
                    WriteLine("ERROR!", 255, 0, 0);
                    WriteLine($"{EX.Message}", 255, 0, 0);
                    WriteLine("Due to this error I cannot guarantee the log will work!");
                    Console.Beep();
                }
            }
            WriteLine($"Bubble {MKL.Newest} - (c) Jeroen P. Broks", 255, 255, 0);
            var s = new NLua.Lua();
            var v = (string)s.DoString("return _VERSION")[0];

            WriteLine($"Uses {v} by PUC-Rio", 180, 0, 255);
            WriteLine($"Data folder: {Bubble_Save.SWorkDir}", 180, 255, 0);
            if (SBubble.JCR.Exists("Bubble/Background.png"))
            {
                WriteLine("Loading: Bubble/Background.png", 255, 180, 0);
                BackGround = TQMG.GetImage("Bubble/Console.png");
            }
            else if (SBubble.JCR.Exists("Bubble/Console.jpg"))
            {
                WriteLine("Loading: Bubble/Console.jpg", 255, 180, 0);
                BackGround = TQMG.GetImage("Bubble/Console.jpg");
            }
            else
            {
                WriteLine("No background found", 255, 0, 0);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Closes and finalizes JCR6 file so it's ready for usage.
        /// All Streams attacked to this JCR6 creation instance will automatically be closed and added according to their settings respectively.
        /// </summary>
        public void Close()
        {
            if (closed)
            {
                return;
            }
            CloseAllEntries();
            var whereami = mystream.Position;

            mystream.Position = ftoffint;
            mystream.WriteInt((int)whereami);
            mystream.Position = whereami;
            // TODO: finalizing JCR6 file
            var ms = new MemoryStream();
            var bt = new QuickStream(ms);

            foreach (string k in Comments.Keys)
            {
                bt.WriteByte(1);
                bt.WriteString("COMMENT");
                bt.WriteString(k);
                bt.WriteString(Comments[k]);
            }
            foreach (string k in Entries.Keys)
            {
                bt.WriteByte(1);
                bt.WriteString("FILE");
                var E = Entries[k];
                foreach (string k2 in E.datastring.Keys)
                {
                    bt.WriteByte(1); bt.WriteString(k2); bt.WriteString(E.datastring[k2]);
                }
                foreach (string k2 in E.databool.Keys)
                {
                    bt.WriteByte(2); bt.WriteString(k2); bt.WriteBool(E.databool[k2]);
                }
                foreach (string k2 in E.dataint.Keys)
                {
                    bt.WriteByte(3); bt.WriteString(k2); bt.WriteInt(E.dataint[k2]);
                }
                bt.WriteByte(255);
            }
            bt.WriteByte(255);
            // TODO: "BRUTE" support file table storage
            //Console.WriteLine($"Write on {whereami}/{mystream.Position}");
            var unpacked = ms.ToArray();
            var fts      = FileTableStorage;
            var packed   = JCR6.CompDrivers[FileTableStorage].Compress(unpacked);

            if (fts != "Store" || packed.Length >= unpacked.Length)
            {
                packed = unpacked; fts = "Store";
            }
            bt.Close();
            mystream.WriteInt(unpacked.Length);
            mystream.WriteInt(packed.Length);
            mystream.WriteString(fts);
            mystream.WriteBytes(packed);
            mystream.Close();
            closed = true;
        }
Ejemplo n.º 7
0
 public void WriteString(string s, bool raw = false) => stream.WriteString(s, raw);