Dan Kegel : cmd: del /a: test deleting readonly files, with fix.

Alexandre Julliard julliard at winehq.org
Tue May 24 12:53:50 CDT 2011


Module: wine
Branch: master
Commit: ff1e7038b2755161d3931b019ad6f6af23970d1b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ff1e7038b2755161d3931b019ad6f6af23970d1b

Author: Dan Kegel <dank at kegel.com>
Date:   Sun May 22 08:27:38 2011 -0700

cmd: del /a: test deleting readonly files, with fix.

---

 programs/cmd/builtins.c                  |    5 +++--
 programs/cmd/tests/test_builtins.cmd     |   16 ++++++++++++++++
 programs/cmd/tests/test_builtins.cmd.exp |    4 ++++
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 7a6ae72..c8baef1 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -712,9 +712,10 @@ BOOL WCMD_delete (WCHAR *command, BOOL expectDir) {
               /* Only proceed if ok to */
               if (ok) {
 
-                /* If file is read only, and /F supplied, delete it */
+                /* If file is read only, and /A:r or /F supplied, delete it */
                 if (fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY &&
-                    strstrW (quals, parmF) != NULL) {
+                    ((wanted_attrs & FILE_ATTRIBUTE_READONLY) ||
+                    strstrW (quals, parmF) != NULL)) {
                     SetFileAttributesW(fpath, fd.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY);
                 }
 
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index 2b117e4..62dbc6c 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -78,6 +78,22 @@ if /i not foo==FOO echo if /i seems to be broken
 if /I foo==FOO echo if /I seems to work
 if /I not foo==FOO echo if /I seems to be broken
 
+echo -----------Testing del /a-----------
+del /f/q *.test > nul
+echo r > r.test
+attrib +r r.test
+echo not-r > not-r.test
+
+if not exist not-r.test echo not-r.test not found before delete, bad
+del /a:-r *.test
+if not exist not-r.test echo not-r.test not found after delete, good
+
+if not exist r.test echo r.test not found before delete, bad
+if exist r.test echo r.test found before delete, good
+del /a:r *.test
+if not exist r.test echo r.test not found after delete, good
+if exist r.test echo r.test found after delete, bad
+
 echo -----------Testing GOTO-----------
 if a==a goto dest1
 :dest1
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index e4644d3..0dcd926 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -78,6 +78,10 @@ Testing case sensitivity with and without /i option
 if seems to default to case sensitivity
 if /i seems to work
 if /I seems to work
+-----------Testing del /a-----------
+not-r.test not found after delete, good
+r.test found before delete, good
+r.test not found after delete, good
 -----------Testing GOTO-----------
 goto with no leading space worked
 goto with a leading space worked




More information about the wine-cvs mailing list