From 2a68954502a8167f5cbbd8955c57872cd0dc00b1 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Fri, 12 Jul 2019 19:39:28 +0300 Subject: [PATCH] Do not move old configuration.backup to trashcan, simply delete it. --- cfgfile.cpp | 2 +- filesys.cpp | 2 +- include/fsdb.h | 2 +- od-win32/fsdb_mywin32.cpp | 12 ++++++------ scsitape.cpp | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cfgfile.cpp b/cfgfile.cpp index 8f69b6f9..810045ff 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -6615,7 +6615,7 @@ void cfgfile_backup (const TCHAR *path) fetch_configurationpath (dpath, sizeof (dpath) / sizeof (TCHAR)); _tcscat (dpath, _T("configuration.backup")); bool hidden = my_isfilehidden (dpath); - my_unlink (dpath); + my_unlink (dpath, true); my_rename (path, dpath); if (hidden) my_setfilehidden (dpath, hidden); diff --git a/filesys.cpp b/filesys.cpp index 3a7c9d5c..ba64af84 100644 --- a/filesys.cpp +++ b/filesys.cpp @@ -6015,7 +6015,7 @@ static void action_delete_object(TrapContext *ctx, Unit *unit, dpacket *packet) return; } } else { - if (my_unlink (a->nname) == -1) { + if (my_unlink (a->nname, false) == -1) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, dos_errno ()); return; diff --git a/include/fsdb.h b/include/fsdb.h index a2797aec..8308aa20 100644 --- a/include/fsdb.h +++ b/include/fsdb.h @@ -153,7 +153,7 @@ extern int my_readdir (struct my_opendir_s*, TCHAR*); extern int my_rmdir (const TCHAR*); extern int my_mkdir (const TCHAR*); -extern int my_unlink (const TCHAR*); +extern int my_unlink (const TCHAR*, bool); extern int my_rename (const TCHAR*, const TCHAR*); extern int my_setcurrentdir (const TCHAR *curdir, TCHAR *oldcur); bool my_isfilehidden (const TCHAR *path); diff --git a/od-win32/fsdb_mywin32.cpp b/od-win32/fsdb_mywin32.cpp index 0d6b9e57..22ef1384 100644 --- a/od-win32/fsdb_mywin32.cpp +++ b/od-win32/fsdb_mywin32.cpp @@ -70,7 +70,7 @@ int my_mkdir (const TCHAR *name) return CreateDirectory (namep, NULL) == 0 ? -1 : 0; } -static int recycle (const TCHAR *name) +static int recycle (const TCHAR *name, bool dontrecycle) { DWORD dirattr = GetFileAttributesSafe (name); bool isdir = dirattr != INVALID_FILE_ATTRIBUTES && (dirattr & FILE_ATTRIBUTE_DIRECTORY); @@ -85,7 +85,7 @@ static int recycle (const TCHAR *name) namep = name; } - if (currprefs.win32_norecyclebin || isdir || currprefs.win32_filesystem_mangle_reserved_names == false) { + if (dontrecycle || currprefs.win32_norecyclebin || isdir || currprefs.win32_filesystem_mangle_reserved_names == false) { if (isdir) return RemoveDirectory (namep) ? 0 : -1; else @@ -162,13 +162,13 @@ int my_rmdir (const TCHAR *name) return -1; } - return recycle (name); + return recycle (name, false); } /* "move to Recycle Bin" (if enabled) -version of DeleteFile() */ -int my_unlink (const TCHAR *name) +int my_unlink (const TCHAR *name, bool dontrecycle) { - return recycle (name); + return recycle (name, dontrecycle); } int my_rename (const TCHAR *oldname, const TCHAR *newname) @@ -944,7 +944,7 @@ bool my_resolveshortcut(TCHAR *linkfile, int size) if (SUCCEEDED(hres)) { // Get the path to the link target. - hres = psl->GetPath(szGotPath, MAX_DPATH, (WIN32_FIND_DATA*)&wfd, SLGP_SHORTPATH); + hres = psl->GetPath(szGotPath, MAX_DPATH, &wfd, SLGP_SHORTPATH); if (SUCCEEDED(hres)) { diff --git a/scsitape.cpp b/scsitape.cpp index 5005b18c..fcbb0635 100644 --- a/scsitape.cpp +++ b/scsitape.cpp @@ -199,7 +199,7 @@ static void erase (struct scsi_data_tape *tape) if (ext && !_tcsicmp (ext, _T(".tape"))) { _stprintf (path, _T("%s%s%s"), tape->tape_dir, FSDB_DIR_SEPARATOR_S, filename); if (my_existsfile (path)) - my_unlink (path); + my_unlink (path, false); } } my_closedir (od); -- 2.47.3