Subversion Repositories SvarDOS

Rev

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

Rev 2040 Rev 2041
Line 236... Line 236...
236
      break;
236
      break;
237
  }
237
  }
238
}
238
}
239
 
239
 
240
 
240
 
241
/* retrieve attributes (ReadOnly/System/...) about file or directory
-
 
242
 * returns (DWORD)-1 on error
-
 
243
 */
-
 
244
static DWORD GetFileAttributes(const char *pathname) {
-
 
245
  union REGS r;
-
 
246
  struct SREGS s;
-
 
247
  char buffer[260];
-
 
248
  int slen;
-
 
249
 
-
 
250
  /* 1st try LFN - Extended get/set attributes (in case LFN used) */
-
 
251
  if (LFN_Enable_Flag)
-
 
252
  {
-
 
253
    r.x.ax = 0x7143;                  /* LFN API, Extended Get/Set Attributes */
-
 
254
    r.x.bx = 0x00;                    /* BL=0, get file attributes            */
-
 
255
    r.x.dx = FP_OFF(pathname);        /* DS:DX points to ASCIIZ filename      */
-
 
256
 
-
 
257
    segread(&s);                      /* load with current segment values     */
-
 
258
    s.ds = FP_SEG(pathname);          /* get Segment of our filename pointer  */
-
 
259
 
-
 
260
    r.x.cflag = 1;                    /* should be set when unsupported ***   */
-
 
261
    asm stc;                          /* but clib usually ignores on entry    */
-
 
262
 
-
 
263
    /* Actually perform the call, carry should be set on error or unuspported */
-
 
264
    intdosx(&r, &r, &s);         /* Clib function to invoke DOS int21h call   */
-
 
265
 
-
 
266
    if (!r.x.cflag)              /* if carry not set then cx has desired info */
-
 
267
      return (DWORD)r.x.cx;
-
 
268
    /* else error other than unsupported LFN api or invalid function [FreeDOS]*/
-
 
269
    else if ((r.x.ax != 0x7100) || (r.x.ax != 0x01))
-
 
270
      return (DWORD)-1;
-
 
271
    /* else fall through to standard get/set file attribute call */
-
 
272
  }
-
 
273
 
-
 
274
  /* we must remove any slashes from end */
-
 
275
  slen = strlen(pathname) - 1;  /* Warning, assuming pathname is not ""   */
-
 
276
  strcpy(buffer, pathname);
-
 
277
  if ((buffer[slen] == '\\') || (buffer[slen] == '/')) /* ends in a slash */
-
 
278
  {
-
 
279
    /* don't remove from root directory (slen == 0),
-
 
280
     * ignore UNC paths as SFN doesn't handle them anyway
-
 
281
     * if slen == 2, then check if drive given (e.g. C:\)
-
 
282
     */
-
 
283
    if (slen && !(slen == 2 &&  buffer[1] == ':'))
-
 
284
      buffer[slen] = '\0';
-
 
285
  }
-
 
286
  /* return standard attributes */
-
 
287
  r.x.ax = 0x4300;                  /* standard Get/Set File Attributes */
-
 
288
  r.x.dx = FP_OFF(buffer);          /* DS:DX points to ASCIIZ filename      */
-
 
289
  segread(&s);                      /* load with current segment values     */
-
 
290
  s.ds = FP_SEG(buffer);            /* get Segment of our filename pointer  */
-
 
291
  intdosx(&r, &r, &s);              /* invoke the DOS int21h call           */
-
 
292
 
-
 
293
  //if (r.x.cflag) printf("ERROR getting std attributes of %s, DOS err %i\n", buffer, r.x.ax);
-
 
294
  if (r.x.cflag) return (DWORD)-1;  /* error obtaining attributes           */
-
 
295
  return (DWORD)(0x3F & r.x.cx); /* mask off any DRDOS bits     */
-
 
296
}
-
 
297
 
-
 
298
 
-
 
299
/* when pause == NOPAUSE then identical to printf,
241
/* when pause == NOPAUSE then identical to printf,
300
   otherwise counts lines printed and pauses as needed.
242
   otherwise counts lines printed and pauses as needed.
301
   Should be used for all messages printed that do not
243
   Should be used for all messages printed that do not
302
   immediately exit afterwards (else printf may be used).
244
   immediately exit afterwards (else printf may be used).
303
   May display N too many lines before pause if line is
245
   May display N too many lines before pause if line is