private void InitFiles()
{
//Creates filestreams and rollbacks, restores rollback to the initial file, if necessary
try
{
RIC.OpenRemoteTable(this._fileName);
//this._fsData = new FileStream(this._fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, _fileStreamBufferSize, FileOptions.WriteThrough);
//this._fsRollback = new FileStream(this._fileName + ".rol", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, _fileStreamBufferSize, FileOptions.WriteThrough);
//this._fsRollbackHelper = new FileStream(this._fileName + ".rhp", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, _fileStreamBufferSize, FileOptions.WriteThrough);
//!!!!We dont have this value in root yet, could have and economize tail of the file in case if rollback occured
//if (this._fsData.Length == 0)
if (RIC.DataFileLength == 0)
{
//Writing initial root data
RIC.DataFilePosition = 0;
RIC.DataFileWrite(new byte[this._trieSettings.ROOT_SIZE], 0, this._trieSettings.ROOT_SIZE, false);
//_fsData.Position = 0;
//_fsData.Write(new byte[this._trieSettings.ROOT_SIZE], 0, this._trieSettings.ROOT_SIZE);
if (_backupIsActive)
{
this._configuration.Backup.WriteBackupElement(ulFileName, 0, 0, new byte[this._trieSettings.ROOT_SIZE]);
}
//no flush here
}
eofData = RIC.DataFileLength;
//eofData = this._fsData.Length;
//Check is .rhp is empty add 0 pointer
//if (this._fsRollbackHelper.Length == 0)
if (RIC.RollbackHelperFileLength == 0)
{
//no sense to write here
}
else
{
InitRollback();
}
_storageFixTime = DateTime.UtcNow;
}
catch (Exception ex)
{
IsOperable = false;
throw DBreezeException.Throw(DBreezeException.eDBreezeExceptions.DB_IS_NOT_OPERABLE, "RISR INIT FAILED: " + this._fileName, ex);
}
}