Changeset 36 for trunk/dll/datamin.c
- Timestamp:
- Oct 17, 2002, 3:53:23 AM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/datamin.c
r30 r36 10 10 11 11 Revisions 14 Sep 02 SHL - Handle large partitions 12 16 Oct 02 SHL - Handle large partitions better 12 13 13 14 ***********************************************************************/ … … 618 619 case UM_PAINT: 619 620 { 620 CHAR s[90], tpm[38],*kfree,path[] = " :",621 CHAR s[90],szFreeQty[38],*pszFreeUM,path[] = " :", 621 622 *szBuf = NULL,*FSystem = NULL; 622 ULONG freebytes,percentfree,wasx,size; 623 ULONG cbPerUnit; 624 UINT cShift; 623 float fltFreeQty; 624 ULONG percentfree,wasx,size; 625 625 HPS hps = (HPS)mp2; 626 626 FSALLOCATE fsa; … … 637 637 if(!WinQueryWindowPos(hwndTemp,&swp)) 638 638 return 0; 639 * tpm= 0;639 *szFreeQty = 0; 640 640 DosError(FERR_DISABLEHARDERR); 641 641 if(!DosQueryFSInfo((id - MINI_DRIVEA) + 1, … … 643 643 &fsa, 644 644 sizeof(FSALLOCATE))) { 645 // Scale to avoid overflow on large drives 646 cbPerUnit = fsa.cSectorUnit * fsa.cbSector; 647 for (cShift = 0; cbPerUnit && ~cbPerUnit & 1 && cShift < 20; cShift++) 648 cbPerUnit >>= 1; 649 freebytes = fsa.cUnitAvail * cbPerUnit; // Scaled by cShift 650 if (freebytes >= (1024 * 1024) >> cShift) { 651 freebytes /= (1024 * 1024) >> cShift; 652 kfree = "mb"; 653 } 654 else if (freebytes << cShift >= 1024) { 655 freebytes <<= cShift; 656 freebytes /= 1024; 657 kfree = "kb"; 645 fltFreeQty = (float)fsa.cUnitAvail * (fsa.cSectorUnit * fsa.cbSector); 646 if (fltFreeQty >= (1024 * 1024)) { 647 fltFreeQty /= (1024 * 1024); 648 pszFreeUM = "mb"; 649 } 650 else if (fltFreeQty >= 1024) { 651 fltFreeQty /= 1024; 652 pszFreeUM = "kb"; 658 653 } 659 654 else 660 { 661 freebytes <<= cShift; 662 kfree = "b"; 663 } 655 { 656 pszFreeUM = "b"; 657 } 664 658 percentfree = (fsa.cUnit && fsa.cUnitAvail) ? 665 (fsa.cUnitAvail * 100) / fsa.cUnit : 0;666 commafmt( tpm,sizeof(tpm),freebytes);659 (fsa.cUnitAvail * 100) / fsa.cUnit : 0; 660 commafmt(szFreeQty,sizeof(szFreeQty),(ULONG)fltFreeQty); 667 661 *path = (CHAR)(id - MINI_DRIVEA) + 'A'; 668 662 if(!DosAllocMem((PVOID)&szBuf, … … 687 681 " %s %s%s (%lu%%) %s%s%s%s", 688 682 path, 689 tpm,690 kfree,683 szFreeQty, 684 pszFreeUM, 691 685 percentfree, 692 686 GetPString(IDS_FREETEXT), … … 870 864 case UM_SETUP2: 871 865 { 872 CHAR s[134],tm[38],tpm[38],*tmk,*tpmk; 873 FILEFINDBUF3 ffb; 874 ULONG nm = 1L; 875 HDIR hdir = HDIR_CREATE; 876 FSALLOCATE fsa; 866 CHAR s[134],szFileQty[38],szFreeQty[38],*pszFileUM,*pszFreeUM; 867 FILEFINDBUF3 ffb; 868 ULONG nm = 1L; 869 float fltFreeQty; 870 HDIR hdir = HDIR_CREATE; 871 FSALLOCATE fsa; 877 872 878 873 if(*SwapperDat) { … … 883 878 priority_bumped(); 884 879 DosFindClose(hdir); 885 * tm = *tpm= 0;880 *szFileQty = *szFreeQty = 0; 886 881 DosError(FERR_DISABLEHARDERR); 887 882 if(!DosQueryFSInfo(toupper(*SwapperDat) - '@',FSIL_ALLOC, 888 883 &fsa,sizeof(FSALLOCATE))) { 889 nm= fsa.cUnitAvail * (fsa.cSectorUnit * fsa.cbSector);890 if( nm> 1024 * 1024) {891 tpmk= "mb";892 commafmt(tpm,sizeof(tpm),nm / (1024 * 1024));884 fltFreeQty = fsa.cUnitAvail * (fsa.cSectorUnit * fsa.cbSector); 885 if(fltFreeQty > 1024 * 1024) { 886 pszFreeUM = "mb"; 887 fltFreeQty /= (1024 * 1024); 893 888 } 894 else if( nm> 1024) {895 tpmk= "kb";896 commafmt(tpm,sizeof(tpm),nm / 1024);889 else if(fltFreeQty > 1024) { 890 pszFreeUM = "kb"; 891 fltFreeQty /= 1024; 897 892 } 898 893 else { 899 tpmk = "b"; 900 commafmt(tpm,sizeof(tpm),nm); 894 pszFreeUM = "b"; 901 895 } 896 commafmt(szFreeQty,sizeof(szFreeQty),(ULONG)fltFreeQty); 902 897 } 903 898 if(ffb.cbFile > 1024 * 1024) { 904 tmk= "mb";905 commafmt( tm,sizeof(tm),ffb.cbFile / (1024 * 1024));899 pszFileUM = "mb"; 900 commafmt(szFileQty,sizeof(szFileQty),ffb.cbFile / (1024 * 1024)); 906 901 } 907 902 else if(ffb.cbFile > 1024) { 908 tmk= "kb";909 commafmt( tm,sizeof(tm),ffb.cbFile / 1024);903 pszFileUM = "kb"; 904 commafmt(szFileQty,sizeof(szFileQty),ffb.cbFile / 1024); 910 905 } 911 906 else { 912 tmk= "b";913 commafmt( tm,sizeof(tm),ffb.cbFile);907 pszFileUM = "b"; 908 commafmt(szFileQty,sizeof(szFileQty),ffb.cbFile); 914 909 } 915 910 sprintf(s," %s %s%s%s%s%s", 916 911 GetPString(IDS_SWAPTITLETEXT), 917 tm,918 tmk,919 (* tpm) ? "/" : NullStr,920 tpm,921 (* tpm) ? tpmk: NullStr);912 szFileQty, 913 pszFileUM, 914 (*szFreeQty) ? "/" : NullStr, 915 szFreeQty, 916 (*szFreeQty) ? pszFreeUM : NullStr); 922 917 WinSetDlgItemText(hwnd, 923 918 MINI_SWAP, … … 930 925 case UM_SETUP3: 931 926 { 932 CHAR s[134],tm[38], tpm[38],*tpmk,*tmk;927 CHAR s[134],tm[38],szQty[38],*pszUM,*tmk; 933 928 ULONG amem = 0; 934 929 935 930 if(!DosQuerySysInfo(QSV_TOTAVAILMEM,QSV_TOTAVAILMEM, 936 931 (PVOID)&amem,(ULONG)sizeof(amem))) { 937 *tm = * tpm= 0;932 *tm = *szQty = 0; 938 933 if(amem > 1024 * 1024) { 939 934 tmk = "mb"; … … 950 945 if(!Dos16MemAvail(&amem)) { 951 946 if(amem > 1024 * 1024) { 952 tpmk= "mb";953 commafmt( tpm,sizeof(tpm),amem / (1024 * 1024));947 pszUM = "mb"; 948 commafmt(szQty,sizeof(szQty),amem / (1024 * 1024)); 954 949 } 955 950 else if(amem > 1024) { 956 tpmk= "kb";957 commafmt( tpm,sizeof(tpm),amem / 1024);951 pszUM = "kb"; 952 commafmt(szQty,sizeof(szQty),amem / 1024); 958 953 } 959 954 else { 960 tpmk= "b";961 commafmt( tpm,sizeof(tpm),amem);955 pszUM = "b"; 956 commafmt(szQty,sizeof(szQty),amem); 962 957 } 963 958 } 964 959 sprintf(s," %s%s%s%s%s%s", 965 960 GetPString(IDS_MEMTITLETEXT), 966 tpm,967 (* tpm) ? tpmk: NullStr,968 (* tpm) ? "/" : NullStr,961 szQty, 962 (*szQty) ? pszUM : NullStr, 963 (*szQty) ? "/" : NullStr, 969 964 tm, 970 965 tmk); … … 994 989 case UM_SETUP5: 995 990 { 996 CHAR s[134],tm[38], tpm[38];991 CHAR s[134],tm[38],szQty[38]; 997 992 998 993 if(fUseQProcStat && !noqproc) { … … 1018 1013 ppi = (PPROCESSINFO)(ppi->ptiFirst + ppi->usThreadCount); 1019 1014 } 1020 * tpm= *tm = 0;1021 commafmt( tpm,sizeof(tpm),numprocs);1015 *szQty = *tm = 0; 1016 commafmt(szQty,sizeof(szQty),numprocs); 1022 1017 commafmt(tm,sizeof(tm),numthreads); 1023 1018 sprintf(s, 1024 1019 " %s%s %s%s", 1025 1020 GetPString(IDS_PROCSTITLETEXT), 1026 tpm,1021 szQty, 1027 1022 GetPString(IDS_THRDSTITLETEXT), 1028 1023 tm); … … 1037 1032 } 1038 1033 else { 1039 * tpm= 0;1040 commafmt( tpm,sizeof(tpm),1034 *szQty = 0; 1035 commafmt(szQty,sizeof(szQty), 1041 1036 WinQuerySwitchList(WinQueryAnchorBlock(hwnd),(PSWBLOCK)0,0)); 1042 1037 sprintf(s, 1043 1038 " %s%s", 1044 1039 GetPString(IDS_TASKSTITLETEXT), 1045 tpm);1040 szQty); 1046 1041 WinSetDlgItemText(hwnd, 1047 1042 MINI_PROC,
Note:
See TracChangeset
for help on using the changeset viewer.