Subversion Repositories SvarDOS

Rev

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

Rev 2200 Rev 2201
Line 476... Line 476...
476
 
476
 
477
  return(0);
477
  return(0);
478
}
478
}
479
 
479
 
480
 
480
 
-
 
481
static void dir_print_summary_files(char *buff64, unsigned short uint32maxlen, unsigned long summary_totsz, unsigned long summary_fcount, unsigned short *availrows, unsigned char flags, const struct nls_patterns *nls) {
-
 
482
  unsigned short i;
-
 
483
  /* x file(s) (maximum of files in a FAT-32 directory is 65'535) */
-
 
484
  memset(buff64, ' ', 8);
-
 
485
  i = nls_format_number(buff64 + 8, summary_fcount, nls);
-
 
486
  sprintf(buff64 + 8 + i, " %s ", svarlang_str(37,22)/*"file(s)"*/);
-
 
487
  output(buff64 + i);
-
 
488
  /* xxxx bytes */
-
 
489
  memset(buff64, ' ', 14);
-
 
490
  i = nls_format_number(buff64 + uint32maxlen, summary_totsz, nls);
-
 
491
  output(buff64 + i + 1);
-
 
492
  output(" ");
-
 
493
  nls_outputnl(37,23); /* "bytes" */
-
 
494
  if (flags & DIR_FLAG_PAUSE) dir_pagination(availrows);
-
 
495
}
-
 
496
 
-
 
497
 
481
#define MAX_SORTABLE_FILES 8192
498
#define MAX_SORTABLE_FILES 8192
482
 
499
 
483
static enum cmd_result cmd_dir(struct cmd_funcparam *p) {
500
static enum cmd_result cmd_dir(struct cmd_funcparam *p) {
484
  struct DTA *dta = (void *)0x80; /* set DTA to its default location at 80h in PSP */
501
  struct DTA *dta = (void *)0x80; /* set DTA to its default location at 80h in PSP */
485
  struct TINYDTA far *dtabuf = NULL; /* used to buffer results when sorting is enabled */
502
  struct TINYDTA far *dtabuf = NULL; /* used to buffer results when sorting is enabled */
Line 495... Line 512...
495
    char path[128];
512
    char path[128];
496
    struct DTA dtastack[64]; /* used for /S, max number of subdirs in DOS5 is 42 (A/B/C/...) */
513
    struct DTA dtastack[64]; /* used for /S, max number of subdirs in DOS5 is 42 (A/B/C/...) */
497
    unsigned char dtastacklen;
514
    unsigned char dtastacklen;
498
    unsigned short orderidx[MAX_SORTABLE_FILES / sizeof(struct TINYDTA)];
515
    unsigned short orderidx[MAX_SORTABLE_FILES / sizeof(struct TINYDTA)];
499
  } *buf;
516
  } *buf;
-
 
517
  unsigned long summary_recurs_fcount = 0; /* used for /s global summary */
-
 
518
  unsigned long summary_recurs_totsz = 0;  /* used for /s global summary */
500
  unsigned long summary_fcount = 0;
519
  unsigned long summary_fcount;
501
  unsigned long summary_totsz = 0;
520
  unsigned long summary_totsz;
502
  unsigned char drv = 0;
521
  unsigned char drv = 0;
503
  struct dirrequest req;
522
  struct dirrequest req;
504
  unsigned short summary_alignpos;
523
  unsigned short summary_alignpos = strlen(svarlang_str(37,22)) + 2;
505
  unsigned short uint32maxlen = 14; /* 13 is the max len of a 32 bit number with thousand separators (4'000'000'000) */
524
  unsigned short uint32maxlen = 14; /* 13 is the max len of a 32 bit number with thousand separators (4'000'000'000) */
506
  if (screenw < 80) uint32maxlen = 10;
525
  if (screenw < 80) uint32maxlen = 10;
507
 
526
 
508
  if (cmd_ishlp(p)) {
527
  if (cmd_ishlp(p)) {
509
    nls_outputnl(37,0); /* "Displays a list of files and subdirectories in a directory" */
528
    nls_outputnl(37,0); /* "Displays a list of files and subdirectories in a directory" */
Line 669... Line 688...
669
    cmd_vol_internal(drv, buf->buff64);
688
    cmd_vol_internal(drv, buf->buff64);
670
  }
689
  }
671
 
690
 
672
  NEXT_ITER: /* re-entry point for /S recursing */
691
  NEXT_ITER: /* re-entry point for /S recursing */
673
 
692
 
-
 
693
  summary_fcount = 0;
-
 
694
  summary_totsz = 0;
-
 
695
 
674
  if (req.format != DIR_OUTPUT_BARE) {
696
  if (req.format != DIR_OUTPUT_BARE) {
675
    sprintf(buf->buff64, svarlang_str(37,20)/*"Directory of %s"*/, buf->path);
697
    sprintf(buf->buff64, svarlang_str(37,20)/*"Directory of %s"*/, buf->path);
676
    /* trim at first '?', if any */
698
    /* trim at first '?', if any */
677
    for (i = 0; buf->buff64[i] != 0; i++) if (buf->buff64[i] == '?') buf->buff64[i] = 0;
699
    for (i = 0; buf->buff64[i] != 0; i++) if (buf->buff64[i] == '?') buf->buff64[i] = 0;
678
    outputnl(buf->buff64);
700
    outputnl(buf->buff64);
Line 852... Line 874...
852
    if (req.flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
874
    if (req.flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
853
  }
875
  }
854
 
876
 
855
  /* print out summary (unless bare output mode) */
877
  /* print out summary (unless bare output mode) */
856
  if (req.format != DIR_OUTPUT_BARE) {
878
  if (req.format != DIR_OUTPUT_BARE) {
857
    /* x file(s) (maximum of files in a FAT-32 directory is 65'535) */
-
 
858
    memset(buf->buff64, ' ', 8);
-
 
859
    i = nls_format_number(buf->buff64 + 8, summary_fcount, &(buf->nls));
-
 
860
    summary_alignpos = sprintf(buf->buff64 + 8 + i, " %s ", svarlang_str(37,22)/*"file(s)"*/);
-
 
861
    output(buf->buff64 + i);
-
 
862
    /* xxxx bytes */
-
 
863
    memset(buf->buff64, ' ', 14);
-
 
864
    i = nls_format_number(buf->buff64 + uint32maxlen, summary_totsz, &(buf->nls));
879
    dir_print_summary_files(buf->buff64, uint32maxlen, summary_totsz, summary_fcount, &availrows, req.flags, &(buf->nls));
865
    output(buf->buff64 + i + 1);
-
 
866
    output(" ");
-
 
867
    nls_outputnl(37,23); /* "bytes" */
-
 
868
    if (req.flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
-
 
869
  }
880
  }
870
 
881
 
-
 
882
  /* update global counters in case /s is used */
-
 
883
  summary_recurs_fcount += summary_fcount;
-
 
884
  summary_recurs_totsz += summary_totsz;
-
 
885
 
871
  /* /S processing */
886
  /* /S processing */
872
  CHECK_RECURS:
887
  CHECK_RECURS:
873
  /* if /S then look for a subdir */
888
  /* if /S then look for a subdir */
874
  if (req.flags & DIR_FLAG_RECUR) {
889
  if (req.flags & DIR_FLAG_RECUR) {
875
    /* do the findfirst on *.* instead of reusing the user filter */
890
    /* do the findfirst on *.* instead of reusing the user filter */
Line 911... Line 926...
911
    goto NEXT_ITER;
926
    goto NEXT_ITER;
912
  }
927
  }
913
 
928
 
914
  /* print out disk space available (unless bare output mode) */
929
  /* print out disk space available (unless bare output mode) */
915
  if (req.format != DIR_OUTPUT_BARE) {
930
  if (req.format != DIR_OUTPUT_BARE) {
-
 
931
    /* if /s mode then print also global stats */
-
 
932
    if (req.flags & DIR_FLAG_RECUR) {
-
 
933
      nls_outputnl(37,25); /* Total files listed: */
-
 
934
      if (req.flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
-
 
935
      dir_print_summary_files(buf->buff64, uint32maxlen, summary_recurs_totsz, summary_recurs_fcount, &availrows, req.flags, &(buf->nls));
-
 
936
    }
916
    /* xxxx bytes free */
937
    /* xxxx bytes free */
917
    i = cmd_dir_df(&summary_totsz, drv);
938
    i = cmd_dir_df(&summary_totsz, drv);
918
    if (i != 0) nls_outputnl_doserr(i);
939
    if (i != 0) nls_outputnl_doserr(i);
919
    memset(buf->buff64, ' ', summary_alignpos + 8 + uint32maxlen); /* align the freebytes value to same column as totbytes */
940
    memset(buf->buff64, ' ', summary_alignpos + 8 + uint32maxlen); /* align the freebytes value to same column as totbytes */
920
    i = nls_format_number(buf->buff64 + summary_alignpos + 8 + uint32maxlen, summary_totsz, &(buf->nls));
941
    i = nls_format_number(buf->buff64 + summary_alignpos + 8 + uint32maxlen, summary_totsz, &(buf->nls));