Example #1
0
        private C4View *OpenIndexWithOptions(C4DatabaseFlags options, bool dryRun = false)
        {
            if (_indexDB == null)
            {
                _indexDB = (C4View *)ForestDBBridge.Check(err =>
                {
                    var encryptionKey = default(C4EncryptionKey);
                    if (_dbStorage.EncryptionKey != null)
                    {
                        encryptionKey = new C4EncryptionKey(_dbStorage.EncryptionKey.KeyData);
                    }

                    return(Native.c4view_open(_dbStorage.Forest, _path, Name, dryRun  ? "0" : Delegate.MapVersion, options,
                                              &encryptionKey, err));
                });

                if (dryRun)
                {
                    ForestDBBridge.Check(err => Native.c4view_close(_indexDB, err));
                    _indexDB = null;
                }
            }

            return(_indexDB);
        }
Example #2
0
 public static C4BlobStore *c4blob_openStore(string dirPath,
                                             C4DatabaseFlags flags,
                                             C4EncryptionKey *encryptionKey,
                                             C4Error *outError)
 {
     using (var dirPath_ = new C4String(dirPath)) {
         return(NativeRaw.c4blob_openStore(dirPath_.AsC4Slice(), flags, encryptionKey, outError));
     }
 }
Example #3
0
        public void Open(string directory, Manager manager, bool readOnly)
        {
            if (IsOpen)
            {
                return;
            }

            IsOpen    = true;
            Directory = directory;
            if (!System.IO.Directory.Exists(directory))
            {
                System.IO.Directory.CreateDirectory(Directory);
            }

            _config = readOnly ? C4DatabaseFlags.ReadOnly : C4DatabaseFlags.Create;
            if (AutoCompact)
            {
                _config |= C4DatabaseFlags.AutoCompact;
            }

            _fdbConnections.GetOrAdd(Thread.CurrentThread.ManagedThreadId, x => (IntPtr)Reopen());
        }
 public static extern C4BlobStore *c4blob_openStore(C4Slice dirPath, C4DatabaseFlags flags, C4EncryptionKey *encryptionKey, C4Error *outError);
        public void Open(string directory, Manager manager, bool readOnly)
        {
            if(IsOpen) {
                return;
            }

            IsOpen = true;
            Directory = directory;
            if (!System.IO.Directory.Exists(directory)) {
                System.IO.Directory.CreateDirectory(Directory);
            }

            _config = readOnly ? C4DatabaseFlags.ReadOnly : C4DatabaseFlags.Create;
            if (AutoCompact) {
                _config |= C4DatabaseFlags.AutoCompact;
            }

            _fdbConnections.GetOrAdd(Thread.CurrentThread.ManagedThreadId, x => (IntPtr)Reopen());
        }
Example #6
0
        public static C4Database* c4db_open(C4Slice path, C4DatabaseFlags flags, 
            C4EncryptionKey *encryptionKey, C4Error *outError)
        {
            #if DEBUG
            var retVal = _c4db_open(path, flags, encryptionKey, outError);
            if(retVal != null) {
                _AllocatedObjects[(IntPtr)retVal] = "C4Database";
                #if ENABLE_LOGGING
                Console.WriteLine("[c4db_open] Allocated 0x{0}", ((IntPtr)retVal).ToString("X"));
                #endif
            }

            return retVal;
            #else
            return _c4db_open(path, flags, encryptionKey, outError);
            #endif
        }
Example #7
0
 private static extern C4Database* _c4db_open(C4Slice path, C4DatabaseFlags flags, 
     C4EncryptionKey *encryptionKey, C4Error *outError);
Example #8
0
 /// <summary>
 /// Opens a database.
 /// </summary>
 /// <param name="path">The path to the DB file</param>
 /// <param name="readOnly">Whether or not the DB should be opened in read-only mode</param>
 /// <param name="encryptionKey">The option encryption key used to encrypt the database</param>
 /// <param name="outError">The error that occurred if the operation doesn't succeed</param>
 /// <returns>A database instance for use in the C4 API</returns>
 public static C4Database *c4db_open(string path, C4DatabaseFlags flags,
     C4EncryptionKey *encryptionKey, C4Error *outError)
 {
     using(var path_ = new C4String(path)) {
         return c4db_open(path_.AsC4Slice(), flags, encryptionKey, outError);
     }
 }
Example #9
0
 /// <summary>
 /// Opens a view, or creates it if the file doesn't already exist.
 /// </summary>
 /// <param name="db">The database the view is associated with</param>
 /// <param name="path">The file that the view is stored in</param>
 /// <param name="viewName">The name of the view</param>
 /// <param name="version">The version of the view's map function</param>
 /// <param name="flags">The flags for opening the view file</param>
 /// <param name="encryptionKey">The option encryption key used to encrypt the database</param>
 /// <param name="outError">The error that occurred if the operation doesn't succeed</param>
 /// <returns>A pointer to the view on success, otherwise null</returns>
 public static C4View* c4view_open(C4Database *db, string path, string viewName, string version, C4DatabaseFlags flags,
     C4EncryptionKey *encryptionKey, C4Error *outError)
 {
     using(var path_ = new C4String(path))
     using(var viewName_ = new C4String(viewName))
     using(var version_ = new C4String(version)) {
         return c4view_open(db, path_.AsC4Slice(), viewName_.AsC4Slice(), version_.AsC4Slice(), flags, encryptionKey, outError);   
     }
 }
Example #10
0
 private static extern C4View* _c4view_open(C4Database *db, C4Slice path, C4Slice viewName, C4Slice version, 
     C4DatabaseFlags flags, C4EncryptionKey *encryptionKey, C4Error *outError);
 public C4BlobStore *c4blob_openStore(string dirPath, C4DatabaseFlags flags, C4EncryptionKey *encryptionKey, C4Error *outError) => Native.c4blob_openStore(dirPath, flags, encryptionKey, outError);
 public static C4BlobStore *c4blob_openStore(FLSlice dirPath, C4DatabaseFlags flags, C4EncryptionKey *encryptionKey, C4Error *outError) => Impl.c4blob_openStore(dirPath, flags, encryptionKey, outError);
Example #13
0
        /// <summary>
        /// Opens a view, or creates it if the file doesn't already exist.
        /// </summary>
        /// <param name="db">The database the view is associated with</param>
        /// <param name="path">The file that the view is stored in</param>
        /// <param name="viewName">The name of the view</param>
        /// <param name="version">The version of the view's map function</param>
        /// <param name="flags">The flags for opening the view file</param>
        /// <param name="encryptionKey">The option encryption key used to encrypt the database</param>
        /// <param name="outError">The error that occurred if the operation doesn't succeed</param>
        /// <returns>A pointer to the view on success, otherwise null</returns>
        public static C4View* c4view_open(C4Database *db, C4Slice path, C4Slice viewName, C4Slice version, 
            C4DatabaseFlags flags, C4EncryptionKey *encryptionKey, C4Error *outError)
        {
            #if DEBUG
            var retVal = _c4view_open(db, path, viewName, version, flags, encryptionKey, outError);
            if(retVal != null) {
                _AllocatedObjects.TryAdd((IntPtr)retVal, "C4View");
                #if ENABLE_LOGGING
                Console.WriteLine("[c4view_open] Allocated 0x{0}", ((IntPtr)retVal).ToString("X"));
                #endif
            }

            return retVal;
            #else
            return _c4view_open(db, path, viewName, version, flags, encryptionKey, outError);
            #endif
        }