Inheritance: MonoBehaviour
Example #1
0
        public void GetMeta(META id, ref uint meta)
        {
            BtShared bt = Bt;
            Enter();
            Debug.Assert(InTrans > TRANS.NONE);
            Debug.Assert(querySharedCacheTableLock(this, MASTER_ROOT, LOCK.READ) == RC.OK);
            Debug.Assert(bt.Page1 != null);
            Debug.Assert(id >= 0 && (int)id <= 15);
            meta = ConvertEx.Get4(bt.Page1.Data, 36 + (int)id * 4);
            // If auto-vacuum is disabled in this build and this is an auto-vacuum database, mark the database as read-only.
#if OMIT_AUTOVACUUM
            if (idx == META.LARGEST_ROOT_PAGE && meta > 0)
                bt.BtsFlags |= BTS.READ_ONLY;
#endif
            Leave();
        }
Example #2
0
        public RC UpdateMeta(META id, uint meta)
        {
            BtShared bt = Bt;
            Debug.Assert((int)id >= 1 && (int)id <= 15);
            Enter();
            Debug.Assert(InTrans == TRANS.WRITE);
            Debug.Assert(bt.Page1 != null);
            byte[] p1 = bt.Page1.Data;
            var rc = Pager.Write(bt.Page1.DBPage);
            if (rc == RC.OK)
            {
                ConvertEx.Put4(p1, 36 + (int)id * 4, meta);
#if !OMIT_AUTOVACUUM
                if (id == META.INCR_VACUUM)
                {
                    Debug.Assert(bt.AutoVacuum || meta == 0);
                    Debug.Assert(meta == 0 || meta == 1);
                    bt.IncrVacuum = (meta != 0);
                }
#endif
            }
            Leave();
            return rc;
        }
        protected override void ReadFile(byte[] contents)
        {
            using (MemoryStream file = new MemoryStream(contents))
                using (BinaryRobloxFileReader reader = new BinaryRobloxFileReader(this, file))
                {
                    // Verify the signature of the file.
                    byte[] binSignature = reader.ReadBytes(14);
                    string signature    = Encoding.UTF7.GetString(binSignature);

                    if (signature != MagicHeader)
                    {
                        throw new InvalidDataException("Provided file's signature does not match BinaryRobloxFile.MagicHeader!");
                    }

                    // Read header data.
                    Version      = reader.ReadUInt16();
                    NumClasses   = reader.ReadUInt32();
                    NumInstances = reader.ReadUInt32();
                    Reserved     = reader.ReadInt64();

                    // Begin reading the file chunks.
                    bool reading = true;

                    Classes   = new INST[NumClasses];
                    Instances = new Instance[NumInstances];

                    while (reading)
                    {
                        try
                        {
                            var chunk = new BinaryRobloxFileChunk(reader);
                            IBinaryFileChunk handler = null;

                            switch (chunk.ChunkType)
                            {
                            case "INST":
                                handler = new INST();
                                break;

                            case "PROP":
                                handler = new PROP();
                                break;

                            case "PRNT":
                                handler = new PRNT();
                                break;

                            case "META":
                                handler = new META();
                                break;

                            case "SSTR":
                                handler = new SSTR();
                                break;

                            case "SIGN":
                                handler = new SIGN();
                                break;

                            case "END\0":
                                ChunksImpl.Add(chunk);
                                reading = false;
                                break;

                            case string unhandled:
                                Console.Error.WriteLine("BinaryRobloxFile - Unhandled chunk-type: {0}!", unhandled);
                                break;

                            default: break;
                            }

                            if (handler != null)
                            {
                                using (var readBuffer = new MemoryStream(chunk.Data))
                                {
                                    using (var dataReader = new BinaryRobloxFileReader(this, readBuffer))
                                    {
                                        chunk.Handler = handler;
                                        handler.Load(dataReader);
                                    }
                                }

                                ChunksImpl.Add(chunk);
                            }
                        }
                        catch (EndOfStreamException)
                        {
                            throw new Exception("Unexpected end of file!");
                        }
                    }
                }
        }