コード例 #1
0
        /// <summary>
        /// Creates a new Storage.
        /// </summary>
        /// <param name="path">A string containing information about storage location</param>
        public void CreateNew(string path)
        {
            CheckDisposed();

            if (PageManager == null)
            {
                throw new InvalidOperationException("Page manager is not set");
            }

            if (_isOpen)
            {
                throw new InvalidOperationException("Unable to create starage because this instance is using to operate with the other storage");
            }

            _path = path;
            FillInfo();
            WriteInfo();

            PageManager.CreateNewPageSpace();
            _isOpen = true;

            PageManager.Lock();
            try
            {
                PageManager.EnterAtomicOperation();

                Init();

                PageManager.ExitAtomicOperation();
                PageManager.EnterAtomicOperation();
            }
            finally
            {
                PageManager.Unlock();
            }
        }