public void Set(Stream source) { _bfs.Lock(); try { int handle = Handle; using (Stream target = _bfs.RewriteFile(handle).BaseStream) { SetStream(source, target); } _bfs.Flush(); } finally { _bfs.UnLock(); } }
public override void Close() { if (_dirty) { _bfs.Lock(); int handle = _handle; try { using (Stream stream = _bfs.RewriteFile(handle).BaseStream) { WriteTo(stream); } _bfs.Flush(); } finally { _bfs.UnLock(); } } base.Close(); }
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; }