From 255c22e6016a06bb7c80285fdb5a032c85e6e0bb Mon Sep 17 00:00:00 2001 From: Dale Whinham Date: Fri, 11 Dec 2020 12:37:57 +0000 Subject: [PATCH] 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. --- support/minimig/minimig_share.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/support/minimig/minimig_share.cpp b/support/minimig/minimig_share.cpp index 6c974aa..954ab77 100644 --- a/support/minimig/minimig_share.cpp +++ b/support/minimig/minimig_share.cpp @@ -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;