/// <summary>Copy the current contents of this buffer to the named output. </summary> public virtual void WriteTo(OutputStream out_Renamed) { Flush(); long end = file.length; long pos = 0; int buffer = 0; while (pos < end) { int length = BUFFER_SIZE; long nextPos = pos + length; if (nextPos > end) { // at the last buffer length = (int) (end - pos); } out_Renamed.WriteBytes((byte[]) file.buffers[buffer++], length); pos = nextPos; } }
/// <summary>Copy the current contents of this buffer to the named output. </summary> public virtual void WriteTo(OutputStream out_Renamed) { Flush(); long end = file.length; long pos = 0; int buffer = 0; while (pos < end) { int length = BUFFER_SIZE; long nextPos = pos + length; if (nextPos > end) { // at the last buffer length = (int)(end - pos); } out_Renamed.WriteBytes((byte[])file.buffers[buffer++], length); pos = nextPos; } }
private RAMDirectory(Directory dir, bool closeDir) { System.String[] files = dir.List(); for (int i = 0; i < files.Length; i++) { // make place on ram disk OutputStream os = CreateFile(System.IO.Path.GetFileName(files[i])); // read current file InputStream is_Renamed = dir.OpenFile(files[i]); // and copy to ram disk int len = (int)is_Renamed.Length(); byte[] buf = new byte[len]; is_Renamed.ReadBytes(buf, 0, len); os.WriteBytes(buf, len); // graceful cleanup is_Renamed.Close(); os.Close(); } if (closeDir) { dir.Close(); } }