public string fileWrite(IVirtualPathProvider vfs, string virtualPath, object contents) { if (contents is string s) { vfs.WriteFile(virtualPath, s); } else if (contents is byte[] bytes) { vfs.WriteFile(virtualPath, bytes); } else if (contents is Stream stream) { vfs.WriteFile(virtualPath, stream); } else { return(null); } return(virtualPath); }
public static void CopyFrom(this IVirtualPathProvider pathProvider, IEnumerable<IVirtualFile> srcFiles, Func<IVirtualFile, string> toPath=null) { foreach (var file in srcFiles) { using (var stream = file.OpenRead()) { var dstPath = toPath != null ? toPath(file) : file.VirtualPath; if (dstPath == null) continue; pathProvider.WriteFile(dstPath, stream); } } }
public static void CopyFrom( this IVirtualPathProvider pathProvider, IEnumerable <IVirtualFile> sourceFiles, Func <IVirtualFile, string> destinationPathSelector) { foreach (var file in sourceFiles) { using (var stream = file.OpenRead()) { var destinationPath = destinationPathSelector(file); pathProvider.WriteFile(destinationPath, stream); } } }
public static void CopyFrom(this IVirtualPathProvider pathProvider, IEnumerable <IVirtualFile> sourceFiles) { foreach (var file in sourceFiles) { using (var stream = file.OpenRead()) { var destinationPath = file.VirtualPath; if (destinationPath == null) { continue; } pathProvider.WriteFile(destinationPath, stream); } } }
public static void AddFile(this IVirtualPathProvider pathProvider, string filePath, string textContents) { pathProvider.WriteFile(filePath, textContents); }
public string writeFile(IVirtualPathProvider vfs, string virtualPath, object contents) { vfs.WriteFile(virtualPath, contents); return(virtualPath); }