Skip to content
Snippets Groups Projects
Commit 4c912de9 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Have movefile() leave the original file with the delete attribute

This has the effect of the file being listed as absent/deleted in the listing that's in memory. As requested by Phil, plt via irc.

Moving a file after this change did result in a crash once, but I couldn't reproduce it with a debugger attached.
parent a40cda0c
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #2263 failed
...@@ -243,15 +243,15 @@ bool sbbs_t::removefile(smb_t* smb, file_t* f) ...@@ -243,15 +243,15 @@ bool sbbs_t::removefile(smb_t* smb, file_t* f)
/****************************************************************************/ /****************************************************************************/
bool sbbs_t::movefile(smb_t* smb, file_t* f, int newdir) bool sbbs_t::movefile(smb_t* smb, file_t* f, int newdir)
{ {
file_t orgfile = *f; file_t newfile = *f;
if(findfile(&cfg, newdir, f->name, NULL)) { if(findfile(&cfg, newdir, f->name, NULL)) {
bprintf(text[FileAlreadyThere], f->name); bprintf(text[FileAlreadyThere], f->name);
return false; return false;
} }
if(!addfile(&cfg, newdir, f, f->extdesc, /* client: */NULL)) if(!addfile(&cfg, newdir, &newfile, newfile.extdesc, /* client: */NULL))
return false; return false;
if(!removefile(smb, &orgfile)) // Use ::removefile() here instead? if(!removefile(smb, f)) // Use ::removefile() here instead?
return false; return false;
bprintf(text[MovedFile],f->name bprintf(text[MovedFile],f->name
,cfg.lib[cfg.dir[newdir]->lib]->sname,cfg.dir[newdir]->sname); ,cfg.lib[cfg.dir[newdir]->lib]->sname,cfg.dir[newdir]->sname);
...@@ -265,9 +265,9 @@ bool sbbs_t::movefile(smb_t* smb, file_t* f, int newdir) ...@@ -265,9 +265,9 @@ bool sbbs_t::movefile(smb_t* smb, file_t* f, int newdir)
/* move actual file */ /* move actual file */
char oldpath[MAX_PATH + 1]; char oldpath[MAX_PATH + 1];
getfilepath(&cfg, f, oldpath); getfilepath(&cfg, f, oldpath);
f->dir = newdir; newfile.dir = newdir;
char newpath[MAX_PATH + 1]; char newpath[MAX_PATH + 1];
getfilepath(&cfg, f, newpath); getfilepath(&cfg, &newfile, newpath);
mv(oldpath, newpath, /* copy */false); mv(oldpath, newpath, /* copy */false);
return true; return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment