Changeset 1603


Ignore:
Timestamp:
Aug 6, 2011, 11:20:56 PM (14 years ago)
Author:
Gregg Young
Message:

If both TEMP and TMP environment variables are missing or point to invalid directories the FM2SaveDirectory doesn't get set. This fixes it and probably the trap in Ticket 468

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/init.c

    r1560 r1603  
    637637  PSZ env;
    638638  CHAR dllfile[CCHMAXPATH];
     639  CHAR temp[CCHMAXPATH];
    639640  ULONG size;
    640641  BOOL fSeparateParmsApp;
     
    717718  }
    718719
     720  //Save the FM2 save directory name. This is the location of the ini, dat files etc.
     721  save_dir2(temp);
     722  pFM2SaveDirectory = xstrdup(temp, pszSrcFile, __LINE__);
    719723  // set up default root names for temp file storage and archive goodies
    720724  env = getenv("TMP");
     
    725729    rc = DosQueryPathInfo(env, FIL_STANDARD, &fs3, sizeof(fs3));
    726730    if (!rc) {
    727       CHAR *enddir, *p, szTempName[CCHMAXPATH], temp[CCHMAXPATH];
     731      CHAR *enddir, *p, szTempName[CCHMAXPATH];
    728732      FILEFINDBUF3 ffb;
    729733      HDIR search_handle;
    730734      ULONG num_matches, ul;
    731735
    732       //Save the FM2 save directory name. This is the location of the ini, dat files etc.
    733       save_dir2(temp);
    734       pFM2SaveDirectory = xstrdup(temp, pszSrcFile, __LINE__);
    735736      strcpy(szTempName, env);
    736737      AddBackslashToPath(szTempName);
    737       //if (szTempName[strlen(szTempName) - 1] != '\\')
    738       //  strcat(szTempName, "\\");
    739738      enddir = &szTempName[strlen(szTempName)];
    740739      strcat(szTempName, "$FM2????.");
     
    747746                        FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
    748747                        FILE_ARCHIVED,
    749                         &ffb, sizeof(ffb), &num_matches, FIL_STANDARD)) {
    750         do {
     748                        &ffb, sizeof(ffb), &num_matches, FIL_STANDARD)) {
     749        do {
    751750          strcpy(enddir, ffb.achName);
    752751          p = strrchr(szTempName, '.');
     
    761760            }
    762761          }
    763         }
    764       while (!DosFindNext(search_handle,
    765                           &ffb, sizeof(ffb), &num_matches));
    766       DosFindClose(search_handle);
    767     }
     762        }
     763        while (!DosFindNext(search_handle,
     764                            &ffb, sizeof(ffb), &num_matches));
     765        DosFindClose(search_handle);
     766      }
    768767      if (fs3.attrFile & FILE_DIRECTORY) {
    769768        strcpy(szTempName, env);
     
    773772          pTmpDir = xstrdup(szTempName, pszSrcFile, __LINE__);  // if writable
    774773        else
    775           pTmpDir = xstrdup(pFM2SaveDirectory, pszSrcFile, __LINE__);
    776         }
     774          pTmpDir = xstrdup(pFM2SaveDirectory, pszSrcFile, __LINE__);
    777775      }
    778776    }
     777  }
     778  else
     779    pTmpDir = xstrdup(pFM2SaveDirectory, pszSrcFile, __LINE__);
    779780  // Check free space on TMP and FM2 Save drives
    780781  {
    781     //ullTmpSpaceNeeded = 5120000;
    782782    if (pTmpDir && CheckDriveSpaceAvail(pTmpDir, ullTmpSpaceNeeded, 0) == 1) {
    783783      if (CheckDriveSpaceAvail(pFM2SaveDirectory, ullTmpSpaceNeeded, 0) == 0){
Note: See TracChangeset for help on using the changeset viewer.