public override IndexInputSlicer CreateSlicer(string name, IOContext context) { lock (this) { EnsureOpen(); if (VERBOSE) { Console.WriteLine("nrtdir.openInput name=" + name); } #pragma warning disable 612, 618 if (cache.FileExists(name)) #pragma warning restore 612, 618 { if (VERBOSE) { Console.WriteLine(" from cache"); } return(cache.CreateSlicer(name, context)); } else { return(@delegate.CreateSlicer(name, context)); } } }
/// <summary> /// Create a new CompoundFileDirectory. /// </summary> 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; } }
/// <summary> /// Create a new <see cref="CompoundFileDirectory"/>. /// </summary> public CompoundFileDirectory(Directory directory, string fileName, IOContext context, bool openForWrite) { this.directory = directory; this.fileName = fileName; this.readBufferSize = BufferedIndexInput.GetBufferSize(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.DisposeWhileHandlingException(handle); } } this.IsOpen = true; writer = null; } else { if (Debugging.AssertsEnabled) { Debugging.Assert(!(directory is CompoundFileDirectory), "compound file inside of compound file: {0}", fileName); } this.entries = SENTINEL; this.IsOpen = true; writer = new CompoundFileWriter(directory, fileName); handle = null; } }
public override IndexInputSlicer CreateSlicer(string name, IOContext context) { lock (this) { EnsureOpen(); if (VERBOSE) { Console.WriteLine("nrtdir.openInput name=" + name); } if (Cache.FileExists(name)) { if (VERBOSE) { Console.WriteLine(" from cache"); } return(Cache.CreateSlicer(name, context)); } else { return(@delegate.CreateSlicer(name, context)); } } }