Changeset 1402 for trunk/dll/copyf.c


Ignore:
Timestamp:
Mar 14, 2009, 6:17:59 PM (16 years ago)
Author:
Gregg Young
Message:

Remove variable aurgs from docopy & unlinkf (not used); Move more strings to PCSZs and string table; Move PCSZs to compile time initialization; Fix hang on startup caused by a drive scan and a dircnr scan trying to update a drive in the tree at the same time (related to the "treeswitch options); Code cleanup mainly removal of old printfs, SayMsgs, DbgMsg and unneeded %s.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/copyf.c

    r1321 r1402  
    2020  29 Feb 08 GKY Use xfree where appropriate
    2121  19 Jul 08 GKY Modify MakeTempName for use making temp directory names
     22  08 Mar 09 GKY Removed variable aurguments from docopyf and unlinkf (not used)
    2223
    2324***********************************************************************/
     
    417418      }
    418419      else
    419         rc = docopyf(type,, "%s",);     /* copy file */
     420       // docopyf changed this won't work rc = docopyf(type,, "%s",);     /* copy file */
    420421      DosError(FERR_DISABLEHARDERR);
    421422    } while (!rc && !DosFindNext());
     
    429430#endif
    430431
    431 APIRET docopyf(INT type, CHAR * oldname, CHAR * newname, ...)
     432APIRET docopyf(INT type, CHAR *oldname, CHAR *newname)
    432433{
    433434  /*
     
    440441   */
    441442
    442   CHAR fullnewname[CCHMAXPATH + 1], longname[CCHMAXPATH],
    443     shortname[CCHMAXPATH];
     443  CHAR longname[CCHMAXPATH], shortname[CCHMAXPATH];
    444444  CHAR olddisk, newdisk, dir[CCHMAXPATH], *p, *pp;
    445445  APIRET ret = -1, rc;
    446446  FILESTATUS3L st, st2, dummy;
    447447  BOOL diskchange = FALSE, zaplong = FALSE;
    448   va_list ap;
    449 
    450   *fullnewname = *shortname = *dir = 0;
    451 
    452   va_start(ap, newname);
    453   vsprintf(fullnewname, newname, ap);
    454   va_end(ap);
    455 
    456   if (!oldname || !*oldname || !*fullnewname)   /* bad string args */
     448
     449  *shortname = *dir = 0;
     450
     451  if (!oldname || !*oldname || !*newname)   /* bad string args */
    457452    return (APIRET) - 1;
    458453
     
    461456    return (APIRET) - 2;                /* no source */
    462457
    463   AdjustWildcardName(oldname, fullnewname);
     458  AdjustWildcardName(oldname, newname);
    464459  MakeFullName(oldname);
    465   MakeFullName(fullnewname);
     460  MakeFullName(newname);
    466461  olddisk = toupper(*oldname);          /* source drive */
    467   newdisk = toupper(*fullnewname);      /* destination drive */
     462  newdisk = toupper(*newname);      /* destination drive */
    468463  if (!(driveflags[toupper(*oldname) - 'A'] & DRIVE_NOLONGNAMES))
    469464    *longname = 0;
     
    478473  /* If root name changed make sure longname EA goes away */
    479474  p = RootName(oldname);
    480   pp = RootName(fullnewname);
     475  pp = RootName(newname);
    481476  if (stricmp(p, pp)) {
    482477    zaplong = TRUE;
     
    493488      hobjsrc = WinQueryObject(oldname);
    494489      if (hobjsrc) {
    495         strcpy(dir, fullnewname);
     490        strcpy(dir, newname);
    496491        p = strrchr(dir, '\\');
    497492        if (p < dir + 3)
     
    518513      hobjsrc = WinQueryObject(oldname);
    519514      if (hobjsrc) {
    520         strcpy(dir, fullnewname);
     515        strcpy(dir, newname);
    521516        p = strrchr(dir, '\\');
    522517        if (p < dir + 3)
     
    539534    if (olddisk == newdisk) {           /* same drive */
    540535      /* make temporary copy in case move fails */
    541       if (IsFile(fullnewname) != -1 && stricmp(oldname, fullnewname)) {
    542         strcpy(dir, fullnewname);
     536      if (IsFile(newname) != -1 && stricmp(oldname, newname)) {
     537        strcpy(dir, newname);
    543538        p = strrchr(dir, '\\');
    544539        if (p)
     
    546541        strcat(dir, "\\");
    547542        MakeTempName(dir, NULL, 0);
    548         if (DosMove(fullnewname, dir))
     543        if (DosMove(newname, dir))
    549544          *dir = 0;
    550545      }
    551546      DosError(FERR_DISABLEHARDERR);
    552       ret = DosMove(oldname, fullnewname);      /* move it */
     547      ret = DosMove(oldname, newname);      /* move it */
    553548      if (ret && *dir) {                /* failed -- clean up */
    554549        DosError(FERR_DISABLEHARDERR);
    555         if (!DosMove(dir, fullnewname))
     550        if (!DosMove(dir, newname))
    556551          Broadcast((HAB) 0, hwndMain, UM_UPDATERECORD, MPFROMP(dir), MPVOID);
    557552      }
     
    580575    else {                              /* different drives */
    581576      DosError(FERR_DISABLEHARDERR);
    582       ret = DosCopy(oldname, fullnewname, DCPY_EXISTING);       /* <=-NOTE! */
     577      ret = DosCopy(oldname, newname, DCPY_EXISTING);       /* <=-NOTE! */
    583578      if (ret == ERROR_DISK_CHANGE) {
    584579        DosError(FERR_ENABLEHARDERR);
    585         ret = DosCopy(oldname, fullnewname, DCPY_EXISTING);
     580        ret = DosCopy(oldname, newname, DCPY_EXISTING);
    586581        diskchange = TRUE;
    587582      }
    588583      if (ret == ERROR_INVALID_NAME || ret == ERROR_FILENAME_EXCED_RANGE) {
    589         if (TruncName(fullnewname, shortname)) {        /* make 8.3 filename */
     584        if (TruncName(newname, shortname)) {        /* make 8.3 filename */
    590585          DosError(FERR_DISABLEHARDERR);
    591586          ret = DosCopy(oldname, shortname, DCPY_EXISTING);
    592587          if (!ret) {                   /* success -- write longname ea */
    593             WriteLongName(shortname, fullnewname);
    594             strcpy(fullnewname, shortname);
     588            WriteLongName(shortname, newname);
     589            strcpy(newname, shortname);
    595590            /* broadcast fixup msg to windows */
    596591            Broadcast((HAB) 0,
     
    603598        CHAR fixname[CCHMAXPATH];
    604599
    605         strcpy(fixname, fullnewname);
     600        strcpy(fixname, newname);
    606601        p = strrchr(fixname, '\\');
    607602        if (p) {
     
    611606        strcat(fixname, longname);
    612607        DosError(FERR_DISABLEHARDERR);
    613         DosMove(fullnewname, fixname);
    614         strcpy(fullnewname, fixname);
     608        DosMove(newname, fixname);
     609        strcpy(newname, fixname);
    615610        if (zaplong)
    616611          ZapLongName(fixname);
     
    620615      if (!ret) {                       /* double-check success */
    621616        DosError(FERR_DISABLEHARDERR);
    622         rc = DosQueryPathInfo(fullnewname,
     617        rc = DosQueryPathInfo(newname,
    623618                              FIL_STANDARDL, &st2, sizeof(FILESTATUS3L));
    624619        if (rc == ERROR_DISK_CHANGE) {
    625620          DosError(FERR_ENABLEHARDERR);
    626           rc = DosQueryPathInfo(fullnewname,
     621          rc = DosQueryPathInfo(newname,
    627622                                FIL_STANDARDL, &st2, sizeof(FILESTATUS3L));
    628623        }
     
    634629          }
    635630          if (!(st2.attrFile & FILE_DIRECTORY)) /* erase file */
    636             unlinkf("%s", oldname);
     631            unlinkf(oldname);
    637632          else {                        /* remove directory */
    638633            wipeallf("%s\\*", oldname);
     
    650645  case COPY:
    651646    DosError(FERR_DISABLEHARDERR);
    652     ret = DosCopy(oldname, fullnewname, DCPY_EXISTING); /* <=-NOTE! */
     647    ret = DosCopy(oldname, newname, DCPY_EXISTING); /* <=-NOTE! */
    653648    if (ret == ERROR_DISK_CHANGE) {
    654649      DosError(FERR_ENABLEHARDERR);
    655       ret = DosCopy(oldname, fullnewname, DCPY_EXISTING);
     650      ret = DosCopy(oldname, newname, DCPY_EXISTING);
    656651      diskchange = TRUE;
    657652    }
    658653    if (ret == ERROR_INVALID_NAME || ret == ERROR_FILENAME_EXCED_RANGE) {
    659       if (TruncName(fullnewname, shortname)) {
     654      if (TruncName(newname, shortname)) {
    660655        DosError((diskchange) ? FERR_ENABLEHARDERR : FERR_DISABLEHARDERR);
    661656        ret = DosCopy(oldname, shortname, DCPY_EXISTING);
    662657        if (!ret) {
    663           WriteLongName(shortname, fullnewname);
    664           strcpy(fullnewname, shortname);
     658          WriteLongName(shortname, newname);
     659          strcpy(newname, shortname);
    665660          Broadcast((HAB) 0,
    666661                    hwndMain, UM_UPDATERECORD, MPFROMP(shortname), MPVOID);
     
    672667      CHAR fixname[CCHMAXPATH];
    673668
    674       strcpy(fixname, fullnewname);
     669      strcpy(fixname, newname);
    675670      p = strrchr(fixname, '\\');
    676671      if (p) {
     
    680675      strcat(fixname, longname);
    681676      DosError(FERR_DISABLEHARDERR);
    682       DosMove(fullnewname, fixname);
     677      DosMove(newname, fixname);
    683678      if (zaplong)
    684679        ZapLongName(fixname);
     
    901896#endif
    902897
    903 INT unlinkf(CHAR * string, ...)
    904 {
    905   CHAR buffer[CCHMAXPATH];
    906   va_list ap;
    907 
    908   va_start(ap, string);
    909   vsprintf(buffer, string, ap);
    910   va_end(ap);
    911 
    912   if (!strstr(buffer, ArcTempRoot)) {
     898INT unlinkf(CHAR *string)
     899{
     900
     901  if (!strstr(string, ArcTempRoot)) {
    913902    DosError(FERR_DISABLEHARDERR);
    914     if (DosDelete(buffer)) {
    915       make_deleteable(buffer);
     903    if (DosDelete(string)) {
     904      make_deleteable(string);
    916905      DosError(FERR_DISABLEHARDERR);
    917       return DosDelete(buffer);
     906      return DosDelete(string);
    918907    }
    919908  }
    920909  else {
    921910    DosError(FERR_DISABLEHARDERR);
    922     if (DosForceDelete(buffer)) {
    923       make_deleteable(buffer);
     911    if (DosForceDelete(string)) {
     912      make_deleteable(string);
    924913      DosError(FERR_DISABLEHARDERR);
    925       return DosForceDelete(buffer);
     914      return DosForceDelete(string);
    926915    }
    927916  }
Note: See TracChangeset for help on using the changeset viewer.