home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / df3os2.zip / DIRECTRY.CPP < prev    next >
C/C++ Source or Header  |  1993-11-13  |  2KB  |  102 lines

  1. // ---------- directry.cpp
  2. // 
  3. // removed direct BIOS calls
  4. // - to be replaced with native OS/2 code.
  5. // 
  6.  
  7. #define INCL_NOPMAPI
  8. #include <os2.h>
  9. #include <direct.h>
  10.  
  11. #include "directry.h"
  12.  
  13. const char *PathNameLabel::CurrentPath()
  14.     {
  15.     static char path[CCHMAXPATH];
  16.     _getdcwd(0, path, CCHMAXPATH);
  17.     return path;
  18.     }
  19.  
  20. void PathNameLabel::FillLabel()
  21.     {
  22.     SetText(CurrentPath());
  23.     }
  24.  
  25.  
  26. DriveListBox::DriveListBox(int lf, int tp, DFWindow *par)
  27.                         : ListBox(lf, tp, 10, 10, par)
  28.     {
  29.     SetAttribute(BORDER);
  30.     currdrive = getdisk();
  31.     for (unsigned int dr = 0; dr < 26; dr++)    
  32.         {
  33.         setdisk(dr);
  34.         if (getdisk() == dr)    {
  35.             // ----- test for remapped B drive removed - jw
  36.             
  37.             String drname(" :");
  38.             drname[0] = dr+'A';
  39.  
  40.             // ---- test for network or RAM disk removed - jw
  41.  
  42.             AddText(drname);
  43.             }
  44.         }
  45.     setdisk(currdrive);
  46.     SetScrollBars();
  47.     }
  48.  
  49.  
  50. DirectoryListBox::DirectoryListBox(int lf, int tp, DFWindow *par)
  51.                         : ListBox(lf, tp, 10, 13, par)
  52.     {
  53.     SetAttribute(BORDER);
  54.     FillList();
  55.     }
  56.  
  57. void DirectoryListBox::FillList()
  58.     {
  59.     ClearText();
  60.     int ax;
  61.     struct ffblk ff;
  62.     ax = findfirst("*.*", &ff, FA_DIREC);
  63.     while (ax == 0)    
  64.         {
  65.         if ((ff.ff_attrib & FA_DIREC) != 0)    
  66.             {
  67.             if (strcmp(ff.ff_name, "."))    
  68.                 {
  69.                 String fname("[");
  70.                 fname += ff.ff_name;
  71.                 fname += "]";
  72.                 AddText(fname);
  73.                 }
  74.             }
  75.         ax = findnext(&ff);
  76.         }
  77.     SetScrollBars();
  78.     }
  79.  
  80. FileNameListBox::FileNameListBox(const char *filespec,int lf,int tp, DFWindow *par)
  81.                         : ListBox(lf, tp, 10, 14, par)
  82.     {
  83.     SetAttribute(BORDER);
  84.     FillList(filespec);
  85.     }
  86.  
  87. void FileNameListBox::FillList(const char *filespec)
  88.     {
  89.     ClearText();
  90.     int ax;
  91.     struct ffblk ff;
  92.     ax = findfirst(*filespec ? filespec : "*.*", &ff, 0);
  93.     while (ax == 0)    
  94.         {
  95.         AddText(ff.ff_name);
  96.         ax = findnext(&ff);
  97.         }
  98.     SetScrollBars();
  99.     }
  100.  
  101.  
  102.