Subversion Repositories SvarDOS

Rev

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

Rev 397 Rev 416
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
 
13
 
14
/* display current path drive d (A=1, B=2, etc)
-
 
15
 * returns 0 on success, doserr otherwise */
-
 
16
static unsigned short cmd_cd_curpathfordrv(char *buff, unsigned char d) {
-
 
17
  unsigned short r = 0;
-
 
18
 
-
 
19
  buff[0] = d + 'A' - 1;
-
 
20
  buff[1] = ':';
-
 
21
  buff[2] = '\\';
-
 
22
 
-
 
23
  _asm {
-
 
24
    push si
-
 
25
    push ax
-
 
26
    push dx
-
 
27
    mov ah, 0x47      /* get current directory */
-
 
28
    mov dl, [d]       /* A: = 1, B: = 2, etc */
-
 
29
    mov si, buff      /* append cur dir to buffer */
-
 
30
    add si, 3         /* skip the present drive:\ prefix */
-
 
31
    int 0x21
-
 
32
    jnc DONE
-
 
33
    mov [r], ax       /* copy result from ax */
-
 
34
    DONE:
-
 
35
    pop dx
-
 
36
    pop ax
-
 
37
    pop si
-
 
38
  }
-
 
39
 
-
 
40
  return(r);
-
 
41
}
-
 
42
 
-
 
43
 
-
 
44
static int cmd_cd(struct cmd_funcparam *p) {
14
static int cmd_cd(struct cmd_funcparam *p) {
45
  char *buffptr = p->BUFFER;
15
  char *buffptr = p->BUFFER;
46
 
16
 
47
  /* CD /? */
17
  /* CD /? */
48
  if (cmd_ishlp(p)) {
18
  if (cmd_ishlp(p)) {
Line 66... Line 36...
66
    return(-1);
36
    return(-1);
67
  }
37
  }
68
 
38
 
69
  /* no argument? display current drive and dir ("CWD") */
39
  /* no argument? display current drive and dir ("CWD") */
70
  if (p->argc == 0) {
40
  if (p->argc == 0) {
71
    unsigned char drv = 0;
-
 
72
 
-
 
73
    _asm {
-
 
74
      push ax
-
 
75
      push dx
-
 
76
      push si
-
 
77
      mov ah, 0x19  /* get current default drive */
-
 
78
      int 0x21      /* al = drive (00h = A:, 01h = B:, etc) */
-
 
79
      inc al        /* convert to 1=A, 2=B, etc */
-
 
80
      mov [drv], al
-
 
81
    }
-
 
82
 
-
 
83
    cmd_cd_curpathfordrv(buffptr, drv);
41
    curpathfordrv(buffptr, 0);
84
    outputnl(buffptr);
42
    outputnl(buffptr);
85
 
-
 
86
    return(-1);
43
    return(-1);
87
  }
44
  }
88
 
45
 
89
  /* argument can be either a drive (D:) or a path */
46
  /* argument can be either a drive (D:) or a path */
90
  if (p->argc == 1) {
47
  if (p->argc == 1) {
Line 97... Line 54...
97
        drive -= ('a' - 1);
54
        drive -= ('a' - 1);
98
      } else {
55
      } else {
99
        drive -= ('A' - 1);
56
        drive -= ('A' - 1);
100
      }
57
      }
101
 
58
 
102
      err = cmd_cd_curpathfordrv(buffptr, drive);
59
      err = curpathfordrv(buffptr, drive);
103
      if (err == 0) outputnl(buffptr);
60
      if (err == 0) outputnl(buffptr);
104
    } else { /* path */
61
    } else { /* path */
105
      _asm {
62
      _asm {
106
        push dx
63
        push dx
107
        push ax
64
        push ax