public CompoundFileDirectory(Directory directory, string fileName, IOContext context, bool openForWrite)
{
this.Directory_Renamed = directory;
this.FileName = fileName;
this.ReadBufferSize = BufferedIndexInput.BufferSize(context);
this.isOpen = false;
this.OpenForWrite = openForWrite;
if (!openForWrite)
{
bool success = false;
Handle = directory.CreateSlicer(fileName, context);
try
{
this.Entries = ReadEntries(Handle, directory, fileName);
success = true;
}
finally
{
if (!success)
{
IOUtils.CloseWhileHandlingException(Handle);
}
}
this.isOpen = true;
Writer = null;
}
else
{
Debug.Assert(!(directory is CompoundFileDirectory), "compound file inside of compound file: " + fileName);
this.Entries = SENTINEL;
this.isOpen = true;
Writer = new CompoundFileWriter(directory, fileName);
Handle = null;
}
}