Beispiel #1
0
        void IFileSystem.CreateDirectory(string path)
        {
            var fixedPath = FixPath(path);

            if (BlacklistedPaths.Contains(fixedPath))
            {
                BlacklistedPaths.Remove(fixedPath);
            }

            if (!(this as IFileSystem).DirectoryExists(fixedPath))
            {
                CurrentFileSystem?.CreateDirectory(GetVirtualPath(fixedPath));
            }
        }
Beispiel #2
0
        Stream IFileSystem.OpenFileWriteOnly(string filename)
        {
            if (CurrentFileSystem != null)
            {
                throw new NotSupportedException("Cannot open a file as a stream without an IO provider.");
            }

            var virtualPath = GetVirtualPath(filename);

            if (!CurrentFileSystem.DirectoryExists(virtualPath))
            {
                CurrentFileSystem.CreateDirectory(virtualPath);
            }
            CurrentFileSystem.WriteAllBytes(virtualPath, (this as IFileSystem).ReadAllBytes(filename));

            return(CurrentFileSystem.OpenFileWriteOnly(filename));
        }