EnvOpen() private method

private EnvOpen ( IntPtr &handle, String fileName, int flags, Parameter parameters ) : int
handle System.IntPtr
fileName String
flags int
parameters Parameter
return int
コード例 #1
0
        /// <summary>
        /// Opens an existing Environment
        /// </summary>
        /// <remarks>
        /// This method wraps the native ups_env_open function.
        /// </remarks>
        ///
        /// <param name="fileName">The file name of the Environment file.</param>
        /// <param name="flags">Optional flags for this operation, combined
        /// with bitwise OR. Possible flags are:
        ///   <list type="bullet">
        ///   <item><see cref="UpsConst.UPS_READ_ONLY" />
        ///     Opens the file for reading only. Operations which need
        ///     write access (i.e. Database.Insert)
        ///     will return <see cref="UpsConst.UPS_WRITE_PROTECTED" />.
        ///     </item><br />
        ///   <item><see cref="UpsConst.UPS_ENABLE_FSYNC" />
        ///     Immediately write modified pages to the disk. This
        ///     slows down all Database operations, but may save the
        ///     Database integrity in case of a system crash.</item><br />
        ///   <item><see cref="UpsConst.UPS_DISABLE_MMAP" />
        ///     Do not use memory mapped files for I/O. By default,
        ///     upscaledb checks if it can use mmap, since mmap is faster
        ///     than read/write. For performance reasons, this flag should
        ///     not be used.</item><br />
        ///   <item><see cref="UpsConst.UPS_AUTO_RECOVERY" />
        ///     Automatically recover the Database, if necessary. This
        ///     flag imples <see cref="UpsConst.UPS_ENABLE_TRANSACTIONS" />.
        ///     </item><br />
        ///   <item><see cref="UpsConst.UPS_ENABLE_TRANSACTIONS" />
        ///     Enables Transactions for this Database.</item><br />
        ///   </list>
        /// </param>
        /// <param name="parameters">An array of <see cref="Parameter" />
        /// structures. The following parameters are available:<br />
        ///   <list type="bullet">
        ///   <item><see cref="UpsConst.UPS_PARAM_CACHESIZE" />
        ///     The size of the Database cache, in bytes. The default size
        ///     is defined in <i>src/config.h</i> as UPS_DEFAULT_CACHESIZE
        ///     - usually 2 MB.</item><br />
        ///   </list>
        /// </param>
        /// <exception cref="DatabaseException">
        ///   <list type="bullet">
        ///   <item><see cref="UpsConst.UPS_INV_PARAMETER"/>
        ///     if an invalid combination of flags was specified</item>
        ///   <item><see cref="UpsConst.UPS_FILE_NOT_FOUND"/>
        ///     if the file does not exist</item>
        ///   <item><see cref="UpsConst.UPS_IO_ERROR"/>
        ///     if the file could not be opened or reading/writing failed</item>
        ///   <item><see cref="UpsConst.UPS_INV_FILE_VERSION"/>
        ///     if the Database version is not compatible with the library
        ///     version</item>
        ///   <item><see cref="UpsConst.UPS_OUT_OF_MEMORY"/>
        ///     if memory could not be allocated</item>
        ///   <item><see cref="UpsConst.UPS_WOULD_BLOCK"/>
        ///     if another process has locked the file</item>
        ///   </list>
        /// </exception>
        public void Open(String fileName, int flags,
                         Parameter[] parameters)
        {
            int st;

            handle = new IntPtr(0);
            if (parameters != null)
            {
                parameters = AppendNullParameter(parameters);
            }
            lock (this) {
                st = NativeMethods.EnvOpen(out handle, fileName, flags,
                                           parameters);
            }
            if (st != 0)
            {
                throw new DatabaseException(st);
            }
        }