Example #1
0
		public BDB43(string file, string table, bool create, DBFormat format, bool allowDuplicates, Env environment) {
			this.env = environment;
			
			db_create(out dbp, environment.envptr, 0);
			funcs = (dbstruct)Marshal.PtrToStructure((IntPtr)((int)dbp+268), typeof(dbstruct));
			
			uint dbflags = DB_DIRECT_DB;
			if (allowDuplicates)
				dbflags |= DB_DUP; // DB_DUPSORT; 
			
			funcs.set_flags(dbp, dbflags);
			
			int type = (int)format;
			uint flags = DB_DIRTY_READ; // | DB_AUTO_COMMIT;
			int chmod_mode = 0;
			
			if (create)
				flags |= DB_CREATE;
			
			// if file & database are null, db is held in-memory
			// on file is taken as UTF8 (is this call right?)
			int ret = funcs.open(dbp, env.Txn, file, table, type, flags, chmod_mode);
			CheckError(ret);
			
			binfmt = new Serializer();
		}
Example #2
0
        public BDB43(string file, string table, bool create, DBFormat format, bool allowDuplicates, Env environment)
        {
            this.env = environment;

            db_create(out dbp, environment.envptr, 0);
            funcs = (dbstruct)Marshal.PtrToStructure((IntPtr)((int)dbp + 268), typeof(dbstruct));

            uint dbflags = DB_DIRECT_DB;

            if (allowDuplicates)
            {
                dbflags |= DB_DUP;                 // DB_DUPSORT;
            }
            funcs.set_flags(dbp, dbflags);

            int  type       = (int)format;
            uint flags      = DB_DIRTY_READ;        // | DB_AUTO_COMMIT;
            int  chmod_mode = 0;

            if (create)
            {
                flags |= DB_CREATE;
            }

            // if file & database are null, db is held in-memory
            // on file is taken as UTF8 (is this call right?)
            int ret = funcs.open(dbp, env.Txn, file, table, type, flags, chmod_mode);

            CheckError(ret);

            binfmt = new Serializer();
        }
Example #3
0
 public BDB46 Get(string name, DBFormat format)
 {
     if (!m_Storage.ContainsKey (name)) {
         if (m_StorageLock.WaitOne ()) {
             if (!m_Storage.ContainsKey (name)) {
                 string file = Path.Combine (Paths.ApplicationData, String.Format ("{0}.db", name));
                 var env = new BDB46.Env (Paths.ApplicationData);
                 var storage = new BDB46 (file, true, format, false, env);
                 m_Storage [name] = storage;
             }
         }
     }
     return m_Storage [name];
 }
Example #4
0
		public BDB43(string file, bool create, DBFormat format, bool allowDuplicates, Env environment)
			: this(file, null, create, format, allowDuplicates, environment) {
		}
Example #5
0
 public BDB43(string file, bool create, DBFormat format, bool allowDuplicates, Env environment)
     : this(file, null, create, format, allowDuplicates, environment)
 {
 }
Example #6
0
		public BDB46(string file, string table, bool create, DBFormat format, bool allowDuplicates, Env environment) {
			if (format == DBFormat.Recno)
				KeyType = DataType.UInt;
			
			this.env = environment;

			int offset = 296;
			if (IntPtr.Size == 8)
				offset = 504;
			
			db_create(out dbp, environment.envptr, 0);
			funcs = (dbstruct)Marshal.PtrToStructure((IntPtr)((int)dbp + offset), typeof(dbstruct));
			
			this.m_Format = format;
			this.m_File = file;
			
			int type = (int)format;
			uint flags = DB_DIRTY_READ; // | DB_AUTO_COMMIT;
			int chmod_mode = 0;
			
			if (create)
				flags |= DB_CREATE;

			/* needed for my renumber stuff. this shit is so hacked, i dont even care about
			 * maintaining compat at this point. oh well.
			 *
			 * -- Christian
			 */
			this.funcs.set_flags (dbp, DB_RENUMBER);
			
			// if file & database are null, db is held in-memory
			// on file is taken as UTF8 (is this call right?)
			int ret = funcs.open(dbp, env.Txn, file, table, type, flags, chmod_mode);
			CheckError(ret);
			
			binfmt = new Serializer();
		}