I agree with putting it in. I'm not a big fan of the filesystem enforcing policy like this. We need to be consistent across all of our file-based tasks, however (I posted a change earlier that would give the same results for the <copy> task).

Should we change it so that this behaviour is by default? We can always provide the force="no" option to handle this the old way.

Sansone, Aaron wrote:

Matthew,

This has not been committed yet.  I'm of the mind now that this is just a lazy
mans attrib task.  One can very easily just call an attrib before this task to
insure that it is not read only.  However, if no one is opposed to this change,
I say put it in.

I'd really like to see my changes to the resgen task reviewed.  The resgen task
changes allow you to take a fileset of resx files for resource file creation.  I
think this is more useful than the delete changes.

For the Resgen task cvs diff, see the archived message:

Date: Wed, 5 Feb 2003 14:55:23 -0600 Subject: [nant-dev] Changes...

-Aaron

-----Original Message-----
From: Matthew Mastracci [mailto:[EMAIL PROTECTED]
Sent: Monday, March 03, 2003 3:53 PM
To: Sansone, Aaron
Cc: Nant-Developers (E-mail)
Subject: Re: [nant-dev] Changes to DeleteTask...


Has anyone reviewed, commented or commit this patch yet? Any objections to this?


Sansone, Aaron wrote:



All,

I've made a change to the DeleteTask that I would like to have
reviewed/committed if you all agree with the change.

This issue I ran into was forcing a delete even if the file is read only.  I
added a parameter "force" that will allow this.  I also added code that would
recurse a directory and "force" the deletion of a directory even if some of the
files in the directory are read only.

Let me know what you all think of this.

Thanks,

Aaron

--- DeleteTask.cs       Fri Jan 17 23:56:22 2003
+++ .\Original\DeleteTask.cs    Wed Feb 05 20:36:33 2003
@@ -19,7 +19,7 @@

using System;
using System.IO;
-using System.Collections;
+
using SourceForge.NAnt.Attributes;

namespace SourceForge.NAnt.Tasks {
@@ -51,8 +51,7 @@
public class DeleteTask : Task {
string _file = null; - string _dir = null;
- bool _force = false;
+ string _dir = null; FileSet _fileset = new FileSet();


/// <summary>The file to delete.</summary>
@@ -61,15 +60,6 @@
get { return _file; }
set {_file = value; }
}
-
- /// <summary>Delete files even if read only.</summary>
- [TaskAttribute("force")]
- [BooleanValidator()]
- public bool ForceDelete
- {
- get { return _force; }
- set {_force = value; }
- }
/// <summary>The directory to delete.</summary>
[TaskAttribute("dir")]
@@ -130,14 +120,7 @@
}


                   Log.WriteLine(LogPrefix + "Deleting directory {0}", path);
-                                       if( ForceDelete )
-                                       {
-                                               foreach(string file in
getRecursiveFileList(path) )
-                                               {
-                                                       File.SetAttributes(file,
FileAttributes.Normal);
-                                               }
-                                       }
-                                       Directory.Delete(path, true);
+                    Directory.Delete(path, true);
               } else {
                   throw new DirectoryNotFoundException();
               }
@@ -149,33 +132,10 @@
           }
       }

- private ArrayList getRecursiveFileList(string path)
- {
- ArrayList files = new ArrayList();
-
- string[] dirs = Directory.GetDirectories(path);
-
- foreach (string dir in dirs) - {
- files.AddRange( getRecursiveFileList(dir) );
- }
-
- if( ! path.Equals(".") )
- {
- files.AddRange(Directory.GetFiles(path));
- }
-
- return files;
- }
-
void DeleteFile(string path, bool verbose) {
try {
if (File.Exists(path)) {
Log.WriteLineIf(verbose, LogPrefix + "Deleting file {0}",
path);
- if( ForceDelete )
- {
- File.SetAttributes(path,
FileAttributes.Normal);
- }
File.Delete(path);
} else {
throw new FileNotFoundException();







-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com
_______________________________________________
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers








-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com
_______________________________________________
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to