private static Dbenv CreateEnv(EnvConfig envConfig) { BDbOffsetOf offsetOf = BDbOffsetOfReader.ReadXmlFile(); BDbOffsetOfInstance.SetInstance(offsetOf); IntPtr pdbenv; BerkeleyDbError error = BDbenvMethods.Create(offsetOf, out pdbenv); if (error != 0) { throw new InvalidOperationException("db_env_create error " + BDbenvMethods.StrError(error)); } BDbenvMethods methods = BDbenvMethods.GetMethods(); error = methods.Open(pdbenv, envConfig.DbHome, envConfig.OpenFlags); if (error == BerkeleyDbError.ENOENT && envConfig.UseTempIfFault) { String dbHome = Path.Combine(Path.GetTempPath(), "berkeley_db_home"); Directory.CreateDirectory(dbHome); error = methods.Open(pdbenv, dbHome, envConfig.OpenFlags); } if (error != 0) { methods.Close(pdbenv, 0); throw new InvalidOperationException("DB_ENV->open error " + BDbenvMethods.StrError(error)); } return(new Dbenv(pdbenv, methods)); }
public Dbenv(IntPtr pdbenv, BDbenvMethods methods) { Handle = pdbenv; Methods = methods; }