diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1998-07-10 20:46:12 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-07-10 20:46:12 +0000 |
commit | e24c7c18173514bd97dba167341e7465f92d5ef7 (patch) | |
tree | 232db464e5b81b8ac10091149ffb885bc83201bc /win32/perlhost.h | |
parent | ac9fe1c23eac5f442f32542eeea699c9f084bf60 (diff) | |
download | perl-e24c7c18173514bd97dba167341e7465f92d5ef7.tar.gz |
add win32_rename() that does what docs say
p4raw-id: //depot/perl@1403
Diffstat (limited to 'win32/perlhost.h')
-rw-r--r-- | win32/perlhost.h | 49 |
1 files changed, 1 insertions, 48 deletions
diff --git a/win32/perlhost.h b/win32/perlhost.h index 10abef93dc..b8a59e409c 100644 --- a/win32/perlhost.h +++ b/win32/perlhost.h @@ -402,54 +402,7 @@ public: }; virtual int Rename(const char *OldFileName, const char *newname, int &err) { - char szNewWorkName[MAX_PATH+1]; - WIN32_FIND_DATA fdOldFile, fdNewFile; - HANDLE handle; - char *ptr; - - if((strchr(OldFileName, '\\') || strchr(OldFileName, '/')) - && strchr(newname, '\\') == NULL - && strchr(newname, '/') == NULL) - { - strcpy(szNewWorkName, OldFileName); - if((ptr = strrchr(szNewWorkName, '\\')) == NULL) - ptr = strrchr(szNewWorkName, '/'); - strcpy(++ptr, newname); - } - else - strcpy(szNewWorkName, newname); - - if(stricmp(OldFileName, szNewWorkName) != 0) - { // check that we're not being fooled by relative paths - // and only delete the new file - // 1) if it exists - // 2) it is not the same file as the old file - // 3) old file exist - // GetFullPathName does not return the long file name on some systems - handle = FindFirstFile(OldFileName, &fdOldFile); - if(handle != INVALID_HANDLE_VALUE) - { - FindClose(handle); - - handle = FindFirstFile(szNewWorkName, &fdNewFile); - - if(handle != INVALID_HANDLE_VALUE) - FindClose(handle); - else - fdNewFile.cFileName[0] = '\0'; - - if(strcmp(fdOldFile.cAlternateFileName, fdNewFile.cAlternateFileName) != 0 - && strcmp(fdOldFile.cFileName, fdNewFile.cFileName) != 0) - { // file exists and not same file - DeleteFile(szNewWorkName); - } - } - } - int ret = rename(OldFileName, szNewWorkName); - if(ret) - err = errno; - - return ret; + CALLFUNCRET(win32_rename(OldFileName, newname)) }; virtual int Setmode(int handle, int mode, int &err) { |