Пример #1
0
        public static RandomAccessFile NewRandomAccessFile(string path, bool readOnly, bool lockFile)
        {
            RandomAccessFile raf = null;
            var ok = false;

            try
            {
                raf = new RandomAccessFile(path, readOnly, lockFile);
                if (lockFile)
                {
                    Platform4.LockFile(path, raf);
                }
                ok = true;
                return(raf);
            }
            catch (IOException x)
            {
                if (new File(path).Exists())
                {
                    throw new DatabaseFileLockedException(path, x);
                }
                throw new Db4oIOException(x);
            }
            finally
            {
                if (!ok && raf != null)
                {
                    raf.Close();
                }
            }
        }