Subversion Repositories SvarDOS

Rev

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

Rev 397 Rev 399
Line 143... Line 143...
143
 
143
 
144
  goto AGAIN;
144
  goto AGAIN;
145
}
145
}
146
 
146
 
147
 
147
 
148
/* converts a path to its canonic representation */
148
/* converts a path to its canonic representation, returns 0 on success
-
 
149
 * or DOS err on failure (invalid drive) */
149
void file_truename(const char *src, char *dst) {
150
unsigned short file_truename(const char *src, char *dst) {
-
 
151
  unsigned short res = 0;
150
  _asm {
152
  _asm {
-
 
153
    push es
151
    mov ah, 0x60  /* query truename, DS:SI=src, ES:DI=dst */
154
    mov ah, 0x60  /* query truename, DS:SI=src, ES:DI=dst */
152
    push ds
155
    push ds
153
    pop es
156
    pop es
154
    mov si, src
157
    mov si, src
155
    mov di, dst
158
    mov di, dst
156
    int 0x21
159
    int 0x21
-
 
160
    jnc DONE
-
 
161
    mov [res], ax
-
 
162
    DONE:
-
 
163
    pop es
157
  }
164
  }
-
 
165
  return(res);
158
}
166
}
159
 
167
 
160
 
168
 
161
/* returns DOS attributes of file, or -1 on error */
169
/* returns DOS attributes of file, or -1 on error */
162
int file_getattr(const char *fname) {
170
int file_getattr(const char *fname) {
Line 206... Line 214...
206
    int 0x21
214
    int 0x21
207
    mov dl, 0x0A
215
    mov dl, 0x0A
208
    int 0x21
216
    int 0x21
209
  }
217
  }
210
}
218
}
-
 
219
 
-
 
220
 
-
 
221
/* validate a drive (A=0, B=1, etc). returns 1 if valid, 0 otherwise */
-
 
222
int isdrivevalid(unsigned char drv) {
-
 
223
  _asm {
-
 
224
    mov ah, 0x19  /* query default (current) disk */
-
 
225
    int 0x21      /* drive in AL (0=A, 1=B, etc) */
-
 
226
    mov ch, al    /* save current drive to ch */
-
 
227
    /* try setting up the drive as current */
-
 
228
    mov ah, 0x0E   /* select default drive */
-
 
229
    mov dl, [drv]  /* 0=A, 1=B, etc */
-
 
230
    int 0x21
-
 
231
    /* this call does not set CF on error, I must check cur drive to look for success */
-
 
232
    mov ah, 0x19  /* query default (current) disk */
-
 
233
    int 0x21      /* drive in AL (0=A, 1=B, etc) */
-
 
234
    mov [drv], 1  /* preset result as success */
-
 
235
    cmp al, dl    /* is eq? */
-
 
236
    je DONE
-
 
237
    mov [drv], 0  /* fail */
-
 
238
    jmp FAILED
-
 
239
    DONE:
-
 
240
    /* set current drive back to what it was initially */
-
 
241
    mov ah, 0x0E
-
 
242
    mov dl, ch
-
 
243
    int 0x21
-
 
244
    FAILED:
-
 
245
  }
-
 
246
  return(drv);
-
 
247
}