public void Delete() { int handle = Handle; if (handle > 0) { _bfs.Lock(); try { _bfs.DeleteFile(handle); } finally { _bfs.UnLock(); } } else { IOTools.DeleteFile(GetFileName()); } }
internal BLOB(Table table, Stream source) { _table = table; _bfs = table.Database.BlobFS; int handle; _bfs.Lock(); try { Stream stream = _bfs.AllocFile(out handle).BaseStream; _id = handle.ToString(); SetStream(source, stream); } 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; }