Subversion Repositories SvarDOS

Rev

Rev 390 | Rev 396 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 390 Rev 393
Line 20... Line 20...
20
 * /B Uses bare format (no heading information or summary)
20
 * /B Uses bare format (no heading information or summary)
21
 * /L Uses lowercases
21
 * /L Uses lowercases
22
 */
22
 */
23
 
23
 
24
static int cmd_dir(struct cmd_funcparam *p) {
24
static int cmd_dir(struct cmd_funcparam *p) {
25
  const char *filespecptr = "*.*";
25
  const char *filespecptr = NULL;
26
  struct DTA *dta = (void *)0x80; /* set DTA to its default location at 80h in PSP */
26
  struct DTA *dta = (void *)0x80; /* set DTA to its default location at 80h in PSP */
-
 
27
  int i;
27
 
28
 
28
  if (cmd_ishlp(p)) {
29
  if (cmd_ishlp(p)) {
29
    outputnl("Displays a list of files and subdirectories in a directory.");
30
    outputnl("Displays a list of files and subdirectories in a directory.");
30
    outputnl("\r\nTHIS COMMAND IS NOT FULLY IMPLEMENTED YET");
31
    outputnl("\r\nTHIS COMMAND IS NOT FULLY IMPLEMENTED YET");
31
    return(-1);
32
    return(-1);
32
  }
33
  }
33
 
34
 
-
 
35
  /* parse command line */
-
 
36
  for (i = 0; i < p->argc; i++) {
-
 
37
    if (p->argv[i][0] == '/') {
-
 
38
      switch (p->argv[i][1]) {
-
 
39
        default:
-
 
40
          outputnl("Invalid switch");
-
 
41
          return(-1);
-
 
42
      }
-
 
43
    } else {  /* filespec */
-
 
44
      if (filespecptr != NULL) {
-
 
45
        outputnl("Too many parameters");
-
 
46
        return(-1);
-
 
47
      }
-
 
48
      filespecptr = p->argv[i];
-
 
49
    }
-
 
50
  }
-
 
51
 
-
 
52
  if (filespecptr == NULL) filespecptr = ".";
-
 
53
 
-
 
54
  file_truename(filespecptr, p->BUFFER);
-
 
55
 
-
 
56
  /* if dir then append \????????.??? */
-
 
57
  i = file_getattr(p->BUFFER);
-
 
58
  if ((i > 0) && (i & DOS_ATTR_DIR)) strcat(p->BUFFER, "\\????????.???");
-
 
59
 
34
  if (findfirst(dta, filespecptr, DOS_ATTR_RO | DOS_ATTR_HID | DOS_ATTR_SYS | DOS_ATTR_DIR | DOS_ATTR_ARC) != 0) return(-1);
60
  if (findfirst(dta, p->BUFFER, DOS_ATTR_RO | DOS_ATTR_HID | DOS_ATTR_SYS | DOS_ATTR_DIR | DOS_ATTR_ARC) != 0) return(-1);
35
 
61
 
36
  outputnl(dta->fname);
62
  outputnl(dta->fname);
37
 
63
 
38
  while (findnext(dta) == 0) outputnl(dta->fname);
64
  while (findnext(dta) == 0) outputnl(dta->fname);
39
 
65