internal Stream OpenWrite(string virtualPath, WriteMode mode)
        {
            Action <byte[]> onClose = (data) => ConnectedClient.WriteAllBytes(virtualPath, data);

            if (mode == WriteMode.Truncate)
            {
                ConnectedClient.DeleteFile(virtualPath);
                return(new InMemory.InMemoryStream(onClose));
            }
            else if (mode == WriteMode.Overwrite)
            {
                return(new InMemory.InMemoryStream(onClose));
            }
            else
            {
                var bytes = default(byte[]);
                using (var readStream = GetStream(virtualPath))
                {
                    bytes = StreamExtensions.ReadStreamToEnd(readStream);
                }
                var stream = new InMemory.InMemoryStream(onClose, bytes);
                stream.Seek(stream.Length, System.IO.SeekOrigin.Begin);
                return(stream);
            }
        }
Exemplo n.º 2
0
        internal void DeleteFile(string path)
        {
            path = NormalizeAbsolutePath(path);
            ConnectedClient.DeleteFile(path);

            if (this.nodes.ContainsKey(path))
            {
                this.nodes.Remove(path);
            }
        }
 internal void DeleteFile(string virtualPath)
 {
     ConnectedClient.DeleteFile(virtualPath);
 }