Changeset 1752 for trunk/dll/arccnrs.c


Ignore:
Timestamp:
Mar 2, 2014, 2:39:13 AM (11 years ago)
Author:
Gregg Young
Message:

Fixed error checking in FillArcCnr only to report missing archivers after all entries have been tried. Added a check b/gzip exes for TAR.B/GZ archives. Use the test archive string from the first working archive description. Enhance the error message. Ticket 502 Fix a trap caused by selecting "print" from the arccontainer menu. Ticket 525 Fix the problem with copying text from the test archive window by launching it in a command shell (i.e. comspec /k archiver -t archive) Ticket 503

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/arccnrs.c

    r1749 r1752  
    9494  22 Feb 14 GKY Fix warn readonly yes don't ask to work when recursing directories.
    9595  28 Apr 14 JBS Ticket #522: Ensure use of wrapper functions where needed
     96  01 Mar 14 GKY Fixed error checking in FillArcCnr only to report missing archivers after
     97                all entries have been tried. Added a check b/gzip exes for TAR.B/GZ archives.
     98                Use the test archive string from the first working archive description.
     99                Enhance the error message. Ticket 502
     100  01 Mar 14 GKY Fix a trap caused by selecting "print" from the arccontainer menu. Ticket 525
     101  01 Mar 14 GKY Fix the problem with copying text from the test archive window by launching
     102                it in a command shell (i.e. comspec /k archiver -t archive) Ticket 503
    96103
    97104***********************************************************************/
     
    330337      break;
    331338
    332     case ARCERR_TEST:
     339    case ARCERR_TEST: {
     340      CHAR *comspec;
     341
    333342      ad = WinQueryWindowPtr(hwnd, QWL_USER);
     343      comspec = getenv( "COMSPEC" );
    334344      runemf2(SEPARATEKEEP | WINDOWED | MAXIMIZED,
    335345              hwnd, pszSrcFile, __LINE__, NULL, NULL,
    336               "%s %s",
    337               ad->info->test,
     346              "%s /k %s %s",
     347              comspec, ad->info->test,
    338348              BldQuotedFileName(szQuotedArcName, ad->arcname));
    339349      break;
     350    }
    340351    }
    341352    return 0;
     
    575586  CHAR lonename[CCHMAXPATH + 2],
    576587       *nsize, *osize, *fdate, *fname, *p, *pp, *arctemp;
    577   // Change the DosQueryAppType call below to xDosQueryAppType if "s" is no longer in low memory
     588  CHAR TestStr[CCHMAXPATH * 2];
    578589  CHAR s[CCHMAXPATH * 2];
    579590  BOOL gotstart;
     
    581592  BOOL wasquote;
    582593  BOOL nomove = FALSE;                  // fixme to be gone?
     594  BOOL notest;
     595  BOOL nobzip, ftarbz, nogzip, ftargz;
    583596  INT highest = 0, fieldnum, counter = 0, numarcfiles = 0;
    584597  PARCITEM lastpai;
     
    588601  APIRET rc;
    589602  CHAR *mode;
     603  ULONG cnter = 0;
    590604
    591605  if (!arcname || !arcinfo)
     
    603617           ArcTempRoot);
    604618  MakeTempName(arctemp, ArcTempRoot, 2);
    605 
     619  p = strrchr(arcname, '.');
     620  if (p) {
     621    APIRET temp;
     622
     623    p = p - 3;
     624    nobzip = stricmp(p, "TAR.BZ");
     625    nogzip = stricmp(p, "TAR.GZ");
     626    if (!nobzip) {
     627      ftarbz = TRUE;
     628      if (DosQueryAppType("bzip.exe" , &apptype)) {
     629        nobzip = TRUE;
     630        temp = saymsg(MB_YESNO, HWND_DESKTOP, NullStr, GetPString(IDS_ARCNOBZIP));
     631        if (temp != MBID_NO)
     632          return 0;                                               
     633      }                                                           
     634    }                                                             
     635    else if (!nogzip) {                                           
     636      ftargz = TRUE;                                             
     637      if (DosQueryAppType("gzip.exe" , &apptype)) {
     638        nogzip = TRUE;
     639        temp = saymsg(MB_YESNO, HWND_DESKTOP, NullStr, GetPString(IDS_ARCNOGZIP));
     640        if (temp != MBID_NO)
     641          return 0;
     642      }
     643    }
     644  }
    606645
    607646ReTry:
     
    681720            return 0;
    682721          }
    683           else {
    684             runemf2(SEPARATE | INVISIBLE | MINIMIZED | BACKGROUND | WAIT,
    685                     hwndCnr, pszSrcFile, __LINE__, NULL, NULL,
    686                     "%s %s",
    687                     info->list,
    688                     BldQuotedFileName(s, arcname));
    689             oldstdout = fileno(stdout);
    690             DosError(FERR_DISABLEHARDERR);
    691             DosDupHandle(newstdout, &oldstdout);
    692             DosClose(newstdout);
    693             fclose(fp);
    694           }
     722          else {
     723            rc = 0;
     724            //DbgMsg(pszSrcFile, __LINE__, "Number of tries %i", cnter);
     725            rc = DosQueryAppType(s, &apptype);
     726            if (!rc) {
     727              cnter ++;
     728              runemf2(SEPARATE | INVISIBLE | MINIMIZED | BACKGROUND | WAIT,
     729                      hwndCnr, pszSrcFile, __LINE__, NULL, NULL,
     730                      "%s %s",
     731                      info->list,
     732                      BldQuotedFileName(s, arcname));
     733              if (cnter == 1) {
     734                if (info->test)
     735                  strcpy(TestStr, info->test);
     736                else
     737                  notest = TRUE;
     738              }
     739              else if (notest && info->test) {
     740                strcpy(TestStr, info->test);
     741                notest = FALSE;
     742              }
     743            }
     744            oldstdout = fileno(stdout);
     745            DosError(FERR_DISABLEHARDERR);
     746            DosDupHandle(newstdout, &oldstdout);
     747            DosClose(newstdout);
     748            fclose(fp);
     749          }
    695750        }
    696751      }
     
    889944
    890945      fclose(fp);
    891 
     946      //DbgMsg(pszSrcFile, __LINE__, "Archive check counter %i numarcfiles %i gotstart %i %c",
     947      //       cnter, numarcfiles, gotstart, pStopFlag);
    892948      if (*pStopFlag)
    893949        numarcfiles = 0;                // Request close
     
    899955        CHAR errstr[CCHMAXPATH + 256];
    900956
    901         // Try for alternate archiver
     957        // Try for alternate archiver
    902958        tinfo = info;
    903959        do {
     
    913969        } while (tinfo);
    914970        if (!fAlertBeepOff)
    915           DosBeep(750, 50);             // wake up user
    916         sprintf(errstr, GetPString(IDS_ARCERRORINFOTEXT),
    917                 arcname,
    918                 !gotstart ? GetPString(IDS_NOGOTSTARTTEXT) : NullStr,
    919                 !numarcfiles ? GetPString(IDS_NOARCFILESFOUNDTEXT) :
    920                 NullStr,
    921                 !gotend ? GetPString(IDS_NOENDOFLISTTEXT) : NullStr);
    922         memset(&ad, 0, sizeof(ARCDUMP));
    923         ad.info = info;
    924         strcpy(ad.listname, arctemp);
    925         strcpy(ad.arcname, arcname);
    926         ad.errmsg = errstr;
    927         WinDlgBox(HWND_DESKTOP,
    928                   hwndCnr,
    929                   ArcErrProc, FM3ModHandle, ARCERR_FRAME, MPFROMP(&ad));
     971          DosBeep(750, 50);             // wake up user
     972        if (cnter > 0) {
     973          CHAR Temp[CCHMAXPATH + 2];
     974
     975          sprintf(errstr, GetPString(IDS_ARCERRORINFOTEXT),
     976                  arcname,
     977                  !gotstart ? GetPString(IDS_NOGOTSTARTTEXT) : NullStr,
     978                  !numarcfiles ? GetPString(IDS_NOARCFILESFOUNDTEXT) : NullStr,
     979                  !gotend ? GetPString(IDS_NOENDOFLISTTEXT) : NullStr,
     980                  !notest ? NullStr : GetPString(IDS_ARCNOTEST),
     981                  ftarbz && !nobzip ? GetPString(IDS_ARCBZIPTESTTARBZ) : NullStr,
     982                  ftargz && !nogzip ? GetPString(IDS_ARCGZIPTESTTARGZ) : NullStr);
     983          memset(&ad, 0, sizeof(ARCDUMP));
     984          ad.info = info;                                                   
     985          strcpy(ad.listname, arctemp);                                     
     986          strcpy(ad.arcname, arcname);                                     
     987          if (!notest) {
     988            strcpy(Temp, info->test);
     989            info->test = xstrdup(TestStr, pszSrcFile, __LINE__);
     990          }
     991          else if ((ftarbz && !nobzip) || (ftargz && !nogzip))
     992            info->test = xstrdup(ftarbz ? "bzip.exe -t" : "gzip.exe - t",
     993                                 pszSrcFile, __LINE__);
     994          ad.errmsg = errstr;
     995          WinDlgBox(HWND_DESKTOP,
     996                    hwndCnr,
     997                    ArcErrProc, FM3ModHandle, ARCERR_FRAME, MPFROMP(&ad));
     998          if (!notest)
     999            info->test = xstrdup(Temp, pszSrcFile, __LINE__);
     1000          else if ((ftarbz && !nobzip) || (ftargz && !nogzip))
     1001            info->test = xstrdup("", pszSrcFile, __LINE__);
     1002        }
     1003        else
     1004          saymsg(MB_OK, HWND_DESKTOP, GetPString(IDS_ARCMISSINGEXE),
     1005                 GetPString(IDS_ARCMISSINGEXEVERBOSE));
    9301006      }
    9311007      else if (!nomove && tinfo) {
    932         // if we got a false hit, move working hit to top
    933         tinfo = info->next;
     1008        // if we got a false hit, move working hit to top                   
     1009        tinfo = info->next;                                                 
    9341010        info->next = arcsighead;
    9351011        arcsighead->prev = info;
     
    18921968                      li->type == IDM_OPENDEFAULT ||
    18931969                      li->type == IDM_OPENSETTINGS ||
    1894                       (li->type == IDM_EDITBINARY &&            // JBS No way for this () to be true??
    1895                        li->type == IDM_MCIPLAY)) &&
     1970                      (li->type == IDM_EDITBINARY ||            // JBS No way for this () to be true??
     1971                       li->type == IDM_MCIPLAY)) ||
    18961972                     !li->info->exwdirs)) ?
    18971973                     li->info->extract :
     
    21982274        } // switch
    21992275      }
    2200       if (li->type != IDM_OPENDEFAULT && li->type != IDM_OPENSETTINGS)
     2276      if (li && li->type != IDM_OPENDEFAULT && li->type != IDM_OPENSETTINGS)
    22012277      {
    22022278        FreeListInfo(li);
     
    26682744          WinEnableMenuItem((HWND) mp2,
    26692745                            IDM_DELETE, dcd->info->delete != NULL);
    2670           WinEnableMenuItem((HWND) mp2, IDM_TEST, dcd->info->test != NULL);
    2671           WinEnableMenuItem((HWND) mp2,
    2672                             IDM_EXTRACT, dcd->info->extract != NULL);
     2746          WinEnableMenuItem((HWND) mp2, IDM_TEST, dcd->info->test != NULL);
     2747          WinEnableMenuItem((HWND) mp2, IDM_EXTRACT,
     2748                            dcd->info->extract != NULL && !strstr(dcd->info->ext, "TAR"));
     2749          WinEnableMenuItem((HWND) mp2, IDM_ARCEXTRACT,
     2750                            dcd->info->extract != NULL && !strstr(dcd->info->ext, "TAR"));
    26732751          WinEnableMenuItem((HWND) mp2,
    26742752                            IDM_EXTRACTWDIRS, dcd->info->exwdirs != NULL);
     
    26822760
    26832761      case IDM_VIEWSMENU:
     2762        WinEnableMenuItem((HWND) mp2, IDM_TEST, dcd->info->test != NULL);
     2763        WinEnableMenuItem((HWND) mp2, IDM_ARCEXTRACT,
     2764                            dcd->info->extract != NULL && !strstr(dcd->info->ext, "TAR"));
    26842765        WinCheckMenuItem((HWND) mp2,
    26852766                         IDM_MINIICONS, (dcd->flWindowAttr & CV_MINI) != 0);
     
    36893770            strcpy(dcd->directory, extractpath);
    36903771        }
    3691         // Removed because it can't be set from inside the container and names with a space
    3692         // break it. I don't think it makes sense from the container any way GKY 8-10-13
    3693         /*if (!*dcd->directory && fFileNameCnrPath && dcd->arcname) {
    3694           strcpy(fullname, dcd->arcname);
    3695           p = strrchr(fullname, '.');
    3696           if (p) {
    3697             *p = 0;
    3698           }
    3699           else {
    3700             p = fullname + strlen(fullname);
    3701             p--;
    3702             *p = 0;
    3703           }
    3704           strcpy(dcd->directory, fullname);
    3705         } */
    37063772        if (!*dcd->directory && *lastextractpath) {
    37073773          //DosEnterCritSec();  //GKY 11-29-08
Note: See TracChangeset for help on using the changeset viewer.