public BlobFSMemoryStream(int handle, BlobFileSystem bfs) : base(1024) { _handle = handle; _bfs = bfs; bfs.Lock(); try { CopyStream(this, bfs.GetRawStream(handle), bfs.GetRawBytes()); } catch { SetLength(0); bfs.RewriteFile(handle); bfs.Flush(); } finally { bfs.UnLock(); } base.Position = 0; _dirty = false; }
public override string ToString() { int handle = Handle; if (handle == 0) { return(Utils.StreamToString(File.Open(GetFileName(), FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))); } _bfs.Lock(); try { return(Utils.StreamToString(_bfs.GetRawStream(handle))); } catch { _bfs.RewriteFile(handle); _bfs.Flush(); return(string.Empty); } finally { _bfs.UnLock(); } }