minimig: Don't return failure if renaming to self

Renaming a file or directory to its own name is legal under AmigaOS, so
ensure that this case is a no-op and returns success.

This fixes the error encountered when creating a new drawer under SHARE:
and accepting the default name of "Unnamed1", for example.
This commit is contained in:
Dale Whinham
2020-12-11 12:37:57 +00:00
parent 3861158c39
commit 255c22e601

View File

@@ -694,6 +694,16 @@ static int process_request(void *reqres_buffer)
ret = ERROR_OBJECT_NOT_FOUND;
break;
}
strcpy(buf, getFullPath(buf));
const char *fp2 = getFullPath(cp2);
// Identical match; do nothing
if (!strcmp(buf, fp2))
{
ret = 0;
break;
}
if (FileExists(cp2, 0) || PathIsDir(cp2, 0))
{
@@ -701,8 +711,7 @@ static int process_request(void *reqres_buffer)
break;
}
strcpy(buf, getFullPath(buf));
if (rename(buf, getFullPath(cp2)))
if (rename(buf, fp2))
{
ret = ERROR_OBJECT_NOT_FOUND;
break;