diff --git a/src/sbbs3/main.cpp b/src/sbbs3/main.cpp index 753592543a0905f22b34fe70a023b0e18f76e0cc..b9f8bf16fda6e72f893173179c3f5ee7df1c7371 100644 --- a/src/sbbs3/main.cpp +++ b/src/sbbs3/main.cpp @@ -3934,33 +3934,27 @@ void sbbs_t::spymsg(const char* msg) /* both 'src' and 'dest' must contain full path and filename */ /* returns 0 if successful, -1 if error */ /****************************************************************************/ -int sbbs_t::mv(char *src, char *dest, char copy) +int sbbs_t::mv(const char* path, const char* dest, bool copy) { + char src[MAX_PATH + 1]; + if(!stricmp(src,dest)) /* source and destination are the same! */ return(0); + + SAFECOPY(src, path); if(!fexistcase(src)) { bprintf("\r\n\7MV ERROR: Source doesn't exist\r\n'%s'\r\n" ,src); return(-1); } - if(!copy && fexistcase(dest)) { + if(!copy && fexist(dest)) { bprintf("\r\n\7MV ERROR: Destination already exists\r\n'%s'\r\n" ,dest); return(-1); } - if(!copy -#ifndef __unix__ /* need to determine if on same mount device */ - && ((src[1]!=':' && dest[1]!=':') || (src[1]==':' && dest[1]==':' && toupper(src[0])==toupper(dest[0]))) -#endif - ) { - if(rename(src,dest)) { /* same drive, so move */ - bprintf("\r\nMV ERROR: Error renaming '%s'" - "\r\n to '%s'\r\n\7",src,dest); - return(-1); - } - return(0); - } - if(!CopyFile(src, dest, /* fail if exists: */true)) { + if(!copy && rename(src, dest) == 0) + return 0; + if(!CopyFile(src, dest, /* fail if exists: */!copy)) { errormsg(WHERE, "CopyFile", src, 0, dest); return -1; } diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h index e17a30bf283d16f69c291f96f671514c2baaffb1..fb41ac2217c92e9e6b535c75f3fe50ea5e37ec44 100644 --- a/src/sbbs3/sbbs.h +++ b/src/sbbs3/sbbs.h @@ -1006,7 +1006,7 @@ public: ulong logonstats(void); void logoffstats(void); int nopen(char *str, int access); - int mv(char *src, char *dest, char copy); /* fast file move/copy function */ + int mv(const char *src, const char *dest, bool copy); /* fast file move/copy function */ bool chksyspass(const char* sys_pw = NULL); bool chk_ar(const uchar * str, user_t* user, client_t* client); /* checks access requirements */ bool ar_exp(const uchar ** ptrptr, user_t*, client_t*);