Changeset 1112 for trunk/dll


Ignore:
Timestamp:
Aug 24, 2008, 5:13:20 AM (17 years ago)
Author:
Gregg Young
Message:

Check free space on TMP & FM2 save directory drives at start up (Ticket 268)

Location:
trunk/dll
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/fm3dll.h

    r1089 r1112  
    545545void SetupWinList(HWND hwndMenu, HWND hwndTop, HWND hwndFrame);
    546546BOOL SwitchCommand(HWND hwndMenu, USHORT cmd);
     547INT CheckDriveSpaceAvail(CHAR *pTargetPath, ULONGLONG ullSpaceNeeded,
     548                         ULONGLONG ullFreeSpaceWhenComplete);
    547549
    548550/* mainwnd.c */
     
    11901192
    11911193DATADEF ULONG ulCnrType, FilesToGet, AutoviewHeight, TreeWidth, FM3UL;
     1194DATADEF ULONGLONG ullTmpSpaceNeeded;
    11921195DATADEF long prnwidth, prnlength, prntmargin, prnbmargin, prnlmargin,
    11931196  prnrmargin, prnspacing, prntabspaces;
  • trunk/dll/fm3dll.str

    r1070 r1112  
    8585 [Rescan suggested]
    8686Dri~ves...
    87 
    88 
    89 
    90 
    91 
    92 
     87The target path %s will have less then %s bytes of space remaining following this operation. Do you wish to continue?
     88The TMP directory %s has less then %s of space. Do you wish to use the FM/2 save directory for temporary files? In any case you should free some space on this drive
     89The TMP directory %s has less then %s of space & The FM/2 save directory %s has less then %s of space. You should free some space on these drives
     90The FM2 save directory %s has less then %s of space. You should free some space on this drive
     91The target path %s will have less then %s bytes of space remaining following this operation. You should free some space on this drive immediately
     92The target path %s has inadequate space remaining for the operation requested. Free some space and try again.
    9393
    9494/OPEN
  • trunk/dll/fm3str.h

    r1070 r1112  
    116116#define IDS_RESCANSUGGESTEDTEXT                               84
    117117#define IDS_DRIVESMENUTEXT                                    85
     118#define IDS_DRIVESPACELIMITED                                 86
     119#define IDS_TMPDRIVESPACELIMITED                              87
     120#define IDS_SAVETMPDRIVESPACELIMITED                          88
     121#define IDS_SAVEDRIVESPACELIMITED                             89
     122#define IDS_DRIVESPACELIMITEDTMPSAVE                          90
     123#define IDS_DRIVESPACEEXCEEDED                                91
    118124#define IDS_OPENCMDTEXT                                       93
    119125#define IDS_CLOSECMDTEXT                                      94
  • trunk/dll/init.c

    r1104 r1112  
    5555  20 Jul 08 GKY Add support to delete orphaned tmp directories without deleting tmp of other
    5656                running sessions
     57  23 Aug 08 GKY Check that space on TMP & FM2 save drives exceed 5 GiB; Done to allow user setting of
     58                minimum size in future
    5759
    5860***********************************************************************/
     
    716718    }
    717719  }
    718   BldFullPathName(ArcTempRoot, pTmpDir, fAmAV2 ? "$AV$ARC$" : "$FM$ARC$");
    719720
    720721  //Save the FM2 save directory name. This is the location of the ini, dat files etc.
     
    724725    pFM2SaveDirectory = xstrdup(temp, pszSrcFile, __LINE__);
    725726  }
     727  {
     728    CHAR szKBTmp[20];
     729
     730    ullTmpSpaceNeeded = 5120000;
     731    CommaFmtULL(szKBTmp, sizeof(szKBTmp),
     732                ullTmpSpaceNeeded, 'M');
     733    printf("%s\r", szKBTmp); fflush(stdout);
     734    if (pTmpDir && CheckDriveSpaceAvail(pTmpDir, ullTmpSpaceNeeded, 0) == 1) {
     735      if (CheckDriveSpaceAvail(pFM2SaveDirectory, ullTmpSpaceNeeded, 0) == 0){
     736        ret = saymsg(MB_YESNO,
     737                     HWND_DESKTOP,
     738                     NullStr,
     739                     GetPString(IDS_TMPDRIVESPACELIMITED),
     740                     pTmpDir,
     741                     szKBTmp);
     742        if (ret == MBID_YES)
     743          pTmpDir = pFM2SaveDirectory;
     744      }
     745      else
     746        saymsg(MB_OK,
     747               HWND_DESKTOP,
     748               NullStr,
     749               GetPString(IDS_SAVETMPDRIVESPACELIMITED),
     750               pTmpDir,
     751               szKBTmp,
     752               pFM2SaveDirectory,
     753               szKBTmp);
     754    }
     755    else if (CheckDriveSpaceAvail(pFM2SaveDirectory, ullTmpSpaceNeeded, 0) == 1)
     756      saymsg(MB_OK,
     757             HWND_DESKTOP,
     758             NullStr,
     759             GetPString(IDS_SAVEDRIVESPACELIMITED),
     760             pFM2SaveDirectory,
     761             szKBTmp);
     762  }
     763  BldFullPathName(ArcTempRoot, pTmpDir, fAmAV2 ? "$AV$ARC$" : "$FM$ARC$");
    726764
    727765  // initialize random number generator
  • trunk/dll/misc.c

    r1106 r1112  
    5151  20 Jul 08 GKY Add save/append filename to clipboard.
    5252                Change menu wording to make these easier to find
     53  23 Aug 08 GKY Add CheckDriveSpaceAvail To pre check drive space to prevent failures
    5354
    5455***********************************************************************/
     
    22162217}
    22172218
     2219/** CheckDriveSpaceAvail
     2220 *  Take space needed and checks that drive has at least 1000 bits in excess of the required space.
     2221 *  Returns 0 if sufficient space is available; 1 if the drive is full & 2 on abort of operation
     2222 *  when the drive would have less than ullFreeSpaceWhenComplete remaining or has insufficient space.
     2223 */
     2224
     2225INT CheckDriveSpaceAvail(CHAR *pTargetPath, ULONGLONG ullSpaceNeeded,
     2226                          ULONGLONG ullFreeSpaceWhenComplete)
     2227{
     2228  FSALLOCATE fsa;
     2229  ULONGLONG  ullFreeQty;
     2230  APIRET ret;
     2231
     2232  DosQueryFSInfo(toupper(*pTargetPath) - 'A' + 1, FSIL_ALLOC, &fsa, sizeof(FSALLOCATE));
     2233  ullFreeQty = (ULONGLONG) fsa.cUnitAvail * (fsa.cSectorUnit * fsa.cbSector);
     2234  if (ullFreeQty > ullSpaceNeeded + ullFreeSpaceWhenComplete)
     2235    return 0;
     2236  else if (ullFreeQty < ullSpaceNeeded + 1024) {
     2237    CHAR szKB[20];
     2238
     2239    if (ullFreeSpaceWhenComplete == 0)
     2240      ullSpaceNeeded = 0;
     2241    commafmt(szKB, sizeof(szKB),
     2242             (ULONG) ullFreeQty - ullSpaceNeeded);
     2243    if (ullFreeSpaceWhenComplete == 0) {
     2244      saymsg(MB_OK,
     2245             HWND_DESKTOP,
     2246             NullStr,
     2247             GetPString(IDS_DRIVESPACELIMITEDTMPSAVE),
     2248             pTargetPath,
     2249             szKB);
     2250      return 0;
     2251    }
     2252    else {
     2253      if (ullFreeQty - ullSpaceNeeded > 0) {
     2254        ret = saymsg(MB_YESNO,
     2255                     HWND_DESKTOP,
     2256                     NullStr,
     2257                     GetPString(IDS_DRIVESPACELIMITED),
     2258                     pTargetPath,
     2259                     szKB);
     2260        if (ret == MBID_YES)
     2261          return 0;
     2262        else
     2263          return 2;
     2264      }
     2265      else {
     2266        saymsg(MB_OK,
     2267               HWND_DESKTOP,
     2268               NullStr,
     2269               GetPString(IDS_DRIVESPACEEXCEEDED),
     2270               pTargetPath);
     2271        return 2;
     2272      }
     2273    }
     2274  }
     2275  else
     2276    return 1;
     2277}
     2278
    22182279#pragma alloc_text(MAINWND5,SetSysMenu)
    22192280#pragma alloc_text(MISC1,BoxWindow,PaintRecessedWindow,PostMsg,PaintSTextWindow,IsFm2Window)
    22202281#pragma alloc_text(MISC1,FixSwitchList,FindDirCnr,CurrentRecord,SetShiftState,AddToListboxBottom)
     2282#pragma alloc_text(MISC1,CheckDriveSpaceAvail)
    22212283
    22222284#ifdef FORTIFY
Note: See TracChangeset for help on using the changeset viewer.