home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / AW20.ZIP / AW_DISK.C < prev    next >
Text File  |  1989-11-28  |  3KB  |  137 lines

  1. #define INCL_WIN
  2. #define INCL_GPI
  3. #define INCL_DOS
  4. #define INCL_VIO
  5. #define INCL_AVIO
  6. #include <os2.h>
  7. #include <mt\stdio.h>
  8. #include <mt\stdlib.h>
  9. #include <mt\string.h>
  10. #include "aw.h"
  11.  
  12. extern HWND    hwndaw;
  13.  
  14. extern char far filename[20];
  15. extern USHORT all;
  16. extern char drive_str[27][4];
  17. extern USHORT num_drive;
  18. extern LONG SecSem;
  19. extern USHORT busy;
  20. extern USHORT file_attr;
  21. char far pathname[180];
  22.  
  23. VOID FAR SecondThread()
  24. {
  25.    USHORT indx;        
  26.  
  27.    while(1)
  28.    {
  29.         DosSemWait(&SecSem,-1L);
  30.        busy = TRUE;
  31.         for(indx= 0; indx < num_drive;indx++)
  32.        {
  33.             find_dir(drive_str[indx]);
  34.        }
  35.         WinPostMsg(hwndaw,WM_PAINT_TTY,"File search complete !!",0L);
  36.        WinAlarm(HWND_DESKTOP,WA_NOTE);
  37.         busy = FALSE;
  38.        DosSemSet(&SecSem);
  39.    }
  40. }
  41.  
  42. VOID find_dir(path)
  43. char *path;
  44. {
  45.    char localpath[180];
  46.    FILEFINDBUF buff;
  47.    USHORT count;
  48.    USHORT handle;
  49.  
  50.    strcat(path,"\\");
  51.    strcpy(localpath,path);
  52.    strcat(localpath,"*.*");
  53.    handle = 0xFFFF;
  54.    count = 1;
  55.    if(DosFindFirst(localpath,&handle,0x0010,&buff,sizeof(buff),&count,0L))
  56.    {
  57.        DosFindClose(handle);
  58.        search_dir(path);
  59.        return;
  60.    }
  61.    if(buff.achName[0] != '.' && (buff.attrFile & 0x0010))
  62.    {
  63.        strcpy(localpath,path);
  64.        strcat(localpath,buff.achName);
  65.        find_dir(localpath);
  66.    }
  67.    while(TRUE)
  68.    {
  69.        if(DosFindNext(handle,&buff,sizeof(buff),&count))
  70.        {
  71.            DosFindClose(handle);
  72.            search_dir(path);
  73.            return;
  74.        }
  75.        if(buff.achName[0] != '.' && (buff.attrFile & 0x0010))
  76.        {
  77.            strcpy(localpath,path);
  78.            strcat(localpath,buff.achName);
  79.            find_dir(localpath);
  80.        }
  81.    }
  82. }
  83.  
  84. VOID search_dir(path)
  85. char *path;
  86. {
  87.    char localpath[180];
  88.    FILEFINDBUF buff;
  89.    USHORT count;
  90.    USHORT handle;
  91.  
  92.    strcpy(localpath,path);
  93.    strcat(localpath,filename);
  94.    strset(buff.achName,0);
  95.    handle = 0xFFFF;
  96.    count = 1;
  97.    if(DosFindFirst(localpath,&handle,file_attr,&buff,sizeof(buff),&count,0L))
  98.    {
  99.        DosFindClose(handle);
  100.        return;
  101.    }
  102.    if(all || (buff.attrFile & file_attr))
  103.    {
  104.        DosSemWait(&SecSem,-1L);
  105.        sprintf(pathname,"%s%s",path,buff.achName);
  106.        DosSemSet(&SecSem);
  107.        WinPostMsg(hwndaw,WM_PAINT_TTY,pathname,0L);
  108.    }
  109.    while(TRUE)
  110.    {
  111.        if(DosFindNext(handle,&buff,sizeof(buff),&count))
  112.        {
  113.            DosFindClose(handle);
  114.            return;
  115.        }
  116.        DosSemWait(&SecSem,-1L);
  117.        if(all || (buff.attrFile & file_attr))
  118.        {
  119.            sprintf(pathname,"%s%s",path,buff.achName);
  120.            DosSemSet(&SecSem);
  121.            WinPostMsg(hwndaw,WM_PAINT_TTY,pathname,0L);
  122.        }
  123.    }
  124. }
  125.  
  126. VOID EnableMenuItem(HWND hwnd, SHORT iMenuItem, BOOL bEnable)
  127. {
  128.    HWND hwndParent;
  129.    HWND hwndMenu;
  130.  
  131.    hwndParent = WinQueryWindow(hwnd,QW_PARENT,FALSE);
  132.    hwndMenu = WinWindowFromID(hwndParent,FID_MENU);
  133.    
  134.    WinSendMsg(hwndMenu,MM_SETITEMATTR,(MPARAM)MAKEULONG(iMenuItem,TRUE),
  135.          (MPARAM)MAKEULONG(MIA_DISABLED,bEnable ? 0 : MIA_DISABLED));
  136. }
  137.