/// <summary> /// Creates a zip archive from one file /// </summary> /// <param name="C">The context</param> /// <param name="Flow">The source/target</param> public static Option <Link <FilePath> > ZipFile(this IApplicationContext C, Link <FilePath> Flow) { var cmd = CreateFileArchive.DefineZipFileCommand(Flow.Source, Flow.Target); var result = C.CPS().ExecuteCommand(cmd); return(result.IsSome ? some(Flow) : none <Link <FilePath> >(result.Message)); }
/// <summary> /// Creates a zip archive from one file /// </summary> /// <param name="C">The context</param> /// <param name="SrcFile">Path to the file that will be archived</param> /// <param name="DstFile">Path to which the archive will be written</param> public static Option <Link <FilePath> > ZipFile(this IApplicationContext C, FilePath SrcFile, FilePath DstFile) { var cmd = CreateFileArchive.DefineZipFileCommand(SrcFile, DstFile); var result = C.CPS().ExecuteCommand(cmd); return(result.IsSome ? some(new Link <FilePath>(SrcFile, DstFile)) : none <Link <FilePath> >(result.Message)); }
/// <summary> /// Creates a zip archive from the contents of a Folder /// </summary> /// <param name="C">The context</param> /// <param name="SrcFolder">Path to the folder that will be archived</param> /// <param name="DstFile">Path to which the archive will be written</param> public static Option <FilePath> ZipDir(this IApplicationContext C, FolderPath SrcFolder, FilePath DstFile) { var command = CreateFileArchive.DefineZipDirCommand(SrcFolder, DstFile); var result = C.CPS().Execute(command); return(result.IsNone() ? result.ToNone <FilePath>() : new Option <FilePath>(DstFile, ArchivedFolder(SrcFolder, DstFile))); }
/// <summary> /// Convenience method for creating <see cref="CreateFileArchive"/> commands /// </summary> /// <param name="SrcFolder"></param> /// <param name="DstFolder"></param> public static IEnumerable <CreateFileArchive> CreateFileArchiveCommands (this FolderPath SrcFolder, FolderPath DstFolder) => CreateFileArchive.DefineZipFilesCommands(SrcFolder, DstFolder);