Subversion Repositories SvarDOS

Rev

Rev 384 | Rev 389 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
368 mateuszvis 1
/*
2
 * dir
3
 *
4
 * Displays a list of files and subdirectories in a directory.
5
 *
6
 * DIR [drive:][path][filename] [/P] [/W] [/A[:]attributes] [/O[[:]sortorder]] [/S] [/B] [/L]
7
 *
8
 * /P Pauses after each screenful of information.
9
 * /W Uses wide list format.
10
 *
11
 * /A Displays file with specified attributes:
12
 *     D Directories           R Read-only files     H Hidden files
13
 *     A Ready for archiving   S System files        - prefix meaning "not"
14
 *
15
 * /O List files in sorted order:
16
 *     N by name            S by size              E by extension
17
 *     D by date            G group dirs first     - prefix to reverse order
18
 *
19
 * /S Displays files in specified directory and all subdirectories.
20
 * /B Uses bare format (no heading information or summary)
21
 * /L Uses lowercases
22
 */
23
 
24
#define cmd_dir_attr_ro   1
25
#define cmd_dir_attr_hid  2
26
#define cmd_dir_attr_sys  4
27
#define cmd_dir_attr_vol  8
28
#define cmd_dir_attr_dir 16
29
#define cmd_dir_attr_arc 32
30
 
31
 
372 mateuszvis 32
static int cmd_dir(struct cmd_funcparam *p) {
368 mateuszvis 33
  const char *filespecptr = "*.*";
388 mateuszvis 34
  struct DTA *dta = (void *)0x80; /* set DTA to its default location at 80h in PSP */
368 mateuszvis 35
 
388 mateuszvis 36
  if (findfirst(dta, filespecptr, cmd_dir_attr_ro | cmd_dir_attr_hid | cmd_dir_attr_sys | cmd_dir_attr_dir | cmd_dir_attr_arc) != 0) return(-1);
368 mateuszvis 37
 
369 mateuszvis 38
  outputnl(dta->fname);
368 mateuszvis 39
 
388 mateuszvis 40
  while (findnext(dta) == 0) outputnl(dta->fname);
368 mateuszvis 41
 
42
  return(-1);
43
}