Subversion Repositories SvarDOS

Rev

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

Rev 2196 Rev 2197
Line 492... Line 492...
492
  struct {
492
  struct {
493
    struct nls_patterns nls;
493
    struct nls_patterns nls;
494
    char buff64[64];
494
    char buff64[64];
495
    char path[128];
495
    char path[128];
496
    struct DTA dtastack[64]; /* used for /S, max number of subdirs in DOS5 is 42 (A/B/C/...) */
496
    struct DTA dtastack[64]; /* used for /S, max number of subdirs in DOS5 is 42 (A/B/C/...) */
497
    unsigned char dirpending; /* set if a dir has been added to dtastack */
-
 
498
    unsigned char dtastacklen;
497
    unsigned char dtastacklen;
499
    unsigned short orderidx[MAX_SORTABLE_FILES / sizeof(struct TINYDTA)];
498
    unsigned short orderidx[MAX_SORTABLE_FILES / sizeof(struct TINYDTA)];
500
  } *buf;
499
  } *buf;
501
  unsigned long summary_fcount = 0;
500
  unsigned long summary_fcount = 0;
502
  unsigned long summary_totsz = 0;
501
  unsigned long summary_totsz = 0;
Line 678... Line 677...
678
  /* if ends with a \ then append ????????.??? */
677
  /* if ends with a \ then append ????????.??? */
679
  if (buf->path[i - 1] == '\\') strcat(buf->path, "????????.???");
678
  if (buf->path[i - 1] == '\\') strcat(buf->path, "????????.???");
680
 
679
 
681
  NEXT_ITER: /* re-entry point for /S recursing */
680
  NEXT_ITER: /* re-entry point for /S recursing */
682
 
681
 
683
  /* ask DOS for list of files, but only with allowed attribs (+directories, because
682
  /* ask DOS for list of files, but only with allowed attribs */
684
   * I need them for /S) */
-
 
685
  i = findfirst(dta, buf->path, req.attrfilter_may | DIR_FLAG_RECUR);
683
  i = findfirst(dta, buf->path, req.attrfilter_may);
686
  if (i != 0) {
684
  if (i != 0) {
-
 
685
    if (req.flags & DIR_FLAG_RECUR) goto CHECK_RECURS;
687
    nls_outputnl_doserr(i);
686
    nls_outputnl_doserr(i);
688
    goto FAIL;
687
    goto FAIL;
689
  }
688
  }
690
 
689
 
691
  /* if sorting is involved, then let's buffer all results (and sort them) */
690
  /* if sorting is involved, then let's buffer all results (and sort them) */
Line 707... Line 706...
707
 
706
 
708
    /* remember the address so I can free it afterwards */
707
    /* remember the address so I can free it afterwards */
709
    glob_sortcmp_dat.dtabuf_root = dtabuf;
708
    glob_sortcmp_dat.dtabuf_root = dtabuf;
710
 
709
 
711
    do {
710
    do {
712
      /* if /S then remember first directory encountered (but not . nor ..) */
-
 
713
      if ((req.flags & DIR_FLAG_RECUR) && (buf->dirpending == 0) && (dta->attr & DOS_ATTR_DIR) && (dta->fname[0] != '.')) {
-
 
714
        buf->dirpending = 1;
-
 
715
        memcpy_ltr(&(buf->dtastack[buf->dtastacklen]), dta, sizeof(struct DTA));
-
 
716
      }
-
 
717
 
-
 
718
      /* filter out files with uninteresting attributes */
711
      /* filter out files with uninteresting attributes */
719
      if (filter_attribs(dta, req.attrfilter_must, req.attrfilter_may) == 0) continue;
712
      if (filter_attribs(dta, req.attrfilter_must, req.attrfilter_may) == 0) continue;
720
 
713
 
721
      /* normalize "size" of directories to zero because kernel returns garbage
714
      /* normalize "size" of directories to zero because kernel returns garbage
722
       * sizes for directories which might confuse the sorting routine later */
715
       * sizes for directories which might confuse the sorting routine later */
Line 758... Line 751...
758
 
751
 
759
  wcolcount = 0; /* may be used for columns counting with wide mode */
752
  wcolcount = 0; /* may be used for columns counting with wide mode */
760
 
753
 
761
  for (;;) {
754
  for (;;) {
762
 
755
 
763
    /* if /S then remember first directory encountered */
-
 
764
      if ((req.flags & DIR_FLAG_RECUR) && (buf->dirpending == 0) && (dta->attr & DOS_ATTR_DIR) && (dta->fname[0] != '.')) {
-
 
765
      buf->dirpending = 1;
-
 
766
      puts("GOT DIR (/S)");
-
 
767
      memcpy_ltr(&(buf->dtastack[buf->dtastacklen]), dta, sizeof(struct DTA));
-
 
768
    }
-
 
769
 
-
 
770
    /* filter out attributes (skip if entry comes from buffer, then it was already veted) */
756
    /* filter out attributes (skip if entry comes from buffer, then it was already veted) */
771
    if (filter_attribs(dta, req.attrfilter_must, req.attrfilter_may) == 0) goto NEXT_ENTRY;
757
    if (filter_attribs(dta, req.attrfilter_must, req.attrfilter_may) == 0) goto NEXT_ENTRY;
772
 
758
 
773
    /* turn string lcase (/L) */
759
    /* turn string lcase (/L) */
774
    if (req.flags & DIR_FLAG_LCASE) _strlwr(dta->fname); /* OpenWatcom extension, probably does not care about NLS so results may be odd with non-A-Z characters... */
760
    if (req.flags & DIR_FLAG_LCASE) _strlwr(dta->fname); /* OpenWatcom extension, probably does not care about NLS so results may be odd with non-A-Z characters... */
Line 889... Line 875...
889
    nls_outputnl(37,24); /* "bytes free" */
875
    nls_outputnl(37,24); /* "bytes free" */
890
    if (req.flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
876
    if (req.flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
891
  }
877
  }
892
 
878
 
893
  /* /S processing */
879
  /* /S processing */
-
 
880
  CHECK_RECURS:
-
 
881
  /* if /S then look for a subdir */
894
  if (buf->dirpending) {
882
  if (req.flags & DIR_FLAG_RECUR) {
-
 
883
    /* do the findfirst on *.* instead of reusing the user filter */
-
 
884
    char *s;
895
    buf->dirpending = 0;
885
    char backup[4];
-
 
886
    printf("orig path='%s' new=", buf->path);
896
    /* add dir to path and redo scan */
887
    for (s = buf->path; *s != 0; s++);
-
 
888
    for (; s[-1] != '\\'; s--);
-
 
889
    memcpy_ltr(backup, s, 4);
-
 
890
    memcpy_ltr(s, "*.*", 4);
-
 
891
    printf("'%s'\n", buf->path);
-
 
892
    if (findfirst(dta, buf->path, DOS_ATTR_DIR) == 0) {
-
 
893
      memcpy_ltr(s, backup, 4);
-
 
894
      for (;;) {
-
 
895
        if ((dta->fname[0] != '.') && (dta->attr & DOS_ATTR_DIR)) break;
-
 
896
        if (findnext(dta) != 0) goto NOSUBDIR;
-
 
897
      }
897
    printf("DIR PENDING: %s\n", buf->dtastack[buf->dtastacklen].fname);
898
      printf("GOT DIR (/S): '%s'\n", dta->fname);
-
 
899
      /* add dir to path and redo scan */
898
    path_add(buf->path, buf->dtastack[buf->dtastacklen].fname);
900
      memcpy_ltr(&(buf->dtastack[buf->dtastacklen]), dta, sizeof(struct DTA));
899
    buf->dtastacklen++;
901
      buf->dtastacklen++;
-
 
902
      path_add(buf->path, dta->fname);
900
    goto NEXT_ITER;
903
      goto NEXT_ITER;
-
 
904
    }
-
 
905
    memcpy_ltr(s, backup, 4);
901
  }
906
  }
-
 
907
  NOSUBDIR:
-
 
908
 
902
  while (buf->dtastacklen > 0) {
909
  while (buf->dtastacklen > 0) {
903
    /* rewind path one directory back, pop the next dta and do a FindNext */
910
    /* rewind path one directory back, pop the next dta and do a FindNext */
904
    path_back(buf->path);
911
    path_back(buf->path);
905
    buf->dtastacklen--;
912
    buf->dtastacklen--;
906
    TRYNEXTENTRY:
913
    TRYNEXTENTRY: