Subversion Repositories SvarDOS

Rev

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

Rev 2044 Rev 2045
Line 38... Line 38...
38
#include "dosdisk.h"
38
#include "dosdisk.h"
39
 
39
 
40
#define searchAttr ( FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_HIDDEN | \
40
#define searchAttr ( FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_HIDDEN | \
41
   FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_ARCHIVE )
41
   FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_ARCHIVE )
42
 
42
 
43
/* If this variable is nonzero then will 1st attempt LFN findfirst
-
 
44
 * (findfirst calls sets flag, so findnext/findclose know proper method to continue)
-
 
45
 * else if 0 then only attempt old 0x4E findfirst.
-
 
46
 * This is mostly a debugging tool, may be useful during runtime.
-
 
47
 * Default is LFN_ENABLE.
-
 
48
 */
-
 
49
int LFN_Enable_Flag = LFN_ENABLE;
-
 
50
 
-
 
51
 
43
 
52
/* copy old style findfirst data FFDTA to a WIN32_FIND_DATA
44
/* copy old style findfirst data FFDTA to a WIN32_FIND_DATA
53
 * NOTE: does not map exactly.
45
 * NOTE: does not map exactly.
54
 * internal to this module only.
46
 * internal to this module only.
55
 */
47
 */
Line 94... Line 86...
94
  memset(hnd, 0, sizeof(struct FindFileStruct));
86
  memset(hnd, 0, sizeof(struct FindFileStruct));
95
 
87
 
96
  /* Clear findData, this is to fix a glitch under NT, with 'special' $???? files */
88
  /* Clear findData, this is to fix a glitch under NT, with 'special' $???? files */
97
  memset(findData, 0, sizeof(struct WIN32_FIND_DATA));
89
  memset(findData, 0, sizeof(struct WIN32_FIND_DATA));
98
 
90
 
99
  /* First try DOS LFN (0x714E) findfirst, going to old (0x4E) if error */
-
 
100
  if (LFN_Enable_Flag)
-
 
101
  {
-
 
102
    unsigned short attr = searchAttr;
-
 
103
    unsigned short varax = 0xffff;
-
 
104
    unsigned short finddata_seg = FP_SEG(findData);
-
 
105
    unsigned short finddata_off = FP_OFF(findData);
-
 
106
    unsigned char cf = 1;
-
 
107
    unsigned short pathname_seg = FP_SEG(pathname);
-
 
108
    unsigned short pathname_off = FP_OFF(pathname);
-
 
109
    hnd->flag = FINDFILELFN;
-
 
110
 
-
 
111
    _asm {
-
 
112
      push ax
-
 
113
      push bx
-
 
114
      push cx
-
 
115
      push dx
-
 
116
      push es
-
 
117
      push si
-
 
118
      push di
-
 
119
 
-
 
120
      stc                          //; In case not supported
-
 
121
      mov si, 1                    //; same format as when old style used, set to 0 for 64bit value
-
 
122
      mov di, finddata_off         //; Set address of findData into ES:DI
-
 
123
      mov es, finddata_seg
-
 
124
      mov ax, 0x714E               //; LFN version of FindFirst
-
 
125
      mov cx, attr
-
 
126
      mov dx, pathname_off         //; Load DS:DX with pointer to path for Findfirst
-
 
127
      push ds
-
 
128
      mov ds, pathname_seg
-
 
129
      int 0x21                     //; Execute interrupt
-
 
130
      pop ds
-
 
131
      jc lfnerror
-
 
132
      mov cf, 0
-
 
133
      mov varax, ax
-
 
134
      lfnerror:
-
 
135
 
-
 
136
      pop di
-
 
137
      pop si
-
 
138
      pop es
-
 
139
      pop dx
-
 
140
      pop cx
-
 
141
      pop bx
-
 
142
      pop ax
-
 
143
    }
-
 
144
    if (cf == 0) {
-
 
145
      hnd->fhnd.handle = varax;  /* store handle finally :) */
-
 
146
      return hnd;
-
 
147
    }
-
 
148
 
-
 
149
    /* AX is supposed to contain 7100h if function not supported, else real error */
-
 
150
    /* However, FreeDOS returns AX = 1 = Invalid function number instead.         */
-
 
151
    if ((varax != 0x7100) && (varax != 0x0001)) {
-
 
152
      free(hnd);
-
 
153
      return INVALID_HANDLE_VALUE;
-
 
154
    }
-
 
155
  }
-
 
156
 
-
 
157
  /* Use DOS (0x4E) findfirst, returning if error */
91
  /* Use DOS (0x4E) findfirst, returning if error */
158
  hnd->flag = FINDFILEOLD;
92
  hnd->flag = FINDFILEOLD;
159
 
93
 
160
  /* allocate memory for the FFDTA */
94
  /* allocate memory for the FFDTA */
161
  if ((hnd->fhnd.ffdtaptr = (struct FFDTA *)malloc(sizeof(struct FFDTA))) == NULL)
95
  if ((hnd->fhnd.ffdtaptr = (struct FFDTA *)malloc(sizeof(struct FFDTA))) == NULL)
Line 397... Line 331...
397
    DWORD serial;
331
    DWORD serial;
398
    char volume[11];
332
    char volume[11];
399
    short ftype[8];
333
    short ftype[8];
400
  } media;
334
  } media;
401
 
335
 
402
  /* buffer to store file system name in lfn get volume information */
-
 
403
  char fsystem[32];
-
 
404
 
-
 
405
  /* Stores the root path we use. */
336
  /* Stores the root path we use. */
406
  char pathname[260];
337
  char pathname[260];
407
 
338
 
408
  /* Used to determine if drive valid (success/failure of this function)
-
 
409
   * 0 = success
-
 
410
   * 1 = failure
-
 
411
   * 2 = LFN api unsupported (tentative failure)
-
 
412
   */
-
 
413
  int cflag=2;
339
  unsigned short cflag;
414
 
340
 
415
  /* validate root path to obtain info on, NULL or "" means use current */
341
  /* validate root path to obtain info on, NULL or "" means use current */
416
  if ((lpRootPathName == NULL) || (*lpRootPathName == '\0')) {
342
  if ((lpRootPathName == NULL) || (*lpRootPathName == '\0')) {
417
    /* Assume if NULL user wants current drive, eg C:\ */
343
    /* Assume if NULL user wants current drive, eg C:\ */
418
    _asm {
344
    _asm {
Line 436... Line 362...
436
    }
362
    }
437
  } else {
363
  } else {
438
    strcpy(pathname, lpRootPathName);
364
    strcpy(pathname, lpRootPathName);
439
  }
365
  }
440
 
366
 
-
 
367
  /* if a drive, test if valid, get volume, and possibly serial # */
-
 
368
 
-
 
369
  /* assume these calls will succeed, change on an error */
-
 
370
  cflag = 0;
-
 
371
 
441
  /* Flag indicate if using LFN DOS or not */
372
  /* get path ending in \*.*, */
-
 
373
  if (pathname[strlen(pathname)-1] != '\\') {
-
 
374
    strcat(pathname, "\\*.*");
-
 
375
  } else {
442
  if (LFN_Enable_Flag)
376
    strcat(pathname, "*.*");
-
 
377
  }
-
 
378
 
-
 
379
  /* Search for volume using old findfirst, as LFN version (NT5 DOS box) does
-
 
380
   * not recognize FILE_ATTRIBUTE_LABEL = 0x0008 as label attribute.
-
 
381
   */
443
  {
382
  {
-
 
383
    struct FFDTA finfo;
-
 
384
    unsigned short attr_seg = FP_SEG(finfo.ff_attr);
-
 
385
    unsigned short attr_off = FP_OFF(finfo.ff_attr);
-
 
386
    unsigned short finfo_seg = FP_SEG(&finfo);
-
 
387
    unsigned short finfo_off = FP_OFF(&finfo);
-
 
388
    unsigned short pathname_seg = FP_SEG(pathname);
-
 
389
    unsigned short pathname_off = FP_OFF(pathname);
-
 
390
 
444
    _asm {
391
    _asm {
445
      push ax
392
      push ax
446
      push bx
393
      push bx
447
      push cx
394
      push cx
448
      push dx
395
      push dx
449
      push es
396
      push es
450
      push di
-
 
451
 
397
 
452
      mov ax, 0x71A0           //; LFN GetVolumeInformation
398
      mov ah, 0x2F              //; Get Current DTA
453
      mov dx, ds               //; Load buffer for file system name into ES:DI
399
      int 0x21                  //; Execute interrupt, returned in ES:BX
-
 
400
      push bx                   //; Store its Offset, then Segment
-
 
401
      push es
-
 
402
      mov ah, 0x1A              //; Set Current DTA to our buffer, DS:DX
-
 
403
      mov dx, finfo_off         //; Load our buffer for new DTA.
454
      MOV es, dx
404
      push ds
455
      lea di, fsystem
405
      mov ds, finfo_seg
456
      mov cx, 32               //; size of ES:DI buffer
406
      int 0x21                  //; Execute interrupt
-
 
407
      pop ds
457
      lea dx, pathname         //; Load root name into DS:DX
408
      mov ax, 0x4E00            //; Actual findfirst call
-
 
409
      mov cx, FILE_ATTRIBUTE_LABEL
-
 
410
      mov dx, pathname_off      //; Load DS:DX with pointer to modified RootPath for Findfirt
-
 
411
      push ds
-
 
412
      mov ds, pathname_seg
458
      stc                      //; in case LFN api unsupported
413
      int 0x21                  //; Execute interrupt, Carry set on error, unset on success
459
      int 0x21
414
      pop ds
460
      jc getvolerror           //; on any error skip storing any info
415
      jnc success               //; If carry is not set then succesful
461
      mov cflag, 0             //; indicate no error
416
      mov [cflag], ax           //; Set flag with error.
-
 
417
      jmp cleanup               //; Restore DTA
-
 
418
    success:                    //; True volume entry only has volume attribute set [MS' LFNspec]
462
      jmp endgetvol
419
      mov bx, attr_off
463
    /* store stuff
420
      push es
464
       BX = file system flags (see #01783)
421
      mov es, attr_seg
-
 
422
      mov al, [es:bx]              //; Looking for a BYTE that is FILE_ATTRIBUTE_LABEL only
-
 
423
      pop es
465
       CX = maximum length of file name [usually 255]
424
      and al, 0xDF              //; Ignore Archive bit
-
 
425
      cmp al, FILE_ATTRIBUTE_LABEL
-
 
426
      je cleanup                //; They match, so should be true volume entry.
-
 
427
      mov ax, 0x4F00            //; Otherwise keep looking (findnext)
466
       DX = maximum length of path [usually 260]
428
      int 0x21                  //; Execute interrupt
467
       fsystem buffer filled (ASCIZ, e.g. "FAT","NTFS","CDFS")
429
      jnc success               //; If carry is not set then succesful
468
    */
430
      mov [cflag], ax           //; Set flag with error.
469
getvolerror:
431
    cleanup:
470
      cmp ax, 0x7100           //; see if real error or unsupported
432
      mov ah, 0x1A              //; Set Current DTA back to original, DS:DX
471
      je endgetvol             //; if so skip ahead
433
      mov dx, ds                //; Store DS, must be preserved
472
      cmp ax, 0x0001           //; FreeDOS returns AX = 1 = Invalid function number
434
      pop ds                    //; Popping ES into DS since thats where we need it.
473
      je endgetvol
435
      pop bx                    //; Now DS:BX points to original DTA
474
      mov cflag, 1             //; indicate failure
436
      int 0x21                  //; Execute interrupt to restore.
475
endgetvol:
437
      mov ds, dx                //; Restore DS
476
 
438
 
477
      pop di
-
 
478
      pop es
439
      pop es
479
      pop dx
440
      pop dx
480
      pop cx
441
      pop cx
481
      pop bx
442
      pop bx
482
      pop ax
443
      pop ax
483
    }
444
    }
484
  }
-
 
485
 
445
 
486
 
-
 
487
  if (cflag != 1)  /* if no error validating volume info or LFN getVolInfo unsupported */
-
 
488
  {
-
 
489
    /* if a drive, test if valid, get volume, and possibly serial # */
-
 
490
    if (pathname[1] == ':') {
-
 
491
      struct FFDTA finfo;
-
 
492
      unsigned short attr_seg = FP_SEG(finfo.ff_attr);
-
 
493
      unsigned short attr_off = FP_OFF(finfo.ff_attr);
-
 
494
      unsigned short finfo_seg = FP_SEG(&finfo);
-
 
495
      unsigned short finfo_off = FP_OFF(&finfo);
-
 
496
      unsigned short pathname_seg = FP_SEG(pathname);
-
 
497
      unsigned short pathname_off = FP_OFF(pathname);
-
 
498
 
-
 
499
      /* assume these calls will succeed, change on an error */
-
 
500
      cflag = 0;
-
 
501
 
-
 
502
      /* get path ending in \*.*, */
-
 
503
      if (pathname[strlen(pathname)-1] != '\\')
-
 
504
	strcat(pathname, "\\*.*");
-
 
505
      else
-
 
506
	strcat(pathname, "*.*");
-
 
507
 
-
 
508
      /* Search for volume using old findfirst, as LFN version (NT5 DOS box) does
-
 
509
       * not recognize FILE_ATTRIBUTE_LABEL = 0x0008 as label attribute.
-
 
510
       */
-
 
511
      _asm {
-
 
512
        push ax
-
 
513
        push bx
-
 
514
        push cx
-
 
515
        push dx
-
 
516
        push es
-
 
517
 
-
 
518
        mov ah, 0x2F              //; Get Current DTA
-
 
519
        int 0x21                  //; Execute interrupt, returned in ES:BX
-
 
520
        push bx                   //; Store its Offset, then Segment
-
 
521
        push es
-
 
522
        mov ah, 0x1A              //; Set Current DTA to our buffer, DS:DX
-
 
523
        mov dx, finfo_off         //; Load our buffer for new DTA.
-
 
524
        push ds
-
 
525
        mov ds, finfo_seg
-
 
526
        int 0x21                  //; Execute interrupt
-
 
527
        pop ds
-
 
528
        mov ax, 0x4E00            //; Actual findfirst call
-
 
529
        mov cx, FILE_ATTRIBUTE_LABEL
-
 
530
        mov dx, pathname_off      //; Load DS:DX with pointer to modified RootPath for Findfirt
-
 
531
        push ds
-
 
532
        mov ds, pathname_seg
-
 
533
        int 0x21                  //; Execute interrupt, Carry set on error, unset on success
-
 
534
        pop ds
-
 
535
        jnc success               //; If carry is not set then succesful
-
 
536
        mov [cflag], ax           //; Set flag with error.
-
 
537
        jmp cleanup               //; Restore DTA
-
 
538
success:                        //; True volume entry only has volume attribute set [MS' LFNspec]
-
 
539
        mov bx, attr_off
-
 
540
        push es
-
 
541
        mov es, attr_seg
-
 
542
        mov al, [es:bx]              //; Looking for a BYTE that is FILE_ATTRIBUTE_LABEL only
-
 
543
        pop es
-
 
544
        and al, 0xDF              //; Ignore Archive bit
-
 
545
        cmp al, FILE_ATTRIBUTE_LABEL
-
 
546
        je cleanup                //; They match, so should be true volume entry.
-
 
547
        mov ax, 0x4F00            //; Otherwise keep looking (findnext)
-
 
548
        int 0x21                  //; Execute interrupt
-
 
549
        jnc success               //; If carry is not set then succesful
-
 
550
        mov [cflag], ax           //; Set flag with error.
-
 
551
cleanup:
-
 
552
        mov ah, 0x1A              //; Set Current DTA back to original, DS:DX
-
 
553
        mov dx, ds                //; Store DS, must be preserved
-
 
554
        pop ds                    //; Popping ES into DS since thats where we need it.
-
 
555
        pop bx                    //; Now DS:BX points to original DTA
-
 
556
        int 0x21                  //; Execute interrupt to restore.
-
 
557
        mov ds, dx                //; Restore DS
-
 
558
 
-
 
559
        pop es
-
 
560
        pop dx
-
 
561
        pop cx
-
 
562
        pop bx
-
 
563
        pop ax
-
 
564
      }
-
 
565
      /* copy over volume label, if buffer given */
446
    /* copy over volume label, if buffer given */
566
      if (lpVolumeNameBuffer != NULL)
447
    if (lpVolumeNameBuffer != NULL) {
567
      {
-
 
568
	if (cflag != 0)    /* error or no label */
448
      if (cflag != 0) {  /* error or no label */
569
	  lpVolumeNameBuffer[0] = '\0';
449
        lpVolumeNameBuffer[0] = '\0';
570
	else                        /* copy up to buffer's size of label */
450
      } else {                      /* copy up to buffer's size of label */
571
	{
-
 
572
	  strncpy(lpVolumeNameBuffer, finfo.ff_name, nVolumeNameSize);
451
        strncpy(lpVolumeNameBuffer, finfo.ff_name, nVolumeNameSize);
573
	  lpVolumeNameBuffer[nVolumeNameSize-1] = '\0';
452
        lpVolumeNameBuffer[nVolumeNameSize-1] = '\0';
574
          /* slide characters over if longer than 8 to remove . */
453
        /* slide characters over if longer than 8 to remove . */
575
          if (lpVolumeNameBuffer[8] == '.')
454
        if (lpVolumeNameBuffer[8] == '.') {
576
          {
-
 
577
            lpVolumeNameBuffer[8] = lpVolumeNameBuffer[9];
455
          lpVolumeNameBuffer[8] = lpVolumeNameBuffer[9];
578
            lpVolumeNameBuffer[9] = lpVolumeNameBuffer[10];
456
          lpVolumeNameBuffer[9] = lpVolumeNameBuffer[10];
579
            lpVolumeNameBuffer[10] = lpVolumeNameBuffer[11];
457
          lpVolumeNameBuffer[10] = lpVolumeNameBuffer[11];
580
            lpVolumeNameBuffer[11] = '\0';
458
          lpVolumeNameBuffer[11] = '\0';
581
          }
-
 
582
        }
459
        }
583
      }
460
      }
584
      /* Test for no label found, which is not an error,
-
 
585
         Note: added the check for 0x02 as FreeDOS returns this instead
-
 
586
         at least for disks with LFN entries and no volume label.
-
 
587
      */
461
    }
588
      if ((cflag == 0x12) || /* No more files or   */
-
 
589
          (cflag == 0x02))   /* File not found     */
-
 
590
        cflag = 0;       /* so assume valid drive  */
-
 
591
 
-
 
592
 
-
 
593
      /* Get Serial Number, only supports drives mapped to letters */
-
 
594
      media.serial = 0;         /* set to 0, stays 0 on an error */
-
 
595
      {
462
  }
596
        unsigned short media_off = FP_OFF(&media);
-
 
597
        unsigned short media_seg = FP_SEG(&media);
-
 
598
        unsigned char drv = (pathname[0] & 0xDF) - 'A' + 1;
-
 
599
      _asm {
-
 
600
        push ax
-
 
601
        push bx
-
 
602
        push cx
-
 
603
        push dx
-
 
604
 
-
 
605
        xor bh, bh
-
 
606
        mov bl, drv             //; Clear BH, drive in BL
-
 
607
        mov cx, 0x0866          //; CH=disk drive, CL=Get Serial #
-
 
608
        mov ax, 0x440D          //; Generic IOCTL
-
 
609
        mov dx, media_off       //; DS:DX pointer to media structure
-
 
610
        push ds
-
 
611
        mov ds, media_seg
-
 
612
        int 0x21
-
 
613
        pop ds
-
 
614
 
463
 
615
        pop dx
464
  /* Test for no label found, which is not an error,
616
        pop cx
465
     Note: added the check for 0x02 as FreeDOS returns this instead
617
        pop bx
466
     at least for disks with LFN entries and no volume label.
618
        pop ax
-
 
619
      }
467
  */
-
 
468
  if ((cflag == 0x12) || /* No more files or   */
-
 
469
      (cflag == 0x02)) {  /* File not found     */
-
 
470
    cflag = 0;       /* so assume valid drive  */
620
      }
471
  }
621
 
472
 
622
/***************** Replaced with 'documented' version of Get Serial Number *********************/
473
  /* Get Serial Number, only supports drives mapped to letters */
623
      /* NT2000pro does NOT set or clear the carry for int21h subfunction 6900h
474
  media.serial = 0;         /* set to 0, stays 0 on an error */
-
 
475
  {
-
 
476
    unsigned short media_off = FP_OFF(&media);
624
       *   if an error occurs, it leaves media unchanged.
477
    unsigned short media_seg = FP_SEG(&media);
-
 
478
    unsigned char drv = (pathname[0] & 0xDF) - 'A' + 1;
-
 
479
    _asm {
625
       */
480
      push ax
626
//      asm {
481
      push bx
627
//        MOV AX, 0x6900
482
      push cx
628
//        INT 21h                 //; Should set carry on error, clear on success [note NT5 does not]
-
 
629
//      }
483
      push dx
630
/***************** End with 'undocumented' version of Get Serial Number *********************/
-
 
631
 
484
 
-
 
485
      xor bh, bh
632
      if (lpVolumeSerialNumber != NULL)
486
      mov bl, drv             //; Clear BH, drive in BL
633
        *lpVolumeSerialNumber = media.serial;
487
      mov cx, 0x0866          //; CH=disk drive, CL=Get Serial #
634
    }
488
      mov ax, 0x440D          //; Generic IOCTL
635
    else /* a network drive, assume results of LFN getVolInfo, no volume or serial [for now] */
489
      mov dx, media_off       //; DS:DX pointer to media structure
636
    {
490
      push ds
637
      if (lpVolumeNameBuffer != NULL)
491
      mov ds, media_seg
-
 
492
      int 0x21
638
        lpVolumeNameBuffer[0] = '\0';
493
      pop ds
639
 
494
 
-
 
495
      pop dx
640
      if (lpVolumeSerialNumber != NULL)
496
      pop cx
641
        *lpVolumeSerialNumber = 0x0;
497
      pop bx
-
 
498
      pop ax
642
    }
499
    }
643
  }
500
  }
644
 
501
 
-
 
502
  if (lpVolumeSerialNumber != NULL) *lpVolumeSerialNumber = media.serial;
-
 
503
 
645
  /* If there was an error getting the validating drive return failure) */
504
  /* If there was an error getting the validating drive return failure) */
646
  if (cflag)    /* cflag is nonzero on any errors */
505
  if (cflag) {  /* cflag is nonzero on any errors )*/
647
    return 0;   /* zero means error! */
506
    return 0;   /* zero means error! */
648
  else
507
  } else {
649
    return 1;   /* Success (drive exists we think anyway) */
508
    return 1;   /* Success (drive exists we think anyway) */
-
 
509
  }
650
}
510
}
651
 
511
 
652
 
512
 
653
/* retrieve attributes (ReadOnly/System/...) about file or directory
513
/* retrieve attributes (ReadOnly/System/...) about file or directory
654
 * returns (DWORD)-1 on error
514
 * returns (DWORD)-1 on error
Line 657... Line 517...
657
  union REGS r;
517
  union REGS r;
658
  struct SREGS s;
518
  struct SREGS s;
659
  char buffer[260];
519
  char buffer[260];
660
  int slen;
520
  int slen;
661
 
521
 
662
  /* 1st try LFN - Extended get/set attributes (in case LFN used) */
-
 
663
  if (LFN_Enable_Flag)
-
 
664
  {
-
 
665
    r.x.ax = 0x7143;                  /* LFN API, Extended Get/Set Attributes */
-
 
666
    r.x.bx = 0x00;                    /* BL=0, get file attributes            */
-
 
667
    r.x.dx = FP_OFF(pathname);        /* DS:DX points to ASCIIZ filename      */
-
 
668
 
-
 
669
    segread(&s);                      /* load with current segment values     */
-
 
670
    s.ds = FP_SEG(pathname);          /* get Segment of our filename pointer  */
-
 
671
 
-
 
672
    r.x.cflag = 1;                    /* should be set when unsupported ***   */
-
 
673
    _asm stc;                          /* but clib usually ignores on entry    */
-
 
674
 
-
 
675
    /* Actually perform the call, carry should be set on error or unuspported */
-
 
676
    intdosx(&r, &r, &s);         /* Clib function to invoke DOS int21h call   */
-
 
677
 
-
 
678
    if (!r.x.cflag)              /* if carry not set then cx has desired info */
-
 
679
      return (DWORD)r.x.cx;
-
 
680
    /* else error other than unsupported LFN api or invalid function [FreeDOS]*/
-
 
681
    else if ((r.x.ax != 0x7100) || (r.x.ax != 0x01))
-
 
682
      return (DWORD)-1;
-
 
683
    /* else fall through to standard get/set file attribute call */
-
 
684
  }
-
 
685
 
-
 
686
  /* we must remove any slashes from end */
522
  /* we must remove any slashes from end */
687
  slen = strlen(pathname) - 1;  /* Warning, assuming pathname is not ""   */
523
  slen = strlen(pathname) - 1;  /* Warning, assuming pathname is not ""   */
688
  strcpy(buffer, pathname);
524
  strcpy(buffer, pathname);
689
  if ((buffer[slen] == '\\') || (buffer[slen] == '/')) /* ends in a slash */
525
  if ((buffer[slen] == '\\') || (buffer[slen] == '/')) { /* ends in a slash */
690
  {
-
 
691
    /* don't remove from root directory (slen == 0),
526
    /* don't remove from root directory (slen == 0),
692
     * ignore UNC paths as SFN doesn't handle them anyway
527
     * ignore UNC paths as SFN doesn't handle them anyway
693
     * if slen == 2, then check if drive given (e.g. C:\)
528
     * if slen == 2, then check if drive given (e.g. C:\)
694
     */
529
     */
695
    if (slen && !(slen == 2 &&  buffer[1] == ':'))
530
    if (slen && !(slen == 2 &&  buffer[1] == ':'))