Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, for more info) to build successfully.

Commit 80422644 authored by Rob Swindell's avatar Rob Swindell 💬

mv() simplified for the non-copy case

Constified function arguments. Source path is still case-insensitive, but destination is case-sensitive (hopefully that's not an issue).

When a "move" (!copy) is requested, a rename() is always attempted first and if successful, job done. Otherwise, we continue on with the file-copy (and then remove).

This should resolve CID 332219 (DEADCODE).
parent 0c5c140e
......@@ -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! */
SAFECOPY(src, path);
if(!fexistcase(src)) {
bprintf("\r\n\7MV ERROR: Source doesn't exist\r\n'%s'\r\n"
if(!copy && fexistcase(dest)) {
if(!copy && fexist(dest)) {
bprintf("\r\n\7MV ERROR: Destination already exists\r\n'%s'\r\n"
#ifndef __unix__ /* need to determine if on same mount device */
&& ((src[1]!=':' && dest[1]!=':') || (src[1]==':' && dest[1]==':' && toupper(src[0])==toupper(dest[0])))
) {
if(rename(src,dest)) { /* same drive, so move */
bprintf("\r\nMV ERROR: Error renaming '%s'"
"\r\n to '%s'\r\n\7",src,dest);
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;
......@@ -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*);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment