Subversion Repositories SvarDOS

Rev

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

Rev 2060 Rev 2061
Line 42... Line 42...
42
#include <stdio.h>
42
#include <stdio.h>
43
#include <string.h>
43
#include <string.h>
44
 
44
 
45
#include "stack.h"
45
#include "stack.h"
46
 
46
 
47
/* DOS disk accesses */
-
 
48
#include "dosdisk.h"
-
 
49
 
-
 
50
 
-
 
51
/* The default extended forms of the lines used. */
47
/* The default extended forms of the lines used. */
52
#define VERTBAR_STR  "\xB3   "                 /* |    */
48
#define VERTBAR_STR  "\xB3   "                 /* |    */
53
#define TBAR_HORZBAR_STR "\xC3\xC4\xC4\xC4"    /* +--- */
49
#define TBAR_HORZBAR_STR "\xC3\xC4\xC4\xC4"    /* +--- */
54
#define CBAR_HORZBAR_STR "\xC0\xC4\xC4\xC4"    /* \--- */
50
#define CBAR_HORZBAR_STR "\xC0\xC4\xC4\xC4"    /* \--- */
55
 
51
 
Line 190... Line 186...
190
"DONE:" \
186
"DONE:" \
191
modify [ax bx dx] \
187
modify [ax bx dx] \
192
value [al]
188
value [al]
193
 
189
 
194
 
190
 
-
 
191
static _Packed struct {
-
 
192
  unsigned short infolevel;
-
 
193
  unsigned short serial2;
-
 
194
  unsigned short serial1;
-
 
195
  char label[11];
-
 
196
  short fstype[8];
-
 
197
} glob_drv_info;
-
 
198
 
-
 
199
/* drv is 1-based (A=1, B=2, ...) */
-
 
200
static void getdrvserial(unsigned char drv);
-
 
201
#pragma aux getdrvserial = \
-
 
202
"push ds" \
-
 
203
"xor bh, bh" \
-
 
204
"mov dx, offset glob_drv_info" \
-
 
205
"mov ax, seg glob_drv_info" \
-
 
206
"mov ds, ax" \
-
 
207
"mov ax, 0x6900" \
-
 
208
"int 0x21" \
-
 
209
"pop ds" \
-
 
210
parm [bl] \
-
 
211
modify [ax bx dx]
-
 
212
 
-
 
213
 
195
static int truename(char *path, const char *origpath) {
214
static int truename(char *path, const char *origpath) {
196
  unsigned short origpath_seg = FP_SEG(origpath);
215
  unsigned short origpath_seg = FP_SEG(origpath);
197
  unsigned short origpath_off = FP_OFF(origpath);
216
  unsigned short origpath_off = FP_OFF(origpath);
198
  unsigned short dstpath_seg = FP_SEG(path);
217
  unsigned short dstpath_seg = FP_SEG(path);
199
  unsigned short dstpath_off = FP_OFF(path);
218
  unsigned short dstpath_off = FP_OFF(path);
Line 524... Line 543...
524
 
543
 
525
 
544
 
526
/**
545
/**
527
 * Fills in the serial and volume variables with the serial #
546
 * Fills in the serial and volume variables with the serial #
528
 * and volume found using path.
547
 * and volume found using path.
529
 * If there is an error getting the volume & serial#, then an
-
 
530
 * error message is displayed and the program exits.
-
 
531
 * Volume and/or serial # returned may be blank if the path specified
-
 
532
 * does not contain them, or an error retrieving
-
 
533
 * (ie UNC paths under DOS), but path is valid.
-
 
534
 */
548
 */
535
static void GetVolumeAndSerial(char *volume, char *serial, char *path) {
549
static void GetVolumeAndSerial(char *volume, char *serial, char *path) {
536
  char rootPath[PATH_MAX];
550
  getdrvserial((path[0] & 0xDF) - '@');
537
  char dummy[PATH_MAX];
-
 
538
  union serialNumber {
-
 
539
    unsigned long serialFull;
551
  memcpy(volume, glob_drv_info.label, 12);
540
    struct {
-
 
541
      unsigned short a;
-
 
542
      unsigned short b;
-
 
543
    } serialParts;
552
  volume[11] = 0;
544
  } serialNum;
-
 
545
 
-
 
546
  /* get drive letter or share server\name */
-
 
547
  splitpath(path, rootPath, dummy);
-
 
548
  strcat(rootPath, "\\");
-
 
549
 
553
 
550
  if (GetVolumeInformation(rootPath, volume, VOLLEN, &serialNum.serialFull) == 0) {
-
 
551
    showInvalidDrive();
-
 
552
  }
-
 
553
 
-
 
554
  if (serialNum.serialFull == 0) {
-
 
555
    serial[0] = '\0';
-
 
556
  } else {
-
 
557
    sprintf(serial, "%04X:%04X", serialNum.serialParts.b, serialNum.serialParts.a);
554
  sprintf(serial, "%04X:%04X", glob_drv_info.serial1, glob_drv_info.serial2);
558
  }
-
 
559
}
555
}
560
 
556
 
561
 
557
 
562
/**
558
/**
563
 * Stores directory information obtained from FindFirst/Next that
559
 * Stores directory information obtained from FindFirst/Next that
Line 607... Line 603...
607
    return(-1);
603
    return(-1);
608
  }
604
  }
609
 
605
 
610
  /*  cycle through entries counting directories found until no more entries */
606
  /*  cycle through entries counting directories found until no more entries */
611
  do {
607
  do {
612
    if (((findData.attrib & FILE_A_SUBDIR) != 0) &&
608
    if (((findData.attrib & _A_SUBDIR) != 0) &&
613
        ((findData.attrib &
609
        ((findData.attrib &
614
         (FILE_A_HIDDEN | FILE_A_SYSTEM)) == 0 || dspAll) ) {
610
         (_A_HIDDEN | _A_SYSTEM)) == 0 || dspAll) ) {
615
      if (findData.name[0] != '.') { /* ignore '.' and '..' */
611
      if (findData.name[0] != '.') { /* ignore '.' and '..' */
616
        hasSubdirs++;      /* subdir of initial path found, so increment counter */
612
        hasSubdirs++;      /* subdir of initial path found, so increment counter */
617
      }
613
      }
618
    }
614
    }
619
  } while(_dos_findnext(&findData) == 0);
615
  } while(_dos_findnext(&findData) == 0);
Line 798... Line 794...
798
  }
794
  }
799
 
795
 
800
  /* optional display data */
796
  /* optional display data */
801
  if (dspAttr)  /* attributes */
797
  if (dspAttr)  /* attributes */
802
    pprintf("[%c%c%c%c%c] ",
798
    pprintf("[%c%c%c%c%c] ",
803
      (ddata->attrib & FILE_A_SUBDIR)?'D':' ',  /* keep this one? its always true */
799
      (ddata->attrib & _A_SUBDIR)?'D':' ',  /* keep this one? its always true */
804
      (ddata->attrib & FILE_A_ARCH)?'A':' ',
800
      (ddata->attrib & _A_ARCH)?'A':' ',
805
      (ddata->attrib & FILE_A_SYSTEM)?'S':' ',
801
      (ddata->attrib & _A_SYSTEM)?'S':' ',
806
      (ddata->attrib & FILE_A_HIDDEN)?'H':' ',
802
      (ddata->attrib & _A_HIDDEN)?'H':' ',
807
      (ddata->attrib & FILE_A_RDONLY)?'R':' '
803
      (ddata->attrib & _A_RDONLY)?'R':' '
808
    );
804
    );
809
 
805
 
810
  /* display directory name */
806
  /* display directory name */
811
  pprintf("%s\n", currentpath);
807
  pprintf("%s\n", currentpath);
812
}
808
}
Line 856... Line 852...
856
 
852
 
857
  /* cycle through directory printing out files. */
853
  /* cycle through directory printing out files. */
858
  do
854
  do
859
  {
855
  {
860
    /* print padding followed by filename */
856
    /* print padding followed by filename */
861
    if ( ((entry.attrib & FILE_A_SUBDIR) == 0) &&
857
    if ( ((entry.attrib & _A_SUBDIR) == 0) &&
862
         ( ((entry.attrib & (FILE_A_HIDDEN | FILE_A_SYSTEM)) == 0)  || dspAll) )
858
         ( ((entry.attrib & (_A_HIDDEN | _A_SYSTEM)) == 0)  || dspAll) )
863
    {
859
    {
864
      /* print lead padding */
860
      /* print lead padding */
865
      pprintf("%s", padding);
861
      pprintf("%s", padding);
866
 
862
 
867
      /* optional display data */
863
      /* optional display data */
868
      if (dspAttr)  /* file attributes */
864
      if (dspAttr)  /* file attributes */
869
        pprintf("[%c%c%c%c] ",
865
        pprintf("[%c%c%c%c] ",
870
          (entry.attrib & FILE_A_ARCH)?'A':' ',
866
          (entry.attrib & _A_ARCH)?'A':' ',
871
          (entry.attrib & FILE_A_SYSTEM)?'S':' ',
867
          (entry.attrib & _A_SYSTEM)?'S':' ',
872
          (entry.attrib & FILE_A_HIDDEN)?'H':' ',
868
          (entry.attrib & _A_HIDDEN)?'H':' ',
873
          (entry.attrib & FILE_A_RDONLY)?'R':' '
869
          (entry.attrib & _A_RDONLY)?'R':' '
874
        );
870
        );
875
 
871
 
876
      if (dspSize) { /* file size */
872
      if (dspSize) { /* file size */
877
        if (entry.size < 1048576ul)  /* if less than a MB, display in bytes */
873
        if (entry.size < 1048576ul)  /* if less than a MB, display in bytes */
878
          pprintf("%10lu ", entry.size);
874
          pprintf("%10lu ", entry.size);
Line 911... Line 907...
911
 */
907
 */
912
static struct find_t *cycleFindResults(struct find_t *entry, char *subdir, char *dsubdir) {
908
static struct find_t *cycleFindResults(struct find_t *entry, char *subdir, char *dsubdir) {
913
  /* cycle through directory until 1st non . or .. directory is found. */
909
  /* cycle through directory until 1st non . or .. directory is found. */
914
  for (;;) {
910
  for (;;) {
915
    /* skip files & hidden or system directories */
911
    /* skip files & hidden or system directories */
916
    if ((((entry->attrib & FILE_A_SUBDIR) == 0) ||
912
    if ((((entry->attrib & _A_SUBDIR) == 0) ||
917
         ((entry->attrib &
913
         ((entry->attrib &
918
          (FILE_A_HIDDEN | FILE_A_SYSTEM)) != 0  && !dspAll) ) ||
914
          (_A_HIDDEN | _A_SYSTEM)) != 0  && !dspAll) ) ||
919
        (entry->name[0] == '.')) {
915
        (entry->name[0] == '.')) {
920
      if (_dos_findnext(entry) != 0) {
916
      if (_dos_findnext(entry) != 0) {
921
        _dos_findclose(entry);      // prevent resource leaks
917
        _dos_findclose(entry);      // prevent resource leaks
922
        return(NULL); // no subdirs found
918
        return(NULL); // no subdirs found
923
      }
919
      }