Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olivier F. R. Dierick
wine
Commits
3ccfbaef
Commit
3ccfbaef
authored
13 years ago
by
Dan Kegel
Committed by
Alexandre Julliard
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
cmd: WCMD_delete: move "Delete *.* ?" processing into WCMD_delete_confirm_wildcard.
parent
51c7ab08
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
programs/cmd/builtins.c
+45
-32
45 additions, 32 deletions
programs/cmd/builtins.c
programs/cmd/tests/test_builtins.cmd
+12
-0
12 additions, 0 deletions
programs/cmd/tests/test_builtins.cmd
programs/cmd/tests/test_builtins.cmd.exp
+3
-0
3 additions, 0 deletions
programs/cmd/tests/test_builtins.cmd.exp
with
60 additions
and
32 deletions
programs/cmd/builtins.c
+
45
−
32
View file @
3ccfbaef
...
...
@@ -579,6 +579,48 @@ static void WCMD_delete_parse_attributes(DWORD *wantSet, DWORD *wantClear) {
}
}
/* If filename part of parameter is * or *.*,
* and neither /Q nor /P options were given,
* prompt the user whether to proceed.
* Returns FALSE if user says no, TRUE otherwise.
* *pPrompted is set to TRUE if the user is prompted.
* (If /P supplied, del will prompt for individual files later.)
*/
static
BOOL
WCMD_delete_confirm_wildcard
(
WCHAR
*
filename
,
BOOL
*
pPrompted
)
{
static
const
WCHAR
parmP
[]
=
{
'/'
,
'P'
,
'\0'
};
static
const
WCHAR
parmQ
[]
=
{
'/'
,
'Q'
,
'\0'
};
if
((
strstrW
(
quals
,
parmQ
)
==
NULL
)
&&
(
strstrW
(
quals
,
parmP
)
==
NULL
))
{
static
const
WCHAR
anyExt
[]
=
{
'.'
,
'*'
,
'\0'
};
WCHAR
drive
[
10
];
WCHAR
dir
[
MAX_PATH
];
WCHAR
fname
[
MAX_PATH
];
WCHAR
ext
[
MAX_PATH
];
WCHAR
fpath
[
MAX_PATH
];
/* Convert path into actual directory spec */
GetFullPathNameW
(
filename
,
sizeof
(
fpath
)
/
sizeof
(
WCHAR
),
fpath
,
NULL
);
WCMD_splitpath
(
fpath
,
drive
,
dir
,
fname
,
ext
);
/* Only prompt for * and *.*, not *a, a*, *.a* etc */
if
((
strcmpW
(
fname
,
starW
)
==
0
)
&&
(
*
ext
==
0x00
||
(
strcmpW
(
ext
,
anyExt
)
==
0
)))
{
WCHAR
question
[
MAXSTRING
];
static
const
WCHAR
fmt
[]
=
{
'%'
,
's'
,
' '
,
'\0'
};
/* Caller uses this to suppress "file not found" warning later */
*
pPrompted
=
TRUE
;
/* Ask for confirmation */
wsprintfW
(
question
,
fmt
,
fpath
);
return
WCMD_ask_confirm
(
question
,
TRUE
,
NULL
);
}
}
/* No scary wildcard, or question suppressed, so it's ok to delete the file(s) */
return
TRUE
;
}
/****************************************************************************
* WCMD_delete
*
...
...
@@ -598,7 +640,6 @@ BOOL WCMD_delete (WCHAR *command, BOOL expectDir) {
int
argsProcessed
=
0
;
WCHAR
*
argN
=
command
;
BOOL
foundAny
=
FALSE
;
static
const
WCHAR
parmQ
[]
=
{
'/'
,
'Q'
,
'\0'
};
static
const
WCHAR
parmP
[]
=
{
'/'
,
'P'
,
'\0'
};
static
const
WCHAR
parmS
[]
=
{
'/'
,
'S'
,
'\0'
};
static
const
WCHAR
parmF
[]
=
{
'/'
,
'F'
,
'\0'
};
...
...
@@ -623,43 +664,15 @@ BOOL WCMD_delete (WCHAR *command, BOOL expectDir) {
WCHAR
*
p
;
BOOL
handleParm
=
TRUE
;
BOOL
found
=
FALSE
;
static
const
WCHAR
anyExt
[]
=
{
'.'
,
'*'
,
'\0'
};
strcpyW
(
argCopy
,
thisArg
);
WINE_TRACE
(
"del: Processing arg %s (quals:%s)
\n
"
,
wine_dbgstr_w
(
argCopy
),
wine_dbgstr_w
(
quals
));
argsProcessed
++
;
/* If filename part of parameter is * or *.*, prompt unless
/Q supplied. */
if
((
strstrW
(
quals
,
parmQ
)
==
NULL
)
&&
(
strstrW
(
quals
,
parmP
)
==
NULL
))
{
WCHAR
drive
[
10
];
WCHAR
dir
[
MAX_PATH
];
WCHAR
fname
[
MAX_PATH
];
WCHAR
ext
[
MAX_PATH
];
/* Convert path into actual directory spec */
GetFullPathNameW
(
argCopy
,
sizeof
(
fpath
)
/
sizeof
(
WCHAR
),
fpath
,
NULL
);
WCMD_splitpath
(
fpath
,
drive
,
dir
,
fname
,
ext
);
/* Only prompt for * and *.*, not *a, a*, *.a* etc */
if
((
strcmpW
(
fname
,
starW
)
==
0
)
&&
(
*
ext
==
0x00
||
(
strcmpW
(
ext
,
anyExt
)
==
0
)))
{
BOOL
ok
;
WCHAR
question
[
MAXSTRING
];
static
const
WCHAR
fmt
[]
=
{
'%'
,
's'
,
' '
,
'\0'
};
/* Note: Flag as found, to avoid file not found message */
found
=
TRUE
;
/* Ask for confirmation */
wsprintfW
(
question
,
fmt
,
fpath
);
ok
=
WCMD_ask_confirm
(
question
,
TRUE
,
NULL
);
/* Abort if answer is 'N' */
if
(
!
ok
)
continue
;
}
if
(
!
WCMD_delete_confirm_wildcard
(
argCopy
,
&
found
))
{
/* Skip this arg if user declines to delete *.* */
continue
;
}
/* First, try to delete in the current directory */
...
...
This diff is collapsed.
Click to expand it.
programs/cmd/tests/test_builtins.cmd
+
12
−
0
View file @
3ccfbaef
...
...
@@ -94,6 +94,18 @@ 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 del /q --------------
mkdir del_q_dir
cd del_q_dir
echo abc > file1
echo abc > file2.dat
rem If /q doesn'
t
work
,
cmd
will
prompt
and
the
test
case
should
hang
del
/q
*
>
nul
for
%%a
in
(
1
2
.dat
)
do
if
exist
file
%%a
echo
del
/q
*
failed
on
file
%%a
for
%%a
in
(
1
2
.dat
)
do
if
not
exist
file
%%a
echo
del
/q
*
succeeded
on
file
%%a
cd
..
rmdir
del_q_dir
echo
---------
--Testing
Errorlevel
-----------
rem nt 4.0 doesn't really support a way of setting errorlevel, so this is weak
rem See http://www.robvanderwoude.com/exit.php
...
...
This diff is collapsed.
Click to expand it.
programs/cmd/tests/test_builtins.cmd.exp
+
3
−
0
View file @
3ccfbaef
...
...
@@ -82,6 +82,9 @@ if /I seems to work
not-r.test not found after delete, good
r.test found before delete, good
r.test not found after delete, good
------------ Testing del /q --------------
del /q * succeeded on file1
del /q * succeeded on file2.dat
-----------Testing Errorlevel-----------
1
errorlevel just right, good
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment