home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 September / PCO_0998.ISO / filesbbs / dos / sbbs230b.exe / EXEC.LZH / DIR.SRC < prev    next >
Encoding:
Text File  |  1995-09-27  |  1.7 KB  |  107 lines

  1. # DIR.SRC
  2.  
  3. # Test of Directory System Functions
  4.  
  5. !include sbbsdefs.inc
  6. !include dir_attr.inc
  7.  
  8. int dir fattr flen ftime bytes files i
  9. str path name attr time date
  10.  
  11. print "Directory of: "
  12. getstrupr path 60
  13. open_dir dir path
  14. if_false
  15.     printf "Unable to open %s\r\n" path
  16.     return
  17.     end_if
  18. printf "Directory of %s\r\n\r\n" path
  19. :next
  20.     copy i _sys_status
  21.     and i SS_ABORT
  22.     compare i 0
  23.     if_not_equal # Ctrl-C hit
  24.         print "Aborted.\n"
  25.         goto end
  26.         end_if
  27.     read_dir dir name
  28.     if_false
  29.         goto end
  30.         end_if
  31.     # Increment file counter
  32.     add files 1
  33.     sprintf str "%s\\%s" path name
  34.     get_file_attrib fattr str
  35.     get_file_length flen str
  36.     # Add to total byte counter
  37.     compare flen 0
  38.     if_greater
  39.         add bytes flen
  40.         end_if
  41.     get_file_time ftime str
  42.     ftime_str time "%H:%M:%S" ftime
  43.     ftime_str date "%m/%d/%y" ftime
  44.  
  45.     set attr ""
  46.  
  47.     copy i fattr
  48.     and i FA_RDONLY
  49.     compare i 0
  50.     if_not_equal
  51.         strcat attr "r"
  52.     else
  53.         strcat attr "-"
  54.         end_if
  55.  
  56.     copy i fattr
  57.     and i FA_HIDDEN
  58.     compare i 0
  59.     if_not_equal
  60.         strcat attr "h"
  61.     else
  62.         strcat attr "-"
  63.                 end_if
  64.  
  65.     copy i fattr
  66.     and i FA_SYSTEM
  67.     compare i 0
  68.     if_not_equal
  69.         strcat attr "s"
  70.     else
  71.         strcat attr "-"
  72.                 end_if
  73.  
  74.     copy i fattr
  75.     and i FA_LABEL
  76.     compare i 0
  77.     if_not_equal
  78.         strcat attr "l"
  79.     else
  80.         strcat attr "-"
  81.                 end_if
  82.  
  83.     copy i fattr
  84.     and i FA_DIREC
  85.     compare i 0
  86.     if_not_equal
  87.         strcat attr "d"
  88.     else
  89.         strcat attr "-"
  90.                 end_if
  91.  
  92.     copy i fattr
  93.     and i FA_ARCH
  94.     compare i 0
  95.     if_not_equal
  96.         strcat attr "a"
  97.     else
  98.         strcat attr "-"
  99.                 end_if
  100.  
  101.     printf "%s %10ld  %s  %s  %s\r\n" attr flen date time name
  102.     goto next
  103. :end
  104. close_dir dir
  105. printf "\r\n%lu total bytes in %lu files\r\n" bytes files
  106.  
  107.