Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
6990cdfe
Commit
6990cdfe
authored
Aug 02, 2011
by
Dan Kegel
Committed by
Alexandre Julliard
Aug 03, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd: mkdir: Set errorlevel and output error message if final directory already exists.
parent
3cd864bd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
47 deletions
+45
-47
builtins.c
programs/cmd/builtins.c
+33
-42
test_builtins.cmd
programs/cmd/tests/test_builtins.cmd
+5
-0
test_builtins.cmd.exp
programs/cmd/tests/test_builtins.cmd.exp
+7
-5
No files found.
programs/cmd/builtins.c
View file @
6990cdfe
...
@@ -473,54 +473,45 @@ void WCMD_copy (void) {
...
@@ -473,54 +473,45 @@ void WCMD_copy (void) {
/****************************************************************************
/****************************************************************************
* WCMD_create_dir
* WCMD_create_dir
*
*
* Create a directory.
* Create a directory
(and, if needed, any intermediate directories)
.
*
*
* this works recursively. so mkdir dir1\dir2\dir3 will create dir1 and dir2 if
* Modifies its argument by replacing slashes temporarily with nulls.
* they do not already exist.
*/
*/
static
BOOL
create_full_path
(
WCHAR
*
path
)
static
BOOL
create_full_path
(
WCHAR
*
path
)
{
{
int
len
;
WCHAR
*
p
,
*
start
;
WCHAR
*
new_path
;
BOOL
ret
=
TRUE
;
/* don't mess with drive letter portion of path, if any */
start
=
path
;
new_path
=
HeapAlloc
(
GetProcessHeap
(),
0
,(
strlenW
(
path
)
+
1
)
*
sizeof
(
WCHAR
));
if
(
path
[
1
]
==
':'
)
strcpyW
(
new_path
,
path
);
start
=
path
+
2
;
while
((
len
=
strlenW
(
new_path
))
&&
new_path
[
len
-
1
]
==
'\\'
)
/* Strip trailing slashes. */
new_path
[
len
-
1
]
=
0
;
for
(
p
=
path
+
strlenW
(
path
)
-
1
;
p
!=
start
&&
*
p
==
'\\'
;
p
--
)
*
p
=
0
;
while
(
!
CreateDirectoryW
(
new_path
,
NULL
))
{
/* Step through path, creating intermediate directories as needed. */
WCHAR
*
slash
;
/* First component includes drive letter, if any. */
DWORD
last_error
=
GetLastError
();
p
=
start
;
if
(
last_error
==
ERROR_ALREADY_EXISTS
)
for
(;;)
{
break
;
DWORD
rv
;
/* Skip to end of component */
if
(
last_error
!=
ERROR_PATH_NOT_FOUND
)
while
(
*
p
==
'\\'
)
p
++
;
{
while
(
*
p
&&
*
p
!=
'\\'
)
p
++
;
ret
=
FALSE
;
if
(
!*
p
)
{
break
;
/* path is now the original full path */
return
CreateDirectoryW
(
path
,
NULL
);
}
}
/* Truncate path, create intermediate directory, and restore path */
if
(
!
(
slash
=
strrchrW
(
new_path
,
'\\'
))
&&
!
(
slash
=
strrchrW
(
new_path
,
'/'
)))
*
p
=
0
;
{
rv
=
CreateDirectoryW
(
path
,
NULL
);
ret
=
FALSE
;
*
p
=
'\\'
;
break
;
if
(
!
rv
&&
GetLastError
()
!=
ERROR_ALREADY_EXISTS
)
}
return
FALSE
;
}
len
=
slash
-
new_path
;
/* notreached */
new_path
[
len
]
=
0
;
return
FALSE
;
if
(
!
create_full_path
(
new_path
))
{
ret
=
FALSE
;
break
;
}
new_path
[
len
]
=
'\\'
;
}
HeapFree
(
GetProcessHeap
(),
0
,
new_path
);
return
ret
;
}
}
void
WCMD_create_dir
(
WCHAR
*
command
)
{
void
WCMD_create_dir
(
WCHAR
*
command
)
{
...
...
programs/cmd/tests/test_builtins.cmd
View file @
6990cdfe
...
@@ -518,6 +518,11 @@ if exist foobar (echo foobar created) else echo foobar not created!
...
@@ -518,6 +518,11 @@ if exist foobar (echo foobar created) else echo foobar not created!
if exist bar\baz (echo bar\baz created) else echo bar\baz not created!
if exist bar\baz (echo bar\baz created) else echo bar\baz not created!
cd ..
cd ..
rd /s/q foobaz
rd /s/q foobaz
call :setError 0
mkdir foo\*
echo mkdir foo\* errorlevel %ErrorLevel%
if exist foo (rmdir foo & echo ok, foo created
) else ( echo bad, foo not created )
echo ----------- Testing rmdir -----------
echo ----------- Testing rmdir -----------
call :setError 0
call :setError 0
...
...
programs/cmd/tests/test_builtins.cmd.exp
View file @
6990cdfe
...
@@ -264,14 +264,14 @@ del /q * succeeded on file2.dat
...
@@ -264,14 +264,14 @@ del /q * succeeded on file2.dat
----------- Testing mkdir -----------
----------- Testing mkdir -----------
0
0
0
0
@todo_wine@
1
1
@todo_wine@
1
1
0
0
0
0
0
0
0
0
0
0
@todo_wine@
1
1
0
0
0
0
0
0
...
@@ -280,13 +280,15 @@ dir created
...
@@ -280,13 +280,15 @@ dir created
mkdir ? gives errorlevel 1
mkdir ? gives errorlevel 1
mkdir ?\foo gives errorlevel 1
mkdir ?\foo gives errorlevel 1
mkdir foo\? gives errorlevel 1
mkdir foo\? gives errorlevel 1
@todo_wine@
ok, foo created
ok, foo created
mkdir foo\bar\? gives errorlevel 1
mkdir foo\bar\? gives errorlevel 1
@todo_wine@
ok, foo\bar created
ok, foo\bar created
foo created
foo created
bar created
bar created
foobar created
foobar created
bar\baz created
bar\baz created
mkdir foo\* errorlevel 1
ok, foo created
----------- Testing rmdir -----------
----------- Testing rmdir -----------
0
0
dir removed
dir removed
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment