Changeset 1686 for trunk/dll/copyf.c


Ignore:
Timestamp:
Mar 10, 2013, 7:34:34 PM (12 years ago)
Author:
Gregg Young
Message:

GKY Improvrd readonly check on delete to allow cancel and don't ask again options; Added saymsg2 for this purpose; Fixes to snapshot file. cs 1685 contained the COMP.C changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/copyf.c

    r1664 r1686  
    3333  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
    3434                readonly files
     35  10 Mar 13 GKY Improvrd readonly check on delete to allow cancel and don't ask again options
    3536
    3637***********************************************************************/
     
    531532          DosError(FERR_DISABLEHARDERR);
    532533          if (DosDeleteDir(dir)) {
    533             make_deleteable(dir, 0);
     534            make_deleteable(dir, -1, TRUE);
    534535            DosDeleteDir(dir);
    535536          }
     
    541542          error = DosForceDelete(dir);
    542543          if (error) {
    543             make_deleteable(dir, error);
     544            make_deleteable(dir, error, FALSE);
    544545            DosForceDelete(dir);
    545546          }
     
    618619            DosError(FERR_DISABLEHARDERR);
    619620            if (DosDeleteDir(oldname)) {
    620               make_deleteable(oldname, 0);
     621              make_deleteable(oldname, -1, TRUE);
    621622              DosDeleteDir(oldname);
    622623            }
     
    675676}
    676677
    677 INT make_deleteable(CHAR * filename, INT error)
     678INT make_deleteable(CHAR * filename, INT error, BOOL Dontcheckreadonly)
    678679{
    679680  APIRET rc;
     
    682683  FILESTATUS3 fsi;
    683684
     685  //DbgMsg(pszSrcFile, __LINE__, "error %i ", error);
     686  DosError(FERR_DISABLEHARDERR);
     687  rc = DosQueryPathInfo(filename, FIL_STANDARD, &fsi, sizeof(fsi));
     688  if (!rc) {
     689    if (fsi.attrFile & 0x00000001) {
     690      if (fWarnReadOnly && !Dontcheckreadonly) {
     691        retrn = saymsg2(NULL, 0,
     692                       HWND_DESKTOP,
     693                       GetPString(IDS_READONLYFILEWARNINGTITLE),
     694                       GetPString(IDS_READONLYFILEWARNING),
     695                       filename);
     696        if (retrn == 3)
     697          ret = 3;
     698        else if (retrn == 4)
     699          ret = 2;
     700        else {
     701          fsi.attrFile = 0;
     702          DosError(FERR_DISABLEHARDERR);
     703          if (!xDosSetPathInfo(filename, FIL_STANDARD, &fsi, sizeof(fsi), 0))
     704            if (retrn == 1)
     705              ret = 0;
     706            else
     707              ret = 1;
     708        }
     709      }
     710      else
     711        fsi.attrFile = 0;
     712        DosError(FERR_DISABLEHARDERR);
     713        if (!xDosSetPathInfo(filename, FIL_STANDARD, &fsi, sizeof(fsi), 0))
     714          ret = 0;
     715    }
     716  }
    684717  if (error ==  ERROR_SHARING_VIOLATION && fUnlock) {
    685718    retrn = saymsg(MB_YESNO | MB_DEFBUTTON2,
     
    694727    }
    695728  }
    696   DosError(FERR_DISABLEHARDERR);
    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   }
    722729
    723730  return ret;
     
    737744  va_list ap;
    738745  INT rc;
     746  static BOOL ignorereadonly = FALSE;
    739747
    740748  va_start(ap, string);
     
    815823          // remove directory
    816824          if (DosDeleteDir(ss)) {
    817             make_deleteable(ss, 0);     // Try harder
     825            make_deleteable(ss, -1, TRUE);      // Try harder
    818826            DosError(FERR_DISABLEHARDERR);
    819827            DosDeleteDir(ss);
     
    826834        DosError(FERR_DISABLEHARDERR);
    827835        error = DosForceDelete(ss);
    828         if (error) {
    829           make_deleteable(ss, error);
     836        if (error) {
     837          INT retrn = 0;
     838
     839          retrn = make_deleteable(ss, error, ignorereadonly);
     840          if (retrn == 3)
     841            continue;
     842          else if (retrn == 1)
     843            ignorereadonly = TRUE;
    830844          DosError(FERR_DISABLEHARDERR);
    831845          rc = (INT) DosForceDelete(ss);
     
    844858  free(ss);
    845859  free(str);
     860  ignorereadonly = FALSE;
    846861  return 0;
    847862}
     
    930945    DosError(FERR_DISABLEHARDERR);
    931946    if (DosDelete(string)) {
    932       make_deleteable(string, -1);
     947      make_deleteable(string, -1, TRUE);
    933948      DosError(FERR_DISABLEHARDERR);
    934949      return DosDelete(string);
     
    941956    error = DosForceDelete(string);
    942957    if (error) {
    943       make_deleteable(string, error);
     958      make_deleteable(string, error, FALSE);
    944959      DosError(FERR_DISABLEHARDERR);
    945960      return DosForceDelete(string);
Note: See TracChangeset for help on using the changeset viewer.