Changeset 1664 for trunk/dll/copyf.c


Ignore:
Timestamp:
Aug 5, 2012, 2:11:07 AM (13 years ago)
Author:
Gregg Young
Message:

Changes to use Unlock to unlock files if Unlock.exe is in path both from menu/toolbar and as part of copy, move and delete operations. Changes to allow copy and move over readonly files with a warning dialog; also added a warning dialog for delete of readonly files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/copyf.c

    r1628 r1664  
    2929  26 Aug 11 GKY Add a low mem version of xDosAlloc* wrappers; move error checking into all the
    3030                xDosAlloc* wrappers.
     31  04 Aug 12 GKY Changes to use Unlock to unlock files if Unlock.exe is in path both from menu/toolbar and as part of copy, move and
     32                delete operations
     33  04 Aug 12 GKY Changes to allow copy and move over readonly files with a warning dialog; also added a warning dialog for delete of
     34                readonly files
    3135
    3236***********************************************************************/
     
    6064#include "fortify.h"
    6165#include "pathutil.h"                   // AddBackslashToPath
     66#include "worker.h"
     67#include "systemf.h"
    6268
    6369static PSZ pszSrcFile = __FILE__;
     
    525531          DosError(FERR_DISABLEHARDERR);
    526532          if (DosDeleteDir(dir)) {
    527             make_deleteable(dir);
     533            make_deleteable(dir, 0);
    528534            DosDeleteDir(dir);
    529535          }
    530536        }
    531         else if (IsFile(dir) > 0) {
    532           DosError(FERR_DISABLEHARDERR);
    533           if (DosForceDelete(dir)) {
    534             make_deleteable(dir);
     537        else if (IsFile(dir) > 0) {
     538          APIRET error;
     539
     540          DosError(FERR_DISABLEHARDERR);
     541          error = DosForceDelete(dir);
     542          if (error) {
     543            make_deleteable(dir, error);
    535544            DosForceDelete(dir);
    536545          }
     
    609618            DosError(FERR_DISABLEHARDERR);
    610619            if (DosDeleteDir(oldname)) {
    611               make_deleteable(oldname);
     620              make_deleteable(oldname, 0);
    612621              DosDeleteDir(oldname);
    613622            }
     
    666675}
    667676
    668 INT make_deleteable(CHAR * filename)
    669 {
     677INT make_deleteable(CHAR * filename, INT error)
     678{
     679  APIRET rc;
    670680  INT ret = -1;
     681  INT retrn;
    671682  FILESTATUS3 fsi;
    672683
     684  if (error ==  ERROR_SHARING_VIOLATION && fUnlock) {
     685    retrn = saymsg(MB_YESNO | MB_DEFBUTTON2,
     686                 HWND_DESKTOP,
     687                 GetPString(IDS_LOCKEDFILEWARNINGTITLE),
     688                 GetPString(IDS_LOCKEDFILEWARNING),
     689                 filename);
     690    if (retrn == MBID_YES) {
     691      runemf2(SEPARATE | INVISIBLE | BACKGROUND | WAIT,
     692              HWND_DESKTOP, pszSrcFile, __LINE__,
     693              NULL, NULL, "%s %s", PCSZ_UNLOCKEXE, filename);
     694    }
     695  }
    673696  DosError(FERR_DISABLEHARDERR);
    674   if (!DosQueryPathInfo(filename, FIL_STANDARD, &fsi, sizeof(fsi))) {
    675     fsi.attrFile = 0;
    676     DosError(FERR_DISABLEHARDERR);
    677     if (!xDosSetPathInfo(filename, FIL_STANDARD, &fsi, sizeof(fsi), 0))
    678       ret = 0;
    679   }
     697  rc = DosQueryPathInfo(filename, FIL_STANDARD, &fsi, sizeof(fsi));
     698  if (!rc) {
     699    if (fsi.attrFile & 0x00000001) {
     700      if (fWarnReadOnly && error != -1) {
     701        retrn = saymsg(MB_YESNO | MB_DEFBUTTON2,
     702                       HWND_DESKTOP,
     703                       GetPString(IDS_READONLYFILEWARNINGTITLE),
     704                       GetPString(IDS_READONLYFILEWARNING),
     705                       filename);
     706        if (retrn == MBID_YES) {
     707          fsi.attrFile = 0;
     708          DosError(FERR_DISABLEHARDERR);
     709          if (!xDosSetPathInfo(filename, FIL_STANDARD, &fsi, sizeof(fsi), 0))
     710            ret = 0;
     711        }
     712        else
     713          ret = 0;
     714      }
     715      else
     716        fsi.attrFile = 0;
     717        DosError(FERR_DISABLEHARDERR);
     718        if (!xDosSetPathInfo(filename, FIL_STANDARD, &fsi, sizeof(fsi), 0))
     719          ret = 0;
     720    }
     721  }
     722
    680723  return ret;
    681724}
     
    772815          // remove directory
    773816          if (DosDeleteDir(ss)) {
    774             make_deleteable(ss);        // Try harder
     817            make_deleteable(ss, 0);     // Try harder
    775818            DosError(FERR_DISABLEHARDERR);
    776819            DosDeleteDir(ss);
     
    779822      }
    780823      else {
    781         DosError(FERR_DISABLEHARDERR);
    782         if (DosForceDelete(ss)) {
    783           make_deleteable(ss);
     824        APIRET error;
     825
     826        DosError(FERR_DISABLEHARDERR);
     827        error = DosForceDelete(ss);
     828        if (error) {
     829          make_deleteable(ss, error);
    784830          DosError(FERR_DISABLEHARDERR);
    785831          rc = (INT) DosForceDelete(ss);
     
    884930    DosError(FERR_DISABLEHARDERR);
    885931    if (DosDelete(string)) {
    886       make_deleteable(string);
     932      make_deleteable(string, -1);
    887933      DosError(FERR_DISABLEHARDERR);
    888934      return DosDelete(string);
     
    890936  }
    891937  else {
     938    APIRET error;
     939
    892940    DosError(FERR_DISABLEHARDERR);
    893     if (DosForceDelete(string)) {
    894       make_deleteable(string);
     941    error = DosForceDelete(string);
     942    if (error) {
     943      make_deleteable(string, error);
    895944      DosError(FERR_DISABLEHARDERR);
    896945      return DosForceDelete(string);
Note: See TracChangeset for help on using the changeset viewer.