(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / nant / src / Tasks / MoveTask.cs
blob2b63014ef0b109452d7cd439c038f682535ca188
1 // NAnt - A .NET build tool
2 // Copyright (C) 2001 Gerry Shaw
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // Gerry Shaw (gerry_shaw@yahoo.com)
19 // Ian MacLean (ian_maclean@another.com)
21 namespace SourceForge.NAnt {
23 using System;
24 using System.IO;
26 [TaskName("move")]
27 public class MoveTask : CopyTask {
29 /// <summary>
30 /// Actually does the file (and possibly empty directory) copies.
31 /// </summary>
32 protected override void DoFileOperations() {
33 if (FileCopyMap.Count > 0) {
35 // loop thru our file list
36 foreach (string sourcePath in FileCopyMap.Keys) {
37 string destinationPath = (string)FileCopyMap[sourcePath];
38 if (sourcePath == destinationPath) {
39 Log.WriteLine(LogPrefix + "Skipping self-move of {0}" + sourcePath);
40 continue;
43 try {
44 // check if directory exists
45 if (Directory.Exists(sourcePath)) {
46 Log.WriteLine(LogPrefix + "moving directory {0} to {1}", sourcePath, destinationPath);
47 Directory.Move(sourcePath, destinationPath);
49 else {
51 DirectoryInfo todir = new DirectoryInfo(destinationPath);
52 if ( !todir.Exists ) {
53 Directory.CreateDirectory( Path.GetDirectoryName(destinationPath) );
56 Log.WriteLine(LogPrefix + "Moving {0} to {1}", sourcePath, destinationPath);
57 // IM look into how Ant does this for directories
58 File.Move(sourcePath, destinationPath);
61 } catch (IOException ioe) {
62 string msg = String.Format("Failed to move {0} to {1}\n{2}", sourcePath, destinationPath, ioe.Message);
63 throw new BuildException(msg, Location);