Changeset 1479


Ignore:
Timestamp:
Nov 15, 2009, 11:40:25 PM (16 years ago)
Author:
Gregg Young
Message:

Work around MMIO's failure to recognize MPG files as media. Reorder file type checks to eliminate problem with MMIO identifying exes etc as media. Check for zero byte file and let user decide to open in an editor or abort (also prevents MMIO misidentification). Tickets 70, 405, 409, 410

Location:
trunk/dll
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/assoc.c

    r1398 r1479  
    2020  19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory and use BldFullPathName
    2121  24 Aug 08 GKY Warn full drive on save of .DAT file; prevent loss of existing file
     22  15 Nov 09 GKY Add check for attempt to open zero byte file (avoids MMPM trying to play them)
    2223
    2324**************************************************************************************/
     
    393394INT ExecAssociation(HWND hwnd, CHAR * datafile)
    394395{
    395   CHAR *file, sig[CCHMAXPATH], sigl[CCHMAXPATH], mask[CCHMAXPATH], *p;
     396  CHAR *file;
     397  CHAR sig[CCHMAXPATH];
     398  CHAR sigl[CCHMAXPATH];
     399  CHAR mask[CCHMAXPATH], *p;
    396400  FILE *fp;
    397   BOOL didmatch, exclude;
     401  BOOL didmatch;
     402  BOOL exclude;
     403  BOOL checked = FALSE;
    398404  ULONG offset;
    399405  LINKASSOC *info;
     
    426432                             strchr(p, ':')) ? datafile : file, p, FALSE);
    427433      if (exclude && didmatch)
    428         didmatch = FALSE;
    429       if (didmatch) {
    430         if (info->sig && *info->sig) {
    431           strcpy(sigl, info->sig);
    432           literal(sigl);
    433           fp = _fsopen(datafile, "rb", SH_DENYNO);
    434           if (fp) {
    435             if (info->offset < 0L) {
    436               fseek(fp, 0L, SEEK_END);
    437               offset = ftell(fp) + info->offset;
    438             }
    439             else
    440               offset = info->offset;
    441             fseek(fp, offset, SEEK_SET);
    442             if (fread(sig,
    443                       1,
    444                       strlen(sigl),
    445                       fp) != strlen(sigl) || strncmp(sigl, sig, strlen(sigl)))
    446               didmatch = FALSE;
    447             fclose(fp);
    448           }
    449         }
     434        didmatch = FALSE;
     435      fp = _fsopen(datafile, "rb", SH_DENYNO);
     436      if (fp) {
     437        if (!checked) {
     438          APIRET temp;
     439 
     440          temp = fread(sig, 1, 2, fp);
     441          if (temp != 2) {
     442            temp = saymsg(MB_YESNO, hwnd, NullStr, GetPString(IDS_ZEROBYTETEXT));
     443            if (temp == MBID_YES) {
     444              DefaultView(hwnd, (HWND) 0, hwndMain, NULL, 8, datafile);
     445            }
     446            fclose(fp);
     447            return 0;
     448          }
     449          else
     450            checked = TRUE;
     451        }
     452        if (didmatch) {
     453          if (info->sig && *info->sig) {
     454            strcpy(sigl, info->sig);
     455            literal(sigl);
     456           
     457              if (info->offset < 0L) {
     458                fseek(fp, 0L, SEEK_END);
     459                offset = ftell(fp) + info->offset;
     460              }
     461              else
     462                offset = info->offset;
     463              fseek(fp, offset, SEEK_SET);
     464              if (fread(sig,
     465                        1,
     466                        strlen(sigl),
     467                        fp) != strlen(sigl) || strncmp(sigl, sig, strlen(sigl)))
     468                didmatch = FALSE;
     469             
     470          }
     471        }
     472        fclose(fp);
    450473      }
    451474      if (didmatch) {                   /* got a match; do it... */
  • trunk/dll/defview.c

    r1402 r1479  
    2222  05 Jan 09 GKY Use TestBinary so that text veiwer isn't used for hex files by default
    2323  08 Mar 09 GKY Additional strings move to PCSZs
     24  15 Nov 09 GKY Add check for attempt to open zero byte file and reorder file type checks
     25                to place exes before MMPM check (avoids MMPM trying to play them)
     26  15 Nov 09 GKY Work around MMIO's falure to identify MPG files as media
    2427
    2528***********************************************************************/
     
    7275  HMODULE MMIOModHandle = NULLHANDLE;
    7376  PMMIOIDENTIFYFILE pMMIOIdentifyFile = NULL;
    74   PMMIOGETINFO pMMIOGetInfo = NULL;
    75   PMMIOCLOSE pMMIOClose = NULL;
    76   PMMIOOPEN pMMIOOpen = NULL;
    77   MMIOINFO mmioinfo;
    78   HMMIO hmmio;
     77  //PMMIOGETINFO pMMIOGetInfo = NULL;
     78  //PMMIOCLOSE pMMIOClose = NULL;
     79  //PMMIOOPEN pMMIOOpen = NULL;
     80  //MMIOINFO mmioinfo;
     81  //HMMIO hmmio;
    7982  FOURCC fccStorageSystem = 0;
    8083  MMFORMATINFO mmFormatInfo;
    81   APIRET rc, rc1;
     84  APIRET rc; // rc1;
    8285  HWND hwnd = HWND_DESKTOP;
    8386  char *p;
     
    101104      return played;
    102105    }
    103     if (DosQueryProcAddr(MMIOModHandle,
     106    /* This code seems to serve no purpose GKY 11-15-09
     107     if (DosQueryProcAddr(MMIOModHandle,
    104108                         0,
    105109                         "mmioGetInfo", (PFN *) & pMMIOGetInfo)) {
     
    121125      no_mmos2 = TRUE;
    122126      return played;
    123     }
     127    }*/
    124128  }
    125129
    126130  /* attempt to identify the file using MMPM/2 */
    127   memset( &mmioinfo, '\0', sizeof(MMIOINFO) );
     131  //memset( &mmioinfo, '\0', sizeof(MMIOINFO) );
    128132  /*Eliminate non multimedia files*/
    129   hmmio = pMMIOOpen(filename,
     133  /*hmmio = pMMIOOpen(filename,
    130134                    &mmioinfo,
    131135                    MMIO_READ);
     
    153157          return played;
    154158  }
    155   rc1 = pMMIOGetInfo(hmmio, &mmioinfo, 0L);
     159  rc1 = pMMIOGetInfo(hmmio, &mmioinfo, 0L);*/
    156160  memset(&mmFormatInfo, 0, sizeof(MMFORMATINFO));
    157161  mmFormatInfo.ulStructLen = sizeof(MMFORMATINFO);
    158162  rc = pMMIOIdentifyFile(filename,
    159                          &mmioinfo,
     163                         0L, //&mmioinfo,
    160164                         &mmFormatInfo,
    161165                         &fccStorageSystem, 0L,
    162166                         MMIO_FORCE_IDENTIFY_FF);
    163167  /* free module handle */
    164   rc1 = pMMIOClose(hmmio, 0L);
     168  //rc1 = pMMIOClose(hmmio, 0L);
    165169  DosFreeModule(MMIOModHandle);
    166170
    167171  /* if identified and not FOURCC_DOS */
    168   if (!rc && mmFormatInfo.fccIOProc != FOURCC_DOS) {
     172  p = strrchr(filename, '.'); //Added to save mp3, ogg & flac which fail above test
     173  if (!p)
     174    p = ".";
     175  if (!rc && (mmFormatInfo.fccIOProc != FOURCC_DOS || !stricmp(p, PCSZ_DOTMPG) ||
     176              !stricmp(p, PCSZ_DOTMPEG))) {  // MPG are identified as FOURCC_DOS
    169177    if (mmFormatInfo.ulMediaType == MMIO_MEDIATYPE_IMAGE &&
    170178        (mmFormatInfo.ulFlags & MMIO_CANREADTRANSLATED)) {
     
    175183            OpenObject(filename, Default, hwnd);  //Image fails to display these
    176184          else       // is an image that can be translated
    177             RunFM2Util("IMAGE.EXE", filename);
     185            RunFM2Util(PCSZ_IMAGEEXE, filename);
    178186          played = TRUE;
    179187    }
     
    311319                          hwndParent, hwndFrame, filename, 4, NULL);
    312320    if (!hwndArc) {
    313       if (!fCheckMM || !ShowMultimedia(filename)) {
    314         if (!IsExecutable(filename) || !ExecFile(hwnd, filename)) {
    315           p = strrchr(filename, '.');
    316           if (!p)
    317             p = ".";
    318           if (stricmp(p, ".INI") || !StartIniEditor(hwndParent, filename, 4)) {
    319             if (stricmp(p, PCSZ_DOTHLP) || !ViewHelp(filename)) {
     321      if (!IsExecutable(filename) || !ExecFile(hwnd, filename)) {
     322        p = strrchr(filename, '.');
     323        if (!p)
     324          p = ".";
     325        if (stricmp(p, ".INI") || !StartIniEditor(hwndParent, filename, 4)) {
     326          if (stricmp(p, PCSZ_DOTHLP) || !ViewHelp(filename)) {
     327            if (!fCheckMM || !stricmp(p, ".DLL") || !ShowMultimedia(filename)) {
    320328            ViewIt:
    321329              if (TestBinary(filename)) {
  • trunk/dll/fm3res.rc

    r1473 r1479  
    4646  15 Sep 09 SHL Add rescan progress messages
    4747  27 Sep 09 SHL Add more items to COMP_MENU
     48  15 Nov 09 GKY Add ZEROBYTETEXT
    4849
    4950***********************************************************************/
     
    24182419    IDS_INIFAILURETEXT                    "Check INI header failed will attempt to replace with backup if backup fails or not found will open with new ini"
    24192420    IDS_HELPCMDTEXT                       "/HELP"
     2421    IDS_ZEROBYTETEXT                      "Zero byte file do you wish to open it in an editor (No cancels)"
    24202422    IDS_DETACHREQUESTTEXT                 "Detach Request"
    24212423    IDS_DIRCNRTOTALHELP                   "This window tells you how many objects\rand how many bytes are in the container.\rYou can drag me (this dir), or drag onto\rme (into this dir)."
  • trunk/dll/fm3str.h

    r1469 r1479  
    3737                inappropriate menu context choices
    3838  15 Sep 09 SHL Add ids for rescan progress messages
     39  15 Nov 09 GKY Add ZEROBYTETEXT (58)
    3940
    4041***********************************************************************/
     
    9899#define IDS_INIFAILURETEXT                                    51
    99100#define IDS_HELPCMDTEXT                                       56
     101#define IDS_ZEROBYTETEXT                                      58
    100102#define IDS_DETACHREQUESTTEXT                                 59
    101103#define IDS_DIRCNRTOTALHELP                                   60
  • trunk/dll/init.c

    r1475 r1479  
    8787                command.com. Prevents hang (at least until a Dos program is started) on a system
    8888                that has a broken MDOS install.
     89  15 Nov 09 GKY Add more PCSZs
    8990
    9091***********************************************************************/
     
    237238PCSZ PCSZ_USERDIRSDAT = "USERDIRS.DAT";
    238239PCSZ PCSZ_FM2PLAYEXE  = "FM2PLAY.EXE";
     240PCSZ PCSZ_IMAGEEXE    = "IMAGE.EXE";
    239241PCSZ PCSZ_FM2PLAYTEMP = "$FM2PLAY.$$$";
    240242PCSZ PCSZ_LVMGUICMD   = "LVMGUI.CMD";
     
    308310PCSZ PCSZ_DOTINF   =  ".INF";
    309311PCSZ PCSZ_DOTMP3   =  ".MP3";
     312PCSZ PCSZ_DOTMPG   =  ".MPG";
     313PCSZ PCSZ_DOTMPEG  =  ".MPEG";
    310314PCSZ PCSZ_DOTOGG   =  ".OGG";
    311315PCSZ PCSZ_DOTFLAC  =  ".FLAC";
     
    11001104  if (DosCreateMutexSem(NULL, &hmtFillingTreeCnr, 0L, FALSE))
    11011105    Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    1102               PCSZ_DOSCREATEMUTEXSEM);
     1106              PCSZ_DOSCREATEMUTEXSEM);
    11031107  if (DosCreateEventSem(NULL, &hevInitialCnrScanComplete, 0L, FALSE))
    11041108    Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
  • trunk/dll/init.h

    r1451 r1479  
    2222                and rescans drive in tree container depending on container focus, greyed out
    2323                inappropriate menu context choices
     24  15 Nov 09 GKY Add more PCSZs
    2425
    2526***********************************************************************/
     
    5051extern PCSZ PCSZ_MINILVMEXE;
    5152extern PCSZ PCSZ_FDISKPMEXE;
     53extern PCSZ PCSZ_IMAGEEXE;
    5254extern PCSZ PCSZ_LVMEXE;
    5355extern PCSZ PCSZ_ARCCNR;
     
    128130extern PCSZ PCSZ_DOTINF;
    129131extern PCSZ PCSZ_DOTMP3;
     132extern PCSZ PCSZ_DOTMPG;
     133extern PCSZ PCSZ_DOTMPEG;
    130134extern PCSZ PCSZ_DOTOGG;
    131135extern PCSZ PCSZ_DOTFLAC;
Note: See TracChangeset for help on using the changeset viewer.