Example #1
0
        public override Stream GetStream(string path, FileMode mode, FileAccess access, long startPosition)
        {
            var fake = _tree.Find(path);

            if (fake == null)
            {
                if (access == FileAccess.Write)
                {
                    var parts = path.Split(new[] { Slash }, StringSplitOptions.RemoveEmptyEntries);
                    fake      = C.Fake <FileSystemItem>();
                    fake.Path = fake.FullPath = path;
                    fake.Type = ItemType.File;
                    fake.Name = parts.Last();
                    _tree.Insert(path, fake);
                }
                else
                {
                    throw new Exception();
                }
            }

            var ms = new TreeItemStream(fake);

            ms.Seek(startPosition, SeekOrigin.Begin);
            return(ms);
        }
Example #2
0
        public override Stream GetStream(string path, FileMode mode, FileAccess access, long startPosition)
        {
            var fake = _tree.Find(path);
            if (fake == null)
            {
                if (access == FileAccess.Write)
                {
                    var parts = path.Split(new[] {Slash}, StringSplitOptions.RemoveEmptyEntries);
                    fake = C.Fake<FileSystemItem>();
                    fake.Path = fake.FullPath = path;
                    fake.Type = ItemType.File;
                    fake.Name = parts.Last();
                    _tree.Insert(path, fake);
                }
                else
                {
                    throw new Exception();
                }
            }

            var ms = new TreeItemStream(fake);
            ms.Seek(startPosition, SeekOrigin.Begin);
            return ms;
        }