Subversion Repositories SvarDOS

Rev

Rev 2057 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2057 Rev 2058
Line 36... Line 36...
36
#include <stdlib.h>
36
#include <stdlib.h>
37
#include <string.h>
37
#include <string.h>
38
 
38
 
39
#include "dosdisk.h"
39
#include "dosdisk.h"
40
 
40
 
41
#define searchAttr ( FILE_A_DIR | FILE_A_HIDDEN | FILE_A_SYSTEM | FILE_A_READONLY | FILE_A_ARCH )
41
#define searchAttr ( FILE_A_SUBDIR | FILE_A_HIDDEN | FILE_A_SYSTEM | FILE_A_RDONLY | FILE_A_ARCH )
42
 
42
 
43
 
43
 
44
struct FFDTA *FindFirstFile(const char *pathname, struct FFDTA *hnd) {
44
struct FFDTA *FindFirstFile(const char *pathname, struct FFDTA *hnd) {
45
  char path[PATH_MAX];
45
  char path[PATH_MAX];
46
  short cflag = 0;  /* used to indicate if findfirst is succesful or not */
46
  short cflag = 0;  /* used to indicate if findfirst is succesful or not */
Line 199... Line 199...
199
    char volume[11];
199
    char volume[11];
200
    short ftype[8];
200
    short ftype[8];
201
  } media;
201
  } media;
202
 
202
 
203
  /* Stores the root path we use. */
203
  /* Stores the root path we use. */
204
  char pathname[260];
204
  char pathname[PATH_MAX + 5];
205
 
205
 
206
  unsigned short cflag;
206
  unsigned short cflag;
207
 
207
 
208
  /* validate root path to obtain info on, NULL or "" means use current */
208
  /* validate root path to obtain info on, NULL or "" means use current */
209
  if ((lpRootPathName == NULL) || (*lpRootPathName == '\0')) {
209
  if ((lpRootPathName == NULL) || (*lpRootPathName == '\0')) {
Line 246... Line 246...
246
  /* Search for volume using old findfirst, as LFN version (NT5 DOS box) does
246
  /* Search for volume using old findfirst, as LFN version (NT5 DOS box) does
247
   * not recognize FILE_A_VOL = 0x0008 as label attribute.
247
   * not recognize FILE_A_VOL = 0x0008 as label attribute.
248
   */
248
   */
249
  {
249
  {
250
    struct FFDTA finfo;
250
    struct FFDTA finfo;
251
    unsigned short attr_seg = FP_SEG(finfo.ff_attr);
251
    unsigned short attr_seg = FP_SEG(finfo.attrib);
252
    unsigned short attr_off = FP_OFF(finfo.ff_attr);
252
    unsigned short attr_off = FP_OFF(finfo.attrib);
253
    unsigned short finfo_seg = FP_SEG(&finfo);
253
    unsigned short finfo_seg = FP_SEG(&finfo);
254
    unsigned short finfo_off = FP_OFF(&finfo);
254
    unsigned short finfo_off = FP_OFF(&finfo);
255
    unsigned short pathname_seg = FP_SEG(pathname);
255
    unsigned short pathname_seg = FP_SEG(pathname);
256
    unsigned short pathname_off = FP_OFF(pathname);
256
    unsigned short pathname_off = FP_OFF(pathname);
257
 
257
 
Line 271... Line 271...
271
      push ds
271
      push ds
272
      mov ds, finfo_seg
272
      mov ds, finfo_seg
273
      int 0x21                  //; Execute interrupt
273
      int 0x21                  //; Execute interrupt
274
      pop ds
274
      pop ds
275
      mov ax, 0x4E00            //; Actual findfirst call
275
      mov ax, 0x4E00            //; Actual findfirst call
276
      mov cx, FILE_A_VOL
276
      mov cx, FILE_A_VOLID
277
      mov dx, pathname_off      //; Load DS:DX with pointer to modified RootPath for Findfirt
277
      mov dx, pathname_off      //; Load DS:DX with pointer to modified RootPath for Findfirt
278
      push ds
278
      push ds
279
      mov ds, pathname_seg
279
      mov ds, pathname_seg
280
      int 0x21                  //; Execute interrupt, Carry set on error, unset on success
280
      int 0x21                  //; Execute interrupt, Carry set on error, unset on success
281
      pop ds
281
      pop ds
Line 287... Line 287...
287
      push es
287
      push es
288
      mov es, attr_seg
288
      mov es, attr_seg
289
      mov al, [es:bx]              //; Looking for a BYTE that is FILE_ATTRIBUTE_LABEL only
289
      mov al, [es:bx]              //; Looking for a BYTE that is FILE_ATTRIBUTE_LABEL only
290
      pop es
290
      pop es
291
      and al, 0xDF              //; Ignore Archive bit
291
      and al, 0xDF              //; Ignore Archive bit
292
      cmp al, FILE_A_VOL
292
      cmp al, FILE_A_VOLID
293
      je cleanup                //; They match, so should be true volume entry.
293
      je cleanup                //; They match, so should be true volume entry.
294
      mov ax, 0x4F00            //; Otherwise keep looking (findnext)
294
      mov ax, 0x4F00            //; Otherwise keep looking (findnext)
295
      int 0x21                  //; Execute interrupt
295
      int 0x21                  //; Execute interrupt
296
      jnc success               //; If carry is not set then succesful
296
      jnc success               //; If carry is not set then succesful
297
      mov [cflag], ax           //; Set flag with error.
297
      mov [cflag], ax           //; Set flag with error.
Line 313... Line 313...
313
    /* copy over volume label, if buffer given */
313
    /* copy over volume label, if buffer given */
314
    if (lpVolumeNameBuffer != NULL) {
314
    if (lpVolumeNameBuffer != NULL) {
315
      if (cflag != 0) {  /* error or no label */
315
      if (cflag != 0) {  /* error or no label */
316
        lpVolumeNameBuffer[0] = '\0';
316
        lpVolumeNameBuffer[0] = '\0';
317
      } else {                      /* copy up to buffer's size of label */
317
      } else {                      /* copy up to buffer's size of label */
318
        strncpy(lpVolumeNameBuffer, finfo.ff_name, nVolumeNameSize);
318
        strncpy(lpVolumeNameBuffer, finfo.name, nVolumeNameSize);
319
        lpVolumeNameBuffer[nVolumeNameSize-1] = '\0';
319
        lpVolumeNameBuffer[nVolumeNameSize-1] = '\0';
320
        /* slide characters over if longer than 8 to remove . */
320
        /* slide characters over if longer than 8 to remove . */
321
        if (lpVolumeNameBuffer[8] == '.') {
321
        if (lpVolumeNameBuffer[8] == '.') {
322
          lpVolumeNameBuffer[8] = lpVolumeNameBuffer[9];
322
          lpVolumeNameBuffer[8] = lpVolumeNameBuffer[9];
323
          lpVolumeNameBuffer[9] = lpVolumeNameBuffer[10];
323
          lpVolumeNameBuffer[9] = lpVolumeNameBuffer[10];