CopyFiles Class

Summary

Copies the content of files from one path on to another path.
Assembly
Wyam.Core.dll
Namespace
Wyam.Core.Modules.IO
Interfaces
Base Types
  • Object
graph BT Type-->Base0["Object"] Type-.->Interface0["IModule"] click Interface0 "/api/Wyam.Common.Modules/IModule" Type-.->Interface1["IAsNewDocuments"] click Interface1 "/api/Wyam.Common.Modules/IAsNewDocuments" Type["CopyFiles"] class Type type-node

Syntax

public class CopyFiles : IModule, IAsNewDocuments

Remarks

For each output document, several metadata values are set with information about the file. By default, files are copied from the input folder (or a subfolder) to the same relative location in the output folder, but this doesn't have to be the case. The output of this module are documents with metadata representing the files copied by the module. Note that the input documents are not output by this module.

Constructors

Name Summary
CopyFiles(DocumentConfig) Copies all files that match the specified globbing patterns and/or absolute paths. This allows you to specify different patterns and/or paths depending on the input document. When this constructor is used, the module is evaluated once for every input document, which may result in copying the same file more than once (and may also result in IO conflicts since copying is typically done in parallel). It is recommended you only specify a function-based source path if there will be no overlap between the path returned from each input document.
CopyFiles(string[]) Copies all files that match the specified globbing patterns and/or absolute paths. When this constructor is used, the module is evaluated only once against empty input document. This makes it possible to string multiple CopyFiles modules together in one pipeline. Keep in mind that the result of the whole pipeline in this case will be documents representing the files copied only by the last CopyFiles module in the pipeline (since the output documents of the previous CopyFiles modules will have been consumed by the last one).

Methods

Name Value Summary
Execute(IReadOnlyList<IDocument>, IExecutionContext) IEnumerable<IDocument>
This should not be called directly, instead call IExecutionContext.Execute() if you need to execute a module from within another module.
To(Func<IFile, FilePath>) CopyFiles
Specifies an alternate destination path for each file (by default files are copied to their same relative path in the output directory). The output of the function should be the full file path (including file name) of the destination file. If the delegate returns null for a particular file, that file will not be copied.
To(Func<IFile, IFile, FilePath>) CopyFiles
Specifies an alternate destination path for each file (by default files are copied to their same relative path in the output directory). The output of the function should be the full file path (including file name) of the destination file. If the delegate returns null for a particular file, that file will not be copied. This overload allows you to view the Wyam.Common.IO.IFile where the module would normally have copied the file to and then manipulate it (or not) as appropriate.
Where(Func<IFile, bool>) CopyFiles
Specifies a predicate that must be satisfied for the file to be copied.
GitHub