Changeset 1155 for trunk/dirsize.c


Ignore:
Timestamp:
Sep 5, 2008, 11:38:38 PM (17 years ago)
Author:
John Small
Message:

Ticket 187: Draft 1: Functions only

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dirsize.c

    r1055 r1155  
    2424#include "dirsize.h"
    2525#include "dll\fm3dll.h"
     26#include "dll\dirsize.h"                        // DirSizeProc
    2627
    2728MRESULT EXPENTRY DirMainProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     
    4950
    5051      for (x = 2; x < 26; x++) {
    51         if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) {
    52           *dirname = (CHAR) x + 'A';
    53           WinSendDlgItemMsg(hwnd, DIRSIZE_LISTBOX, LM_INSERTITEM,
    54                             MPFROM2SHORT(LIT_END, 0), MPFROMP(dirname));
    55           if (first) {
    56             WinSendDlgItemMsg(hwnd, DIRSIZE_LISTBOX, LM_SELECTITEM,
    57                               MPFROMSHORT(0), MPFROMSHORT(TRUE));
    58             first = FALSE;
    59           }
    60         }
     52        if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) {
     53          *dirname = (CHAR) x + 'A';
     54          WinSendDlgItemMsg(hwnd, DIRSIZE_LISTBOX, LM_INSERTITEM,
     55                            MPFROM2SHORT(LIT_END, 0), MPFROMP(dirname));
     56          if (first) {
     57            WinSendDlgItemMsg(hwnd, DIRSIZE_LISTBOX, LM_SELECTITEM,
     58                              MPFROMSHORT(0), MPFROMSHORT(TRUE));
     59            first = FALSE;
     60          }
     61        }
    6162      }
    6263    }
     
    7374      struct
    7475      {
    75         ULONG serial;
    76         CHAR volumelength;
    77         CHAR volumelabel[CCHMAXPATH];
     76        ULONG serial;
     77        CHAR volumelength;
     78        CHAR volumelabel[CCHMAXPATH];
    7879      }
    7980      volser;
     
    9091      WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "");
    9192      WinSendDlgItemMsg(hwnd, DIRSIZE_SLIDER, SLM_SETSLIDERINFO,
    92                         MPFROM2SHORT(SMA_SLIDERARMPOSITION,
    93                                      SMA_INCREMENTVALUE), MPFROMSHORT(0));
     93                        MPFROM2SHORT(SMA_SLIDERARMPOSITION,
     94                                     SMA_INCREMENTVALUE), MPFROMSHORT(0));
    9495      removable = CheckDrive(toupper(*curdir), FileSystem, &type);
    9596      if (removable != -1) {
    96         if (type & DRIVE_ZIPSTREAM)
    97           WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Zipstream drive");
    98         else if (type & DRIVE_REMOTE)
    99           WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Remote drive");
    100         else if (type & DRIVE_VIRTUAL)
    101             WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Virtual drive");
    102         else if (type & DRIVE_RAMDISK)
    103           WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Ramdisk");
    104         else {
    105           sprintf(s, "Local drive%s", (removable) ? " (removable)" : "");
    106           WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, s);
    107         }
    108         sprintf(s, "IFS:  %s", FileSystem);
    109         WinSetDlgItemText(hwnd, DIRSIZE_IFS, s);
    110         memset(&volser, 0, sizeof(volser));
    111         DosError(FERR_DISABLEHARDERR);
    112         if (!DosQueryFSInfo(toupper(*curdir) - '@', FSIL_VOLSER,
    113                             &volser, (ULONG) sizeof(volser))) {
    114           sprintf(s, "Label:  %s", volser.volumelabel);
    115           WinSetDlgItemText(hwnd, DIRSIZE_LABEL, s);
    116         }
    117         if (!DosQueryFSInfo(toupper(*curdir) - '@',
    118                             FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
    119           percentfree = fsa.cUnit ? (USHORT)((fsa.cUnitAvail * 100) / fsa.cUnit) : 0;   // 27 May 08 SHL
    120           if (!percentfree && fsa.cUnitAvail)
    121             percentfree = 1;
    122           percentused = 100 - percentfree;
    123           sprintf(s, "Units free:  %lu", fsa.cUnitAvail);
    124           WinSetDlgItemText(hwnd, DIRSIZE_UNITSFREE, s);
    125           sprintf(s, "Unit size:  %lu x %u = %lu",
    126                   fsa.cSectorUnit,
    127                   fsa.cbSector, fsa.cSectorUnit * fsa.cbSector);
    128           WinSetDlgItemText(hwnd, DIRSIZE_UNITSIZE, s);
    129           sprintf(s, "Units used:  %lu", fsa.cUnit - fsa.cUnitAvail);
    130           WinSetDlgItemText(hwnd, DIRSIZE_UNITSUSED, s);
    131           sprintf(s, "Bytes free:  %.0f",
    132                   (float)fsa.cUnitAvail * (fsa.cSectorUnit * fsa.cbSector));
    133           WinSetDlgItemText(hwnd, DIRSIZE_BYTESFREE, s);
    134           sprintf(s, "Bytes used:  %.0f",
    135                   (float)(fsa.cUnit - fsa.cUnitAvail) *
    136                   (fsa.cSectorUnit * fsa.cbSector));
    137           WinSetDlgItemText(hwnd, DIRSIZE_BYTESUSED, s);
    138           sprintf(s, "Percent used:  %u%%", percentused);
    139           WinSetDlgItemText(hwnd, DIRSIZE_PERCENT, s);
    140           WinSendDlgItemMsg(hwnd, DIRSIZE_SLIDER, SLM_SETSLIDERINFO,
    141                             MPFROM2SHORT(SMA_SLIDERARMPOSITION,
    142                                         SMA_INCREMENTVALUE),
    143                             MPFROMSHORT(percentused));
    144           WinShowWindow(WinWindowFromID(hwnd, DIRSIZE_SLIDER), TRUE);
    145         }
     97        if (type & DRIVE_ZIPSTREAM)
     98          WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Zipstream drive");
     99        else if (type & DRIVE_REMOTE)
     100          WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Remote drive");
     101        else if (type & DRIVE_VIRTUAL)
     102            WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Virtual drive");
     103        else if (type & DRIVE_RAMDISK)
     104          WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Ramdisk");
     105        else {
     106          sprintf(s, "Local drive%s", (removable) ? " (removable)" : "");
     107          WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, s);
     108        }
     109        sprintf(s, "IFS:  %s", FileSystem);
     110        WinSetDlgItemText(hwnd, DIRSIZE_IFS, s);
     111        memset(&volser, 0, sizeof(volser));
     112        DosError(FERR_DISABLEHARDERR);
     113        if (!DosQueryFSInfo(toupper(*curdir) - '@', FSIL_VOLSER,
     114                            &volser, (ULONG) sizeof(volser))) {
     115          sprintf(s, "Label:  %s", volser.volumelabel);
     116          WinSetDlgItemText(hwnd, DIRSIZE_LABEL, s);
     117        }
     118        if (!DosQueryFSInfo(toupper(*curdir) - '@',
     119                            FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
     120          percentfree = fsa.cUnit ? (USHORT)((fsa.cUnitAvail * 100) / fsa.cUnit) : 0;   // 27 May 08 SHL
     121          if (!percentfree && fsa.cUnitAvail)
     122            percentfree = 1;
     123          percentused = 100 - percentfree;
     124          sprintf(s, "Units free:  %lu", fsa.cUnitAvail);
     125          WinSetDlgItemText(hwnd, DIRSIZE_UNITSFREE, s);
     126          sprintf(s, "Unit size:  %lu x %u = %lu",
     127                  fsa.cSectorUnit,
     128                  fsa.cbSector, fsa.cSectorUnit * fsa.cbSector);
     129          WinSetDlgItemText(hwnd, DIRSIZE_UNITSIZE, s);
     130          sprintf(s, "Units used:  %lu", fsa.cUnit - fsa.cUnitAvail);
     131          WinSetDlgItemText(hwnd, DIRSIZE_UNITSUSED, s);
     132          sprintf(s, "Bytes free:  %.0f",
     133                  (float)fsa.cUnitAvail * (fsa.cSectorUnit * fsa.cbSector));
     134          WinSetDlgItemText(hwnd, DIRSIZE_BYTESFREE, s);
     135          sprintf(s, "Bytes used:  %.0f",
     136                  (float)(fsa.cUnit - fsa.cUnitAvail) *
     137                  (fsa.cSectorUnit * fsa.cbSector));
     138          WinSetDlgItemText(hwnd, DIRSIZE_BYTESUSED, s);
     139          sprintf(s, "Percent used:  %u%%", percentused);
     140          WinSetDlgItemText(hwnd, DIRSIZE_PERCENT, s);
     141          WinSendDlgItemMsg(hwnd, DIRSIZE_SLIDER, SLM_SETSLIDERINFO,
     142                            MPFROM2SHORT(SMA_SLIDERARMPOSITION,
     143                                        SMA_INCREMENTVALUE),
     144                            MPFROMSHORT(percentused));
     145          WinShowWindow(WinWindowFromID(hwnd, DIRSIZE_SLIDER), TRUE);
     146        }
    146147      }
    147148      else {
    148         WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Drive not ready.");
    149         WinShowWindow(WinWindowFromID(hwnd, DIRSIZE_SLIDER), FALSE);
     149        WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Drive not ready.");
     150        WinShowWindow(WinWindowFromID(hwnd, DIRSIZE_SLIDER), FALSE);
    150151      }
    151152    }
     
    157158      switch (SHORT2FROMMP(mp1)) {
    158159      case LN_ENTER:
    159         WinPostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
    160         break;
     160        WinPostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
     161        break;
    161162      case LN_SELECT:
    162         {
    163           SHORT x;
    164 
    165           x = (SHORT) WinSendDlgItemMsg(hwnd, DIRSIZE_LISTBOX,
    166                                         LM_QUERYSELECTION,
    167                                         MPFROMSHORT(LIT_FIRST), MPVOID);
    168           if (x >= 0) {
    169             WinSendDlgItemMsg(hwnd, DIRSIZE_LISTBOX,
    170                               LM_QUERYITEMTEXT,
    171                               MPFROM2SHORT(x, sizeof(curdir)),
    172                               MPFROMP(curdir));
    173             WinPostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    174           }
    175         }
    176         break;
     163        {
     164          SHORT x;
     165
     166          x = (SHORT) WinSendDlgItemMsg(hwnd, DIRSIZE_LISTBOX,
     167                                        LM_QUERYSELECTION,
     168                                        MPFROMSHORT(LIT_FIRST), MPVOID);
     169          if (x >= 0) {
     170            WinSendDlgItemMsg(hwnd, DIRSIZE_LISTBOX,
     171                              LM_QUERYITEMTEXT,
     172                              MPFROM2SHORT(x, sizeof(curdir)),
     173                              MPFROMP(curdir));
     174            WinPostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     175          }
     176        }
     177        break;
    177178      }
    178179      break;
     
    188189    case DID_OK:
    189190      if (*curdir) {
    190         WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_HIDE);
    191         WinDlgBox(HWND_DESKTOP, hwnd,
    192                   DirSizeProc, FM3ModHandle, DSZ_FRAME, curdir);
    193         WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOW);
     191        WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_HIDE);
     192        WinDlgBox(HWND_DESKTOP, hwnd,
     193                  DirSizeProc, FM3ModHandle, DSZ_FRAME, curdir);
     194        WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOW);
    194195      }
    195196      else
    196         DosBeep(50, 100);
     197        DosBeep(50, 100);
    197198      break;
    198199    }
    199200    return 0;
    200   }                                     // switch
     201  }                                     // switch
    201202  return WinDefDlgProc(hwnd, msg, mp1, mp2);
    202203}
    203204
    204 #ifdef NEVER                            // 05 Jan 08 SHL fixme to be gone?
     205#ifdef NEVER                            // 05 Jan 08 SHL fixme to be gone?
    205206
    206207VOID APIENTRY deinit(ULONG why)
     
    229230  for (x = 1; x < argc; x++) {
    230231    if (!strchr("/;,`\'", *argv[x]) &&
    231         !*fullname && (IsRoot(argv[x]) || IsFile(argv[x]) == 0)) {
     232        !*fullname && (IsRoot(argv[x]) || IsFile(argv[x]) == 0)) {
    232233      if (IsRoot(argv[x]))
    233         strcpy(fullname, argv[x]);
     234        strcpy(fullname, argv[x]);
    234235      else if (DosQueryPathInfo(argv[x],
    235                                 FIL_QUERYFULLNAME,
    236                                 fullname, sizeof(fullname)))
    237         *fullname = 0;
     236                                FIL_QUERYFULLNAME,
     237                                fullname, sizeof(fullname)))
     238        *fullname = 0;
    238239    }
    239240  }
     
    248249    if (hmq) {
    249250      if (InitFM3DLL(hab, argc, argv)) {
    250         if (!*fullname)
    251           rcl = WinDlgBox(HWND_DESKTOP,
    252                           HWND_DESKTOP, DirMainProc, 0, DIRSIZE_FRAME, NULL);
    253         else
    254           rcl = WinDlgBox(HWND_DESKTOP,
    255                           HWND_DESKTOP,
    256                           DirSizeProc, FM3ModHandle, DSZ_FRAME, fullname);
    257         if (rcl == DID_ERROR)
    258           rcl = WinGetLastError(hab);
     251        if (!*fullname)
     252          rcl = WinDlgBox(HWND_DESKTOP,
     253                          HWND_DESKTOP, DirMainProc, 0, DIRSIZE_FRAME, NULL);
     254        else
     255          rcl = WinDlgBox(HWND_DESKTOP,
     256                          HWND_DESKTOP,
     257                          DirSizeProc, FM3ModHandle, DSZ_FRAME, fullname);
     258        if (rcl == DID_ERROR)
     259          rcl = WinGetLastError(hab);
    259260      }
    260261      WinDestroyMsgQueue(hmq);
     
    264265  return 0;
    265266
    266 }                                       // main
     267}                                       // main
Note: See TracChangeset for help on using the changeset viewer.