Subversion Repositories SvarDOS

Rev

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

Rev 2054 Rev 2056
Line 393... Line 393...
393
    return 0;   /* zero means error! */
393
    return 0;   /* zero means error! */
394
  } else {
394
  } else {
395
    return 1;   /* Success (drive exists we think anyway) */
395
    return 1;   /* Success (drive exists we think anyway) */
396
  }
396
  }
397
}
397
}
398
 
-
 
399
 
-
 
400
/* retrieve attributes (ReadOnly/System/...) about file or directory
-
 
401
 * returns -1 on error
-
 
402
 */
-
 
403
int GetFileAttributes(unsigned short *attr, const char *pathname) {
-
 
404
  union REGS r;
-
 
405
  struct SREGS s;
-
 
406
  char buffer[260];
-
 
407
  int slen;
-
 
408
 
-
 
409
  /* we must remove any slashes from end */
-
 
410
  slen = strlen(pathname) - 1;  /* Warning, assuming pathname is not ""   */
-
 
411
  strcpy(buffer, pathname);
-
 
412
  if ((buffer[slen] == '\\') || (buffer[slen] == '/')) { /* ends in a slash */
-
 
413
    /* don't remove from root directory (slen == 0),
-
 
414
     * ignore UNC paths as SFN doesn't handle them anyway
-
 
415
     * if slen == 2, then check if drive given (e.g. C:\)
-
 
416
     */
-
 
417
    if (slen && !(slen == 2 &&  buffer[1] == ':'))
-
 
418
      buffer[slen] = '\0';
-
 
419
  }
-
 
420
  /* return standard attributes */
-
 
421
  r.x.ax = 0x4300;                  /* standard Get/Set File Attributes */
-
 
422
  r.x.dx = FP_OFF(buffer);          /* DS:DX points to ASCIIZ filename      */
-
 
423
  segread(&s);                      /* load with current segment values     */
-
 
424
  s.ds = FP_SEG(buffer);            /* get Segment of our filename pointer  */
-
 
425
  intdosx(&r, &r, &s);              /* invoke the DOS int21h call           */
-
 
426
 
-
 
427
  //if (r.x.cflag) printf("ERROR getting std attributes of %s, DOS err %i\n", buffer, r.x.ax);
-
 
428
  if (r.x.cflag) return(-1);  /* error obtaining attributes           */
-
 
429
  *attr = (0x3F & r.x.cx); /* mask off any DRDOS bits     */
-
 
430
  return(0);
-
 
431
}
-