using System; using System.IO; using RamDavisk.Ramfs.Inters; using WebDAVSharp.Server.Stores; namespace RamDavisk.Ramfs { internal class WebDavRamfsStoreDocument : WebDavRamfsStoreItem, IWebDavStoreDocument { private readonly MemoryStream _buf; public WebDavRamfsStoreDocument() { _buf = new MemoryStream(); } public Stream OpenReadStream() => new StreamWrap(_buf); public Stream OpenWriteStream(bool append) { try { var s = new StreamWrap(_buf); if (append) s.Position = _buf.Position; return s; } finally { ModificationDate = DateTime.Now; } } public override long Size => _buf.Length; public override string Etag => ModificationDate.GetHashCode().ToString(); public override bool IsCollection => false; public override void Dispose() { _buf.Dispose(); GC.Collect(); } } }