SCP: Cleanup path argument to MKDIR command
Also allow making a directory that already exists to return successfully with a message. The message can be suppressed with the -Q switch.
This commit is contained in:
parent
26128800ee
commit
e5f9a7dca8
1 changed files with 6 additions and 0 deletions
6
scp.c
6
scp.c
|
@ -6612,6 +6612,12 @@ if ((!cptr) || (*cptr == '\0'))
|
|||
strlcpy (path, cptr, sizeof (path));
|
||||
while ((c = strchr (path, '\\')))
|
||||
*c = '/';
|
||||
if (path[strlen (path) - 1] == '/') /* trim any trailing / from the path */
|
||||
path[strlen (path) - 1] = '\0';
|
||||
while ((c = strstr (path, "//")))
|
||||
memmove (c, c + 1, strlen (c + 1) + 1); /* clean out any empty directories // */
|
||||
if ((!stat (path, &filestat)) && (filestat.st_mode & S_IFDIR))
|
||||
return sim_messagef (SCPE_OK, "directory %s already exists\n", path);
|
||||
c = path;
|
||||
while ((c = strchr (c, '/'))) {
|
||||
*c = '\0';
|
||||
|
|
Loading…
Add table
Reference in a new issue