/// <summary> /// Copies existing files to a new location. /// </summary> /// <param name="env">The context.</param> /// <param name="filePaths">The file paths.</param> /// <param name="targetDirectoryPath">The target directory path.</param> /// <example> /// <code> /// CreateDirectory("destination"); /// var files = new [] { /// "Cake.exe", /// "Cake.pdb" /// }; /// CopyFiles(files, "destination"); /// </code> /// </example> /// <exception cref="ArgumentNullException"><paramref name="env"/> or <paramref name="filePaths"/> /// or <paramref name="targetDirectoryPath"/> is <see langword="null"/></exception> /// <exception cref="InvalidOperationException">The target directory does not exist.</exception> /// <exception cref="FileNotFoundException">The file does not exist.</exception> public static void CopyFiles(this IFileSystemEnvironment env, IEnumerable <string> filePaths, DirectoryPath targetDirectoryPath) { if (filePaths == null) { throw new ArgumentNullException(nameof(filePaths)); } var paths = filePaths.Select(p => new FilePath(p)); FileCopier.CopyFiles(env, paths, targetDirectoryPath); }
/// <summary> /// Copies all files matching the provided pattern to a new location. /// </summary> /// <param name="env">The context.</param> /// <param name="pattern">The pattern.</param> /// <param name="targetDirectoryPath">The target directory path.</param> /// <example> /// <code> /// CopyFiles("Cake.*", "./publish"); /// </code> /// </example> /// <exception cref="ArgumentNullException"><paramref name="env"/> or <paramref name="pattern"/> /// or <paramref name="targetDirectoryPath"/> is <see langword="null"/></exception> /// <exception cref="FileNotFoundException">The file does not exist.</exception> /// <exception cref="InvalidOperationException">The target directory does not exist.</exception> public static void CopyFiles(this IFileSystemEnvironment env, string pattern, DirectoryPath targetDirectoryPath) { FileCopier.CopyFiles(env, pattern, targetDirectoryPath); }
/// <summary> /// Copies an existing file to a new file, providing the option to specify a new file name. /// </summary> /// <param name="env">The context.</param> /// <param name="filePath">The file path.</param> /// <param name="targetFilePath">The target file path.</param> /// <example> /// <code> /// CopyFile("test.tmp", "test.txt"); /// </code> /// </example> /// <exception cref="ArgumentNullException"><paramref name="env"/> or <paramref name="filePath"/> /// or <paramref name="targetFilePath"/> is <see langword="null"/></exception> /// <exception cref="FileNotFoundException">The file does not exist.</exception> /// <exception cref="InvalidOperationException">The target directory does not exist.</exception> public static void CopyFile(this IFileSystemEnvironment env, FilePath filePath, FilePath targetFilePath) { FileCopier.CopyFile(env, filePath, targetFilePath); }
/// <summary> /// Copies an existing file to a new location. /// </summary> /// <param name="env">The context.</param> /// <param name="filePath">The file path.</param> /// <param name="targetDirectoryPath">The target directory path.</param> /// <example> /// <code> /// CopyFileToDirectory("test.txt", "./targetdir"); /// </code> /// </example> /// <exception cref="ArgumentNullException"><paramref name="env"/> or <paramref name="filePath"/> /// or <paramref name="targetDirectoryPath"/> is <see langword="null"/></exception> /// <exception cref="FileNotFoundException">The file does not exist.</exception> /// <exception cref="InvalidOperationException">The target directory does not exist.</exception> public static void CopyFileToDirectory(this IFileSystemEnvironment env, FilePath filePath, DirectoryPath targetDirectoryPath) { FileCopier.CopyFileToDirectory(env, filePath, targetDirectoryPath); }
/// <summary> /// Copies existing files to a new location. /// </summary> /// <param name="env">The context.</param> /// <param name="filePaths">The file paths.</param> /// <param name="targetDirectoryPath">The target directory path.</param> /// <example> /// <code> /// var files = GetFiles("./**/Cake.*"); /// CopyFiles(files, "destination"); /// </code> /// </example> /// <exception cref="ArgumentNullException"><paramref name="env"/> or <paramref name="filePaths"/> /// or <paramref name="targetDirectoryPath"/> is <see langword="null"/></exception> /// <exception cref="FileNotFoundException">The file does not exist.</exception> /// <exception cref="InvalidOperationException">The target directory does not exist.</exception> public static void CopyFiles(this IFileSystemEnvironment env, IEnumerable <FilePath> filePaths, DirectoryPath targetDirectoryPath) { FileCopier.CopyFiles(env, filePaths, targetDirectoryPath); }