Subversion Repositories SvarDOS

Rev

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

Rev 372 Rev 374
Line 9... Line 9...
9
 * Type CD drive: to display the current directory in the specified drive.
9
 * Type CD drive: to display the current directory in the specified drive.
10
 * Type CD without parameters to display the current drive and directory.
10
 * Type CD without parameters to display the current drive and directory.
11
 */
11
 */
12
 
12
 
13
static int cmd_cd(struct cmd_funcparam *p) {
13
static int cmd_cd(struct cmd_funcparam *p) {
-
 
14
  char *buffptr = p->BUFFER;
-
 
15
 
14
  /* two arguments max */
16
  /* two arguments max */
15
  if (p->argc > 1) {
17
  if (p->argc > 1) {
16
    outputnl("Too many parameters");
18
    outputnl("Too many parameters");
-
 
19
    return(-1);
-
 
20
  }
-
 
21
 
-
 
22
  /* CD /? */
-
 
23
  if ((p->argc == 1) && (imatch(p->argv[0], "/?"))) {
-
 
24
    outputnl("Displays the name of or changes the current directory.");
-
 
25
    outputnl("");
-
 
26
    outputnl("CHDIR [drive:][path]");
-
 
27
    outputnl("CHDIR[..]");
-
 
28
    outputnl("CD [drive:][path]");
-
 
29
    outputnl("CD[..]");
-
 
30
    outputnl("");
-
 
31
    outputnl(".. Specifies that you want to change to the parent directory.");
-
 
32
    outputnl("");
-
 
33
    outputnl("Type CD drive: to display the current directory in the specified drive.");
-
 
34
    outputnl("Type CD without parameters to display the current drive and directory.");
-
 
35
    return(-1);
17
  }
36
  }
18
 
37
 
19
  /* no argument? display current drive and dir ("CWD") */
38
  /* no argument? display current drive and dir ("CWD") */
20
  if (p->argc == 0) {
39
  if (p->argc == 0) {
21
    char buff[64];
-
 
22
    char *buffptr = buff;
-
 
23
    _asm {
40
    _asm {
24
      push ax
41
      push ax
25
      push dx
42
      push dx
26
      push si
43
      push si
27
      mov ah, 0x19  /* get current default drive */
44
      mov ah, 0x19  /* get current default drive */
Line 42... Line 59...
42
      int 0x21
59
      int 0x21
43
      pop si
60
      pop si
44
      pop dx
61
      pop dx
45
      pop ax
62
      pop ax
46
    }
63
    }
47
    puts(buff);
64
    outputnl(buffptr);
-
 
65
    return(-1);
48
  }
66
  }
49
 
67
 
50
  /* argument can be either a drive (D:) or a path */
68
  /* argument can be either a drive (D:) or a path */
51
  if (p->argc == 1) {
69
  if (p->argc == 1) {
52
    const char *arg = p->argv[0];
70
    const char *arg = p->argv[0];
53
    unsigned short err = 0;
71
    unsigned short err = 0;
54
    /* drive (CD B:) */
72
    /* drive (CD B:) */
55
    if ((arg[0] != '\\') && (arg[1] == ':') && (arg[2] == 0)) {
73
    if ((arg[0] != '\\') && (arg[1] == ':') && (arg[2] == 0)) {
56
      char buff[64];
-
 
57
      char *buffptr = buff;
-
 
58
      unsigned char drive = arg[0];
74
      unsigned char drive = arg[0];
59
      if (drive >= 'a') {
75
      if (drive >= 'a') {
60
        drive -= 'a';
76
        drive -= 'a';
61
      } else {
77
      } else {
62
        drive -= 'A';
78
        drive -= 'A';
Line 75... Line 91...
75
        DONE:
91
        DONE:
76
        pop dx
92
        pop dx
77
        pop ax
93
        pop ax
78
        pop si
94
        pop si
79
      }
95
      }
80
      if (err == 0) printf("%c:\\%s\r\n", drive + 'A' - 1, buff);
96
      if (err == 0) printf("%c:\\%s\r\n", drive + 'A' - 1, buffptr);
81
    } else { /* path */
97
    } else { /* path */
82
      _asm {
98
      _asm {
83
        push dx
99
        push dx
84
        push ax
100
        push ax
85
        mov ah, 0x3B  /* CHDIR (set current directory) */
101
        mov ah, 0x3B  /* CHDIR (set current directory) */