Open() public method

public Open ( long offset ) : void
offset long
return void
Ejemplo n.º 1
0
        private void InitObjectStore()
        {
            // Does the file already exist?
            bool blobStoreExists = StoreSystem.StoreExists(ObjectStoreName);
            // If the blob store doesn't exist and we are read_only, we can't do
            // anything further so simply return.
            if (!blobStoreExists && IsReadOnly) {
                return;
            }

            // The blob store,
            if (blobStoreExists) {
                lobStore = StoreSystem.OpenStore(ObjectStoreName);
            } else {
                lobStore = StoreSystem.CreateStore(ObjectStoreName);
            }

            try {
                lobStore.Lock();

                // TODO: have multiple BLOB stores
                LargeObjectStore = new ObjectStore(0, lobStore);

                // Get the 64 byte fixed area
                var fixedArea = lobStore.GetArea(-1, false);
                // If the blob store didn't exist then we need to create it here,
                if (!blobStoreExists) {
                    long headerP = LargeObjectStore.Create();
                    fixedArea.WriteInt8(headerP);
                    fixedArea.Flush();
                } else {
                    // Otherwise we need to initialize the blob store
                    long headerP = fixedArea.ReadInt8();
                    LargeObjectStore.Open(headerP);
                }
            } finally {
                lobStore.Unlock();
            }
        }