Changeset 1860 for trunk/dll/init.c


Ignore:
Timestamp:
Aug 22, 2015, 4:30:34 AM (10 years ago)
Author:
Steven Levine
Message:

Rework FlesWaitForWorkListEmpty to support wait for parents of path
Add more wrappers for mutex and event semaphores
Clean up some obsolete code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/init.c

    r1859 r1860  
    7878  14 Mar 09 GKY PCSZ strings moved to compile time initialization
    7979  14 Mar 09 GKY Prevent execution of UM_SHOWME while drive scan is occuring replaces check for
    80                 saved drive containers.
     80                saved drive containers.
    8181  06 Jun 09 GKY Add option to show file system type or drive label in tree
    8282  28 Jun 09 GKY Added AddBackslashToPath() to remove repeatative code.
     
    8585  22 Jul 09 GKY Fix failure to restore the notebook setting for saving container states or not
    8686  12 Sep 09 GKY Change protectonly check to check for VKBD being loaded instead of starting
    87                 command.com. Prevents hang (at least until a Dos program is started) on a system
    88                 that has a broken MDOS install.
     87                command.com. Prevents hang (at least until a Dos program is started) on a system
     88                that has a broken MDOS install.
    8989  15 Nov 09 GKY Add more PCSZs
    9090  22 Nov 09 GKY Fix FindSwapperDat so the check for large file support actually occurs if the
    91                 fall back to config.sys is used to find it; use bstripcr to streamline code.
     91                fall back to config.sys is used to find it; use bstripcr to streamline code.
    9292  13 Dec 09 GKY Fixed separate paramenters. Please note that appname should be used in
    93                 profile calls for user settings that work and are setable in more than one
    94                 miniapp; FM3Str should be used for setting only relavent to FM/2 or that
    95                 aren't user settable; realappname should be used for setting applicable to
    96                 one or more miniapp but not to FM/2
     93                profile calls for user settings that work and are setable in more than one
     94                miniapp; FM3Str should be used for setting only relavent to FM/2 or that
     95                aren't user settable; realappname should be used for setting applicable to
     96                one or more miniapp but not to FM/2
    9797  17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR
    98                 CONSTANT * as CHAR *.
     98                CONSTANT * as CHAR *.
    9999  09 MAY 10 JBS Ticket 434: Make fDontSuggestAgain a "global" flag, not a per app flag
    100100  23 Oct 10 GKY Changes to populate and utilize a HELPTABLE for context specific help
    101101  20 Nov 10 GKY Rework scanning code to remove redundant scans, prevent double directory
    102                 entries in the tree container, fix related semaphore performance using
    103                 combination of event and mutex semaphores
     102                entries in the tree container, fix related semaphore performance using
     103                combination of event and mutex semaphores
    104104  20 Nov 10 GKY Check that pTmpDir IsValid and recreate if not found; Fixes hangs caused
    105                 by temp file creation failures.
     105                by temp file creation failures.
    106106  03 Mar 11 SHL Try using FM3INI to create help instance if fm3.hlp not in current directory
    107107  06 Aug 11 GKY Fixed failure to initalize pFM2SaveDirectory if TEMP and TMP were not present
    108                 or invalid
     108                or invalid
    109109  22 Oct 11 GKY Thread notes dialog now reopens on startup if it was open on shutdown.
    110110  08 Jan 12 GKY Add support for changing PresParams in the notify status window
    111111  04 Aug 12 GKY Changes to use Unlock to unlock files if Unlock.exe is in path both from menu/toolbar and as part of
    112                 copy, move and delete operations
     112                copy, move and delete operations
    113113  04 Aug 12 GKY Changes to allow copy and move over readonly files with a warning dialog; also added a warning dialog
    114                 for delete of readonly files
     114                for delete of readonly files
    115115  09 Feb 14 GKY Fix separate parameters. Moved to general page renamed separate settings
    116                 for apps.
     116                for apps.
    117117  09 Feb 14 GKY Modified wipeallf to allow suppression of the readonly warning on delete
    118                 of temporary files
     118                of temporary files
    119119  16 Feb 14 GKY Add "#" command line switch to workaround problem with blank command shell
    120                 started from fm2 after fm2 has been started with stdout and stderr
    121                 redirected to a file.
     120                started from fm2 after fm2 has been started with stdout and stderr
     121                redirected to a file.
    122122  22 Feb 14 GKY Cleanup of readonly check code suppress spurious error on blocked directory
    123                 delete and eliminated the check on additional temp file deletes
     123                delete and eliminated the check on additional temp file deletes
    124124  23 Feb 14 JBS Ticket #515: Corrected a mis-coded call to strtol which was causing the traps
    125                 described in this ticket. (Also changed it to strtoul.)
     125                described in this ticket. (Also changed it to strtoul.)
    126126  01 Mar 14 JBS Ticket #524: Made "searchapath" thread-safe. Function names and signatures were changed.
    127                 So calls to these functions had to be changed.
     127                So calls to these functions had to be changed.
    128128  02 Mar 14 GKY Fixed typo that reversed the function of the saymsg dialog g/bzip check.
    129                 Added option to suppress message regarding missing bzip2.exe
    130                 or gzip.exe on TAR.B/GZ archives.
     129                Added option to suppress message regarding missing bzip2.exe
     130                or gzip.exe on TAR.B/GZ archives.
    131131  30 Aug 14 GKY Add semaphore hmtxFiltering to prevent freeing dcd while filtering. Prevents
    132                 a trap when FM2 is shutdown while directory containers are still populating
     132                a trap when FM2 is shutdown while directory containers are still populating
    133133  02 Aug 15 GKY Serialize local hard drive scanning to reduce drive thrashing continue to scan
    134                 all other drive types in separate threads.
     134                all other drive types in separate threads.
    135135  12 Aug 15 JBS Ticket #522: Ensure no "highmem-unsafe" functions are called directly
    136                 Calls to unsafe Dos... functions have been changed to call the wrapped xDos... functions
     136                Calls to unsafe Dos... functions have been changed to call the wrapped xDos... functions
    137137  19 Aug 15 SHL Delete obsoletes
     138  20 Aug 15 SHL Support PCSZ_DOS...SEM
    138139
    139140***********************************************************************/
     
    336337PCSZ PCSZ_CM_ALLOCRECORD  = "CM_ALLOCRECORD";
    337338PCSZ PCSZ_QUERYCNRINFO    = "CM_QUERYCNRINFO";
    338 PCSZ PCSZ_DOSCREATEMUTEXSEM =  "DosCreateMutexSem";
    339 PCSZ PCSZ_DOSCREATEEVENTSEM =  "DosCreateEventSem";
     339
     340PCSZ PCSZ_DOSCREATEMUTEXSEM = "DosCreateMutexSem";
     341PCSZ PCSZ_DOSREQUESTMUTEXSEM = "DosRequestMutexSem";
     342PCSZ PCSZ_DOSRELEASEMUTEXSEM =  "DosReleaseMutexSem";
     343PCSZ PCSZ_DOSCREATEEVENTSEM = "DosCreateEventSem";
     344PCSZ PCSZ_DOSWAITEVENTSEM = "DosWaitEventSem";
     345PCSZ PCSZ_DOSPOSTEVENTSEM = "DosPostEventSem";
     346PCSZ PCSZ_DOSRESETEVENTSEM = "DosResetEventSem";
     347
    340348PCSZ PCSZ_DOSDUPHANDLE    =  "DosDupHandle";
    341349PCSZ PCSZ_DOSGETINFOBLOCKS = "DosGetInfoBlocks";
     
    812820                        FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
    813821                        FILE_ARCHIVED,
    814                         &ffb, sizeof(ffb), &num_matches, FIL_STANDARD)) {
    815         do {
     822                        &ffb, sizeof(ffb), &num_matches, FIL_STANDARD)) {
     823        do {
    816824          strcpy(enddir, ffb.achName);
    817825          p = strrchr(szTempName, '.');
    818826          if (p) {
    819827            p++;
    820             ul = strtoul(p, NULL, 16);
     828            ul = strtoul(p, NULL, 16);
    821829            GetDosPgmName(ul, temp);
    822830            if (!strstr(temp, "FM/2") &&
     
    826834            }
    827835          }
    828         }
    829         while (!DosFindNext(search_handle,
    830                             &ffb, sizeof(ffb), &num_matches));
    831         DosFindClose(search_handle);
     836        }
     837        while (!DosFindNext(search_handle,
     838                            &ffb, sizeof(ffb), &num_matches));
     839        DosFindClose(search_handle);
    832840      }
    833841      if (fs3.attrFile & FILE_DIRECTORY) {
     
    836844        rc = DosCreateDir(szTempName, 0);
    837845        if (!rc)
    838           pTmpDir = xstrdup(szTempName, pszSrcFile, __LINE__);  // if writable
    839         else
    840           pTmpDir = xstrdup(pFM2SaveDirectory, pszSrcFile, __LINE__);
     846          pTmpDir = xstrdup(szTempName, pszSrcFile, __LINE__);  // if writable
     847        else
     848          pTmpDir = xstrdup(pFM2SaveDirectory, pszSrcFile, __LINE__);
    841849      }
    842850    }
     
    925933      CHAR szFullFilename[CCHMAXPATH];
    926934      if (!SearchMultiplePathsForFile(profile, szFullFilename)) {
    927         strcpy(inipath, szFullFilename);
     935        strcpy(inipath, szFullFilename);
    928936      } else {
    929         strcpy(inipath, profile);
     937        strcpy(inipath, profile);
    930938      }
    931939    } //fixme the DosCopies probably fail if the INI isn't in the FM2 directory GKY 06 Aug 11
     
    936944    if (rc) {
    937945      if (rc == ERROR_FILE_NOT_FOUND) {
    938         DosCopy(PCSZ_FM3INIDOTBAK, PCSZ_FM3DOTINI, 0);
     946        DosCopy(PCSZ_FM3INIDOTBAK, PCSZ_FM3DOTINI, 0);
    939947      }
    940948      rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3));
    941949      if (rc)
    942         fWantFirstTimeInit = TRUE;
     950        fWantFirstTimeInit = TRUE;
    943951    }
    944952    if (!fWantFirstTimeInit) { //Check the ini file header and restore from backup if corupted
    945953      if (!CheckFileHeader(inipath, "\xff\xff\xff\xff\x14\x00\x00\x00", 0L)) {
    946         saymsg(MB_ENTER,HWND_DESKTOP, GetPString(IDS_DEBUG_STRING),
    947                GetPString(IDS_INIFAILURETEXT));
    948         DosCopy(PCSZ_FM3DOTINI, PCSZ_FM3INIDOTBAD, DCPY_EXISTING);
    949         DosCopy(PCSZ_FM3INIDOTBAK, PCSZ_FM3DOTINI, DCPY_EXISTING);
    950         if (!CheckFileHeader(inipath, "\xff\xff\xff\xff\x14\x00\x00\x00", 0L)) {
    951           DosCopy(PCSZ_FM3DOTINI, PCSZ_FM3INIDOTBAD2, DCPY_EXISTING);
    952           fWantFirstTimeInit = TRUE;
    953         }
     954        saymsg(MB_ENTER,HWND_DESKTOP, GetPString(IDS_DEBUG_STRING),
     955               GetPString(IDS_INIFAILURETEXT));
     956        DosCopy(PCSZ_FM3DOTINI, PCSZ_FM3INIDOTBAD, DCPY_EXISTING);
     957        DosCopy(PCSZ_FM3INIDOTBAK, PCSZ_FM3DOTINI, DCPY_EXISTING);
     958        if (!CheckFileHeader(inipath, "\xff\xff\xff\xff\x14\x00\x00\x00", 0L)) {
     959          DosCopy(PCSZ_FM3DOTINI, PCSZ_FM3INIDOTBAD2, DCPY_EXISTING);
     960          fWantFirstTimeInit = TRUE;
     961        }
    954962      }
    955963    }
     
    959967      fIniExisted = TRUE;
    960968      if (fs3.attrFile & (FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM)) {
    961         fs3.attrFile &= ~(FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM);
    962         rc = xDosSetPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3), 0);
    963         if (rc) {
    964           Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    965                       GetPString(IDS_INIREADONLYTEXT), inipath);
    966         }
     969        fs3.attrFile &= ~(FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM);
     970        rc = xDosSetPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3), 0);
     971        if (rc) {
     972          Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     973                      GetPString(IDS_INIREADONLYTEXT), inipath);
     974        }
    967975      }
    968976    }
     
    10101018          hwndHelp = WinCreateHelpInstance(hab, &hini);
    10111019          if (!hwndHelp)
    1012             Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
    1013                       "WinCreateHelpInstance failed for %s with error 0x%x",
    1014                       hini.pszHelpLibraryName, hini.ulReturnCode);
     1020            Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
     1021                      "WinCreateHelpInstance failed for %s with error 0x%x",
     1022                      hini.pszHelpLibraryName, hini.ulReturnCode);
    10151023        }
    10161024      }
     
    11741182  if (rc) {
    11751183    Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    1176               PCSZ_DOSCREATEMUTEXSEM);
     1184              PCSZ_DOSCREATEMUTEXSEM);
    11771185  }
    11781186  rc = DosCreateMutexSem(NULL, &hmtxFM2Delete, 0L, FALSE);
    11791187  if (rc) {
    11801188    Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    1181               PCSZ_DOSCREATEMUTEXSEM);
     1189              PCSZ_DOSCREATEMUTEXSEM);
    11821190  }
    11831191  rc = DosCreateMutexSem(NULL, &hmtxFiltering, 0L, FALSE);
    11841192  if (rc) {
    11851193    Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    1186               PCSZ_DOSCREATEMUTEXSEM);
     1194              PCSZ_DOSCREATEMUTEXSEM);
    11871195  }
    11881196
Note: See TracChangeset for help on using the changeset viewer.