public /*internal*/ RAMOutputStream(RAMFile f) { file = f; // make sure that we switch to the // first needed buffer lazily currentBufferIndex = - 1; currentBuffer = null; }
public /*internal*/ RAMOutputStream(RAMFile f) { file = f; // make sure that we switch to the // first needed buffer lazily currentBufferIndex = -1; currentBuffer = null; }
public /*internal*/ RAMInputStream(RAMFile f) { file = f; length = file.length; if (length / BUFFER_SIZE >= System.Int32.MaxValue) { throw new System.IO.IOException("Too large RAMFile! " + length); } // make sure that we switch to the // first needed buffer lazily currentBufferIndex = - 1; currentBuffer = null; }
public /*internal*/ RAMInputStream(RAMFile f) { file = f; length = file.length; if (length / BUFFER_SIZE >= System.Int32.MaxValue) { throw new System.IO.IOException("Too large RAMFile! " + length); } // make sure that we switch to the // first needed buffer lazily currentBufferIndex = -1; currentBuffer = null; }
/// <summary>Creates a new, empty file in the directory with the given name. Returns a stream writing this file. </summary> public override IndexOutput CreateOutput(System.String name) { EnsureOpen(); RAMFile file = new RAMFile(this); lock (this) { RAMFile existing = (RAMFile)fileMap[name]; if (existing != null) { sizeInBytes -= existing.sizeInBytes; existing.directory = null; } fileMap[name] = file; } return(new RAMOutputStream(file)); }
/// <summary>Removes an existing file in the directory.</summary> /// <throws> IOException if the file does not exist </throws> public override void DeleteFile(System.String name) { lock (this) { EnsureOpen(); RAMFile file = (RAMFile)fileMap[name]; if (file != null) { fileMap.Remove(name); file.directory = null; sizeInBytes -= file.sizeInBytes; } else { throw new System.IO.FileNotFoundException(name); } } }
public override void RenameFile(System.String from, System.String to) { lock (this) { EnsureOpen(); RAMFile fromFile = (RAMFile)fileMap[from]; if (fromFile == null) { throw new System.IO.FileNotFoundException(from); } RAMFile toFile = (RAMFile)fileMap[to]; if (toFile != null) { sizeInBytes -= toFile.sizeInBytes; // updates to RAMFile.sizeInBytes synchronized on directory toFile.directory = null; } fileMap.Remove(from); fileMap[to] = fromFile; } }
/// <summary>Creates a new, empty file in the directory with the given name. Returns a stream writing this file. </summary> public override IndexOutput CreateOutput(System.String name) { EnsureOpen(); RAMFile file = new RAMFile(this); lock (this) { RAMFile existing = (RAMFile) fileMap[name]; if (existing != null) { sizeInBytes -= existing.sizeInBytes; existing.directory = null; } fileMap[name] = file; } return new RAMOutputStream(file); }