Changeset 1163 for trunk/dll/copyf.c


Ignore:
Timestamp:
Sep 5, 2008, 11:43:52 PM (17 years ago)
Author:
John Small
Message:

Ticket 187: Draft 1: Functions only

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/copyf.c

    r1082 r1163  
    1212  14 Oct 02 SHL Drop obsolete debug code
    1313  10 Nov 02 SHL docopyf - don't forget to terminate longname
    14                 optimize longname logic
     14                optimize longname logic
    1515  01 Aug 04 SHL Rework lstrip/rstrip usage
    1616  28 May 05 SHL Drop debug code
     
    3434
    3535#include "fm3str.h"
    36 #include "errutil.h"                    // Dos_Error...
    37 #include "strutil.h"                    // GetPString
     36#include "errutil.h"                    // Dos_Error...
     37#include "strutil.h"                    // GetPString
     38#include "copyf.h"
     39#include "literal.h"                    // fixup
    3840#include "fm3dll.h"
    3941#include "fortify.h"
     
    4143static PSZ pszSrcFile = __FILE__;
    4244
     45//static CHAR default_disk(VOID);
     46//static INT unlink_allf(CHAR * string, ...);
     47
    4348#ifndef WinMoveObject
    4449HOBJECT APIENTRY WinMoveObject(HOBJECT hObjectofObject,
    45                                HOBJECT hObjectofDest, ULONG ulReserved);
     50                               HOBJECT hObjectofDest, ULONG ulReserved);
    4651#endif
    4752#ifndef WinCopyObject
    4853HOBJECT APIENTRY WinCopyObject(HOBJECT hObjectofObject,
    49                                HOBJECT hObjectofDest, ULONG ulReserved);
     54                               HOBJECT hObjectofDest, ULONG ulReserved);
    5055#endif
    5156
     
    9095      (*p)++;
    9196      while (strchr("*?<>\":/\\|+=;,[]. ", *p))
    92         (*p)++;
     97        (*p)++;
    9398      *p = toupper(*p);
    9499    }
     
    96101      p--;
    97102      if (p >= o && *p == '.')
    98         p--;
     103        p--;
    99104      goto Loop;
    100105    }
     
    126131  f = oldname + (f - buffer);
    127132  strupr(buffer);
    128   while (*f == '.')                     /* skip leading '.'s */
     133  while (*f == '.')                     /* skip leading '.'s */
    129134    f++;
    130135  s = f;
    131   while (*f && *f != '.' && f < s + 8) {        /* skip past rootname */
     136  while (*f && *f != '.' && f < s + 8) {        /* skip past rootname */
    132137    *p = toupper(*f);
    133138    p++;
     
    184189      (*p)++;
    185190      while (strchr("*?<>\":/\\|+=;,[]. ", *p))
    186         (*p)++;
     191        (*p)++;
    187192      *p = toupper(*p);
    188193    }
     
    190195      p--;
    191196      if (p >= o && *p == '.')
    192         p--;
     197        p--;
    193198      goto Loop;
    194199    }
     
    218223    while (*value) {
    219224      if (*value == '/')
    220         *value = '\\';
     225        *value = '\\';
    221226      value++;
    222227    }
     
    235240      pfealist = xmallocz(1536, pszSrcFile, __LINE__);
    236241      if (pfealist) {
    237         pfealist->cbList = 1024;
    238         eaop.fpGEA2List = pgealist;
    239         eaop.fpFEA2List = pfealist;
    240         eaop.oError = 0L;
    241         DosError(FERR_DISABLEHARDERR);
    242         rc = DosQueryPathInfo(oldname,
    243                               FIL_QUERYEASFROMLIST,
    244                               (PVOID) & eaop, (ULONG) sizeof(EAOP2));
    245         if (!rc) {
    246           pfea = &eaop.fpFEA2List->list[0];
    247           value = pfea->szName + pfea->cbName + 1;
    248           value[pfea->cbValue] = 0;
    249           if (*(USHORT *) value == EAT_ASCII)
    250             strncat(longname,
    251                     value + (sizeof(USHORT) * 2),
    252                     CCHMAXPATH - strlen(longname));
    253           longname[CCHMAXPATH - 1] = 0;
    254         }
    255         free(pfealist);
     242        pfealist->cbList = 1024;
     243        eaop.fpGEA2List = pgealist;
     244        eaop.fpFEA2List = pfealist;
     245        eaop.oError = 0L;
     246        DosError(FERR_DISABLEHARDERR);
     247        rc = DosQueryPathInfo(oldname,
     248                              FIL_QUERYEASFROMLIST,
     249                              (PVOID) & eaop, (ULONG) sizeof(EAOP2));
     250        if (!rc) {
     251          pfea = &eaop.fpFEA2List->list[0];
     252          value = pfea->szName + pfea->cbName + 1;
     253          value[pfea->cbValue] = 0;
     254          if (*(USHORT *) value == EAT_ASCII)
     255            strncat(longname,
     256                    value + (sizeof(USHORT) * 2),
     257                    CCHMAXPATH - strlen(longname));
     258          longname[CCHMAXPATH - 1] = 0;
     259        }
     260        free(pfealist);
    256261      }
    257262      free(pgealist);
     
    290295    ealen = sizeof(FEALIST) + 10;
    291296  rc = DosAllocMem((PPVOID) & pfealist,
    292                    ealen + 32L, OBJ_TILE | PAG_COMMIT | PAG_READ | PAG_WRITE);
     297                   ealen + 32L, OBJ_TILE | PAG_COMMIT | PAG_READ | PAG_WRITE);
    293298  if (rc)
    294299    Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    295               GetPString(IDS_OUTOFMEMORY));
     300              GetPString(IDS_OUTOFMEMORY));
    296301  else {
    297302    memset(pfealist, 0, ealen + 1);
     
    317322    DosError(FERR_DISABLEHARDERR);
    318323    rc = xDosSetPathInfo(filename, FIL_QUERYEASIZE,
    319                         &eaop, sizeof(eaop), DSPI_WRTTHRU);
     324                        &eaop, sizeof(eaop), DSPI_WRTTHRU);
    320325    DosFreeMem(pfealist);
    321326    if (rc)
     
    341346      p = strrchr(oldname, '\\');
    342347      if (p && *(p + 1)) {
    343         strcpy(srce, p + 1);
    344         DosError(FERR_DISABLEHARDERR);
    345         if (!DosEditName(1L, srce, dest, result, (ULONG) sizeof(result))) {
    346           p = strrchr(newname, '\\');
    347           p++;
    348           strcpy(p, result);
    349           ret = TRUE;
    350         }
     348        strcpy(srce, p + 1);
     349        DosError(FERR_DISABLEHARDERR);
     350        if (!DosEditName(1L, srce, dest, result, (ULONG) sizeof(result))) {
     351          p = strrchr(newname, '\\');
     352          p++;
     353          strcpy(p, result);
     354          ret = TRUE;
     355        }
    351356      }
    352357    }
     
    355360}
    356361
     362#if 0   // JBS
    357363CHAR default_disk(VOID)
    358364{
     
    363369  return (CHAR) toupper((INT) ulDriveNum) + '@';
    364370}
     371#endif
    365372
    366373#ifdef NEVER
     
    385392
    386393      if (fb.attrFile & FILE_DIRECTORY) {
    387         DosError(FERR_ENABLEHARDERR);
    388         rc = DosCreateDir();
    389         if (rc == ERROR_INVALID_NAME || rc == ERROR_FILENAME_EXCED_RANGE) {
    390 
    391           /* truncate directory name */
    392           /* create that directory */
    393           /* update containers for name used */
    394 
    395         }
    396         rc = docopyallf(type,, "%s",);  /* recurse */
     394        DosError(FERR_ENABLEHARDERR);
     395        rc = DosCreateDir();
     396        if (rc == ERROR_INVALID_NAME || rc == ERROR_FILENAME_EXCED_RANGE) {
     397
     398          /* truncate directory name */
     399          /* create that directory */
     400          /* update containers for name used */
     401
     402        }
     403        rc = docopyallf(type,, "%s",);  /* recurse */
    397404      }
    398405      else
    399         rc = docopyf(type,, "%s",);     /* copy file */
     406        rc = docopyf(type,, "%s",);     /* copy file */
    400407      DosError(FERR_DISABLEHARDERR);
    401408    } while (!rc && !DosFindNext());
     
    434441  va_end(ap);
    435442
    436   if (!oldname || !*oldname || !*fullnewname)   /* bad string args */
     443  if (!oldname || !*oldname || !*fullnewname)   /* bad string args */
    437444    return (APIRET) - 1;
    438445
    439446  DosError(FERR_DISABLEHARDERR);
    440447  if (DosQueryPathInfo(oldname, FIL_STANDARDL, &st, sizeof(FILESTATUS3L)))
    441     return (APIRET) - 2;                /* no source */
     448    return (APIRET) - 2;                /* no source */
    442449
    443450  AdjustWildcardName(oldname, fullnewname);
    444451  MakeFullName(oldname);
    445452  MakeFullName(fullnewname);
    446   olddisk = toupper(*oldname);          /* source drive */
    447   newdisk = toupper(*fullnewname);      /* destination drive */
     453  olddisk = toupper(*oldname);          /* source drive */
     454  newdisk = toupper(*fullnewname);      /* destination drive */
    448455  if (!(driveflags[toupper(*oldname) - 'A'] & DRIVE_NOLONGNAMES))
    449456    *longname = 0;
     
    453460      p = RootName(longname);
    454461      if (p != longname)
    455         memmove(longname, p, strlen(p) + 1);
     462        memmove(longname, p, strlen(p) + 1);
    456463    }
    457464  }
     
    473480      hobjsrc = WinQueryObject(oldname);
    474481      if (hobjsrc) {
    475         strcpy(dir, fullnewname);
    476         p = strrchr(dir, '\\');
    477         if (p < dir + 3)
    478           p++;
    479         *p = 0;
    480         ret = ERROR_PATH_NOT_FOUND;
    481         hobjdest = WinQueryObject(dir);
    482         if (hobjdest) {
    483           ret = ERROR_GEN_FAILURE;
    484           hobjsrc = WinMoveObject(hobjsrc, hobjdest, 0);
    485           if (hobjsrc)
    486             ret = 0;
    487         }
     482        strcpy(dir, fullnewname);
     483        p = strrchr(dir, '\\');
     484        if (p < dir + 3)
     485          p++;
     486        *p = 0;
     487        ret = ERROR_PATH_NOT_FOUND;
     488        hobjdest = WinQueryObject(dir);
     489        if (hobjdest) {
     490          ret = ERROR_GEN_FAILURE;
     491          hobjsrc = WinMoveObject(hobjsrc, hobjdest, 0);
     492          if (hobjsrc)
     493            ret = 0;
     494        }
    488495      }
    489496    }
     
    498505      hobjsrc = WinQueryObject(oldname);
    499506      if (hobjsrc) {
    500         strcpy(dir, fullnewname);
    501         p = strrchr(dir, '\\');
    502         if (p < dir + 3)
    503           p++;
    504         *p = 0;
    505         ret = ERROR_PATH_NOT_FOUND;
    506         hobjdest = WinQueryObject(dir);
    507         if (hobjdest) {
    508           ret = ERROR_GEN_FAILURE;
    509           hobjsrc = WinCopyObject(hobjsrc, hobjdest, 0);
    510           if (hobjsrc)
    511             ret = 0;
    512         }
     507        strcpy(dir, fullnewname);
     508        p = strrchr(dir, '\\');
     509        if (p < dir + 3)
     510          p++;
     511        *p = 0;
     512        ret = ERROR_PATH_NOT_FOUND;
     513        hobjdest = WinQueryObject(dir);
     514        if (hobjdest) {
     515          ret = ERROR_GEN_FAILURE;
     516          hobjsrc = WinCopyObject(hobjsrc, hobjdest, 0);
     517          if (hobjsrc)
     518            ret = 0;
     519        }
    513520      }
    514521    }
     
    517524  case MOVE:
    518525    *dir = 0;
    519     if (olddisk == newdisk) {           /* same drive */
     526    if (olddisk == newdisk) {           /* same drive */
    520527      /* make temporary copy in case move fails */
    521528      if (IsFile(fullnewname) != -1 && stricmp(oldname, fullnewname)) {
    522         strcpy(dir, fullnewname);
    523         p = strrchr(dir, '\\');
    524         if (p)
    525           *p = 0;
    526         strcat(dir, "\\");
    527         MakeTempName(dir, NULL, 0);
    528         if (DosMove(fullnewname, dir))
    529           *dir = 0;
     529        strcpy(dir, fullnewname);
     530        p = strrchr(dir, '\\');
     531        if (p)
     532          *p = 0;
     533        strcat(dir, "\\");
     534        MakeTempName(dir, NULL, 0);
     535        if (DosMove(fullnewname, dir))
     536          *dir = 0;
    530537      }
    531538      DosError(FERR_DISABLEHARDERR);
    532       ret = DosMove(oldname, fullnewname);      /* move it */
    533       if (ret && *dir) {                /* failed -- clean up */
    534         DosError(FERR_DISABLEHARDERR);
    535         if (!DosMove(dir, fullnewname))
    536           Broadcast((HAB) 0, hwndMain, UM_UPDATERECORD, MPFROMP(dir), MPVOID);
     539      ret = DosMove(oldname, fullnewname);      /* move it */
     540      if (ret && *dir) {                /* failed -- clean up */
     541        DosError(FERR_DISABLEHARDERR);
     542        if (!DosMove(dir, fullnewname))
     543          Broadcast((HAB) 0, hwndMain, UM_UPDATERECORD, MPFROMP(dir), MPVOID);
    537544      }
    538545      else if (!ret && *dir) {
    539         if (!IsFile(dir)) {
    540           if (!strchr(dir, '?') && !strchr(dir, '*'))
    541             wipeallf("%s\\*", dir);
    542           DosError(FERR_DISABLEHARDERR);
    543           if (DosDeleteDir(dir)) {
    544             make_deleteable(dir);
    545             DosDeleteDir(dir);
    546           }
    547         }
    548         else if (IsFile(dir) > 0) {
    549           DosError(FERR_DISABLEHARDERR);
    550           if (DosForceDelete(dir)) {
    551             make_deleteable(dir);
    552             DosForceDelete(dir);
    553           }
    554           if (zaplong)
    555             ZapLongName(dir);
    556           Broadcast((HAB) 0, hwndMain, UM_UPDATERECORD, MPFROMP(dir), MPVOID);
    557         }
    558       }
    559     }
    560     else {                              /* different drives */
     546        if (!IsFile(dir)) {
     547          if (!strchr(dir, '?') && !strchr(dir, '*'))
     548            wipeallf("%s\\*", dir);
     549          DosError(FERR_DISABLEHARDERR);
     550          if (DosDeleteDir(dir)) {
     551            make_deleteable(dir);
     552            DosDeleteDir(dir);
     553          }
     554        }
     555        else if (IsFile(dir) > 0) {
     556          DosError(FERR_DISABLEHARDERR);
     557          if (DosForceDelete(dir)) {
     558            make_deleteable(dir);
     559            DosForceDelete(dir);
     560          }
     561          if (zaplong)
     562            ZapLongName(dir);
     563          Broadcast((HAB) 0, hwndMain, UM_UPDATERECORD, MPFROMP(dir), MPVOID);
     564        }
     565      }
     566    }
     567    else {                              /* different drives */
    561568      DosError(FERR_DISABLEHARDERR);
    562       ret = DosCopy(oldname, fullnewname, DCPY_EXISTING);       /* <=-NOTE! */
     569      ret = DosCopy(oldname, fullnewname, DCPY_EXISTING);       /* <=-NOTE! */
    563570      if (ret == ERROR_DISK_CHANGE) {
    564         DosError(FERR_ENABLEHARDERR);
    565         ret = DosCopy(oldname, fullnewname, DCPY_EXISTING);
    566         diskchange = TRUE;
     571        DosError(FERR_ENABLEHARDERR);
     572        ret = DosCopy(oldname, fullnewname, DCPY_EXISTING);
     573        diskchange = TRUE;
    567574      }
    568575      if (ret == ERROR_INVALID_NAME || ret == ERROR_FILENAME_EXCED_RANGE) {
    569         if (TruncName(fullnewname, shortname)) {        /* make 8.3 filename */
    570           DosError(FERR_DISABLEHARDERR);
    571           ret = DosCopy(oldname, shortname, DCPY_EXISTING);
    572           if (!ret) {                   /* success -- write longname ea */
    573             WriteLongName(shortname, fullnewname);
    574             strcpy(fullnewname, shortname);
    575             /* broadcast fixup msg to windows */
    576             Broadcast((HAB) 0,
    577                       hwndMain, UM_UPDATERECORD, MPFROMP(shortname), MPVOID);
    578           }
    579         }
     576        if (TruncName(fullnewname, shortname)) {        /* make 8.3 filename */
     577          DosError(FERR_DISABLEHARDERR);
     578          ret = DosCopy(oldname, shortname, DCPY_EXISTING);
     579          if (!ret) {                   /* success -- write longname ea */
     580            WriteLongName(shortname, fullnewname);
     581            strcpy(fullnewname, shortname);
     582            /* broadcast fixup msg to windows */
     583            Broadcast((HAB) 0,
     584                      hwndMain, UM_UPDATERECORD, MPFROMP(shortname), MPVOID);
     585          }
     586        }
    580587      }
    581588      else if (!ret && *longname) {
    582589
    583         CHAR fixname[CCHMAXPATH];
    584 
    585         strcpy(fixname, fullnewname);
    586         p = strrchr(fixname, '\\');
    587         if (p) {
    588           p++;
    589           *p = 0;
    590         }
    591         strcat(fixname, longname);
    592         DosError(FERR_DISABLEHARDERR);
    593         DosMove(fullnewname, fixname);
    594         strcpy(fullnewname, fixname);
    595         if (zaplong)
    596           ZapLongName(fixname);
    597         Broadcast((HAB) 0,
    598                   hwndMain, UM_UPDATERECORD, MPFROMP(fixname), MPVOID);
    599       }
    600       if (!ret) {                       /* double-check success */
    601         DosError(FERR_DISABLEHARDERR);
    602         rc = DosQueryPathInfo(fullnewname,
    603                               FIL_STANDARDL, &st2, sizeof(FILESTATUS3L));
    604         if (rc == ERROR_DISK_CHANGE) {
    605           DosError(FERR_ENABLEHARDERR);
    606           rc = DosQueryPathInfo(fullnewname,
    607                                 FIL_STANDARDL, &st2, sizeof(FILESTATUS3L));
    608         }
    609         if (!rc && st2.cbFile == st.cbFile) {   /* seems to have worked... */
    610           DosError(FERR_DISABLEHARDERR);
    611           if (diskchange) {
    612             DosError(FERR_ENABLEHARDERR);
    613             DosQueryPathInfo(oldname, FIL_STANDARDL, &dummy, sizeof(FILESTATUS3L));     /* force disk change */
    614           }
    615           if (!(st2.attrFile & FILE_DIRECTORY)) /* erase file */
    616             unlinkf("%s", oldname);
    617           else {                        /* remove directory */
    618             wipeallf("%s\\*", oldname);
    619             DosError(FERR_DISABLEHARDERR);
    620             if (DosDeleteDir(oldname)) {
    621               make_deleteable(oldname);
    622               DosDeleteDir(oldname);
    623             }
    624           }
    625         }
     590        CHAR fixname[CCHMAXPATH];
     591
     592        strcpy(fixname, fullnewname);
     593        p = strrchr(fixname, '\\');
     594        if (p) {
     595          p++;
     596          *p = 0;
     597        }
     598        strcat(fixname, longname);
     599        DosError(FERR_DISABLEHARDERR);
     600        DosMove(fullnewname, fixname);
     601        strcpy(fullnewname, fixname);
     602        if (zaplong)
     603          ZapLongName(fixname);
     604        Broadcast((HAB) 0,
     605                  hwndMain, UM_UPDATERECORD, MPFROMP(fixname), MPVOID);
     606      }
     607      if (!ret) {                       /* double-check success */
     608        DosError(FERR_DISABLEHARDERR);
     609        rc = DosQueryPathInfo(fullnewname,
     610                              FIL_STANDARDL, &st2, sizeof(FILESTATUS3L));
     611        if (rc == ERROR_DISK_CHANGE) {
     612          DosError(FERR_ENABLEHARDERR);
     613          rc = DosQueryPathInfo(fullnewname,
     614                                FIL_STANDARDL, &st2, sizeof(FILESTATUS3L));
     615        }
     616        if (!rc && st2.cbFile == st.cbFile) {   /* seems to have worked... */
     617          DosError(FERR_DISABLEHARDERR);
     618          if (diskchange) {
     619            DosError(FERR_ENABLEHARDERR);
     620            DosQueryPathInfo(oldname, FIL_STANDARDL, &dummy, sizeof(FILESTATUS3L));     /* force disk change */
     621          }
     622          if (!(st2.attrFile & FILE_DIRECTORY)) /* erase file */
     623            unlinkf("%s", oldname);
     624          else {                        /* remove directory */
     625            wipeallf("%s\\*", oldname);
     626            DosError(FERR_DISABLEHARDERR);
     627            if (DosDeleteDir(oldname)) {
     628              make_deleteable(oldname);
     629              DosDeleteDir(oldname);
     630            }
     631          }
     632        }
    626633      }
    627634    }
     
    630637  case COPY:
    631638    DosError(FERR_DISABLEHARDERR);
    632     ret = DosCopy(oldname, fullnewname, DCPY_EXISTING); /* <=-NOTE! */
     639    ret = DosCopy(oldname, fullnewname, DCPY_EXISTING); /* <=-NOTE! */
    633640    if (ret == ERROR_DISK_CHANGE) {
    634641      DosError(FERR_ENABLEHARDERR);
     
    638645    if (ret == ERROR_INVALID_NAME || ret == ERROR_FILENAME_EXCED_RANGE) {
    639646      if (TruncName(fullnewname, shortname)) {
    640         DosError((diskchange) ? FERR_ENABLEHARDERR : FERR_DISABLEHARDERR);
    641         ret = DosCopy(oldname, shortname, DCPY_EXISTING);
    642         if (!ret) {
    643           WriteLongName(shortname, fullnewname);
    644           strcpy(fullnewname, shortname);
    645           Broadcast((HAB) 0,
    646                     hwndMain, UM_UPDATERECORD, MPFROMP(shortname), MPVOID);
    647         }
     647        DosError((diskchange) ? FERR_ENABLEHARDERR : FERR_DISABLEHARDERR);
     648        ret = DosCopy(oldname, shortname, DCPY_EXISTING);
     649        if (!ret) {
     650          WriteLongName(shortname, fullnewname);
     651          strcpy(fullnewname, shortname);
     652          Broadcast((HAB) 0,
     653                    hwndMain, UM_UPDATERECORD, MPFROMP(shortname), MPVOID);
     654        }
    648655      }
    649656    }
     
    655662      p = strrchr(fixname, '\\');
    656663      if (p) {
    657         p++;
    658         *p = 0;
     664        p++;
     665        *p = 0;
    659666      }
    660667      strcat(fixname, longname);
     
    662669      DosMove(fullnewname, fixname);
    663670      if (zaplong)
    664         ZapLongName(fixname);
     671        ZapLongName(fixname);
    665672      Broadcast((HAB) 0, hwndMain, UM_UPDATERECORD, MPFROMP(fixname), MPVOID);
    666673    }
    667674    return ret;
    668675
    669   default:                              /* shouldn't happen */
     676  default:                              /* shouldn't happen */
    670677    Runtime_Error(pszSrcFile, __LINE__, "bad case %u", type);
    671678    break;
    672679  }
    673   return (APIRET) - 3;                  /* bad type */
     680  return (APIRET) - 3;                  /* bad type */
    674681}
    675682
     
    717724    return -1;
    718725
    719   {                                     /* safety net -- disallow deleting a root dir or partial name */
     726  {                                     /* safety net -- disallow deleting a root dir or partial name */
    720727    CHAR temp;
    721728
     
    726733      *p = 0;
    727734      if (IsRoot(str) || !IsFullName(str)) {
    728         /* under no circumstances! */
    729         Runtime_Error(pszSrcFile, __LINE__, "bad name %s", str);
    730         free(str);
    731         return -1;
     735        /* under no circumstances! */
     736        Runtime_Error(pszSrcFile, __LINE__, "bad name %s", str);
     737        free(str);
     738        return -1;
    732739      }
    733740      *p = temp;
     
    736743
    737744  p = s;
    738   p = strrchr(s, '\\');                 /* strip s to just path */
     745  p = strrchr(s, '\\');                 /* strip s to just path */
    739746  if (!p)
    740747    p = strrchr(s, ':');
     
    764771  DosError(FERR_DISABLEHARDERR);
    765772  if (!DosFindFirst(str, &search_handle, FILE_NORMAL | FILE_DIRECTORY |
    766                      FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN | FILE_ARCHIVED,
    767                      f, sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
     773                     FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN | FILE_ARCHIVED,
     774                     f, sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
    768775
    769776    strcpy(ss, s);
     
    773780      strcpy(p, f->achName);
    774781      if (f->attrFile & FILE_DIRECTORY) {
    775         if (strcmp(f->achName, ".") && strcmp(f->achName, "..")) {
    776           wipeallf("%s/%s", ss, mask);  /* recurse to wipe files */
    777           DosError(FERR_DISABLEHARDERR);
    778           if (DosDeleteDir(ss)) {       /* remove directory */
    779             make_deleteable(ss);
    780             DosError(FERR_DISABLEHARDERR);
    781             DosDeleteDir(ss);
    782           }
    783         }
     782        if (strcmp(f->achName, ".") && strcmp(f->achName, "..")) {
     783          wipeallf("%s/%s", ss, mask);  /* recurse to wipe files */
     784          DosError(FERR_DISABLEHARDERR);
     785          if (DosDeleteDir(ss)) {       /* remove directory */
     786            make_deleteable(ss);
     787            DosError(FERR_DISABLEHARDERR);
     788            DosDeleteDir(ss);
     789          }
     790        }
    784791      }
    785792      else {
    786         DosError(FERR_DISABLEHARDERR);
    787         if (DosForceDelete(ss)) {
    788           make_deleteable(ss);
    789           DosError(FERR_DISABLEHARDERR);
    790           rc = (INT) DosForceDelete(ss);
    791           if (rc)
    792             return rc;
    793         }
     793        DosError(FERR_DISABLEHARDERR);
     794        if (DosForceDelete(ss)) {
     795          make_deleteable(ss);
     796          DosError(FERR_DISABLEHARDERR);
     797          rc = (INT) DosForceDelete(ss);
     798          if (rc)
     799            return rc;
     800        }
    794801      }
    795802      num_matches = 1;
    796803      DosError(FERR_DISABLEHARDERR);
    797804    } while (!DosFindNext(search_handle, f, sizeof(FILEFINDBUF3),
    798                           &num_matches));
     805                          &num_matches));
    799806    DosFindClose(search_handle);
    800807  }
     
    806813}
    807814
     815#if 0   // JBS
    808816INT unlink_allf(CHAR * string, ...)
    809817{
     
    834842
    835843  p = s;
    836   p = strrchr(s, '\\');                 /* strip s to just path */
     844  p = strrchr(s, '\\');                 /* strip s to just path */
    837845  if (!p)
    838846    p = strrchr(s, ':');
     
    858866  DosError(FERR_DISABLEHARDERR);
    859867  if (!DosFindFirst(str, &search_handle, FILE_NORMAL, f,
    860                     sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
     868                    sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
    861869
    862870    strcpy(ss, s);
     
    869877      DosError(FERR_DISABLEHARDERR);
    870878    } while (!DosFindNext(search_handle, f, sizeof(FILEFINDBUF3),
    871                           &num_matches));
     879                          &num_matches));
    872880    DosFindClose(search_handle);
    873881  }
     
    878886  return 0;
    879887}
     888#endif
    880889
    881890INT unlinkf(CHAR * string, ...)
Note: See TracChangeset for help on using the changeset viewer.