Line 499... |
Line 499... |
499 |
} *buf;
|
499 |
} *buf;
|
500 |
unsigned long summary_fcount = 0;
|
500 |
unsigned long summary_fcount = 0;
|
501 |
unsigned long summary_totsz = 0;
|
501 |
unsigned long summary_totsz = 0;
|
502 |
unsigned char drv = 0;
|
502 |
unsigned char drv = 0;
|
503 |
struct dirrequest req;
|
503 |
struct dirrequest req;
|
- |
|
504 |
unsigned short summary_alignpos;
|
- |
|
505 |
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;
|
504 |
|
507 |
|
505 |
if (cmd_ishlp(p)) {
|
508 |
if (cmd_ishlp(p)) {
|
506 |
nls_outputnl(37,0); /* "Displays a list of files and subdirectories in a directory" */
|
509 |
nls_outputnl(37,0); /* "Displays a list of files and subdirectories in a directory" */
|
507 |
outputnl("");
|
510 |
outputnl("");
|
508 |
nls_outputnl(37,1); /* "DIR [drive:][path][filename] [/P] [/W] [/A[:]attributes] [/O[[:]sortorder]] [/S] [/B] [/L]" */
|
511 |
nls_outputnl(37,1); /* "DIR [drive:][path][filename] [/P] [/W] [/A[:]attributes] [/O[[:]sortorder]] [/S] [/B] [/L]" */
|
Line 849... |
Line 852... |
849 |
if (req.flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
|
852 |
if (req.flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
|
850 |
}
|
853 |
}
|
851 |
|
854 |
|
852 |
/* print out summary (unless bare output mode) */
|
855 |
/* print out summary (unless bare output mode) */
|
853 |
if (req.format != DIR_OUTPUT_BARE) {
|
856 |
if (req.format != DIR_OUTPUT_BARE) {
|
854 |
unsigned short alignpos;
|
- |
|
855 |
unsigned short uint32maxlen = 14; /* 13 is the max len of a 32 bit number with thousand separators (4'000'000'000) */
|
- |
|
856 |
if (screenw < 80) uint32maxlen = 10;
|
- |
|
857 |
|
- |
|
858 |
/* x file(s) (maximum of files in a FAT-32 directory is 65'535) */
|
857 |
/* x file(s) (maximum of files in a FAT-32 directory is 65'535) */
|
859 |
memset(buf->buff64, ' ', 8);
|
858 |
memset(buf->buff64, ' ', 8);
|
860 |
i = nls_format_number(buf->buff64 + 8, summary_fcount, &(buf->nls));
|
859 |
i = nls_format_number(buf->buff64 + 8, summary_fcount, &(buf->nls));
|
861 |
alignpos = sprintf(buf->buff64 + 8 + i, " %s ", svarlang_str(37,22)/*"file(s)"*/);
|
860 |
summary_alignpos = sprintf(buf->buff64 + 8 + i, " %s ", svarlang_str(37,22)/*"file(s)"*/);
|
862 |
output(buf->buff64 + i);
|
861 |
output(buf->buff64 + i);
|
863 |
/* xxxx bytes */
|
862 |
/* xxxx bytes */
|
864 |
memset(buf->buff64, ' ', 14);
|
863 |
memset(buf->buff64, ' ', 14);
|
865 |
i = nls_format_number(buf->buff64 + uint32maxlen, summary_totsz, &(buf->nls));
|
864 |
i = nls_format_number(buf->buff64 + uint32maxlen, summary_totsz, &(buf->nls));
|
866 |
output(buf->buff64 + i + 1);
|
865 |
output(buf->buff64 + i + 1);
|
867 |
output(" ");
|
866 |
output(" ");
|
868 |
nls_outputnl(37,23); /* "bytes" */
|
867 |
nls_outputnl(37,23); /* "bytes" */
|
869 |
if (req.flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
|
868 |
if (req.flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
|
870 |
|
- |
|
871 |
/* xxxx bytes free */
|
- |
|
872 |
i = cmd_dir_df(&summary_totsz, drv);
|
- |
|
873 |
if (i != 0) nls_outputnl_doserr(i);
|
- |
|
874 |
alignpos += 8 + uint32maxlen;
|
- |
|
875 |
memset(buf->buff64, ' ', alignpos); /* align the freebytes value to same column as totbytes */
|
- |
|
876 |
i = nls_format_number(buf->buff64 + alignpos, summary_totsz, &(buf->nls));
|
- |
|
877 |
output(buf->buff64 + i + 1);
|
- |
|
878 |
output(" ");
|
- |
|
879 |
nls_outputnl(37,24); /* "bytes free" */
|
- |
|
880 |
if (req.flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
|
- |
|
881 |
}
|
869 |
}
|
882 |
|
870 |
|
883 |
/* /S processing */
|
871 |
/* /S processing */
|
884 |
CHECK_RECURS:
|
872 |
CHECK_RECURS:
|
885 |
/* if /S then look for a subdir */
|
873 |
/* if /S then look for a subdir */
|
886 |
if (req.flags & DIR_FLAG_RECUR) {
|
874 |
if (req.flags & DIR_FLAG_RECUR) {
|
887 |
/* do the findfirst on *.* instead of reusing the user filter */
|
875 |
/* do the findfirst on *.* instead of reusing the user filter */
|
888 |
char *s;
|
876 |
char *s;
|
889 |
char backup[4];
|
877 |
char backup[4];
|
890 |
printf("orig path='%s' new=", buf->path);
|
878 |
//printf("orig path='%s' new=", buf->path);
|
891 |
for (s = buf->path; *s != 0; s++);
|
879 |
for (s = buf->path; *s != 0; s++);
|
892 |
for (; s[-1] != '\\'; s--);
|
880 |
for (; s[-1] != '\\'; s--);
|
893 |
memcpy_ltr(backup, s, 4);
|
881 |
memcpy_ltr(backup, s, 4);
|
894 |
memcpy_ltr(s, "*.*", 4);
|
882 |
memcpy_ltr(s, "*.*", 4);
|
895 |
printf("'%s'\n", buf->path);
|
883 |
//printf("'%s'\n", buf->path);
|
896 |
if (findfirst(dta, buf->path, DOS_ATTR_DIR) == 0) {
|
884 |
if (findfirst(dta, buf->path, DOS_ATTR_DIR) == 0) {
|
897 |
memcpy_ltr(s, backup, 4);
|
885 |
memcpy_ltr(s, backup, 4);
|
898 |
for (;;) {
|
886 |
for (;;) {
|
899 |
if ((dta->fname[0] != '.') && (dta->attr & DOS_ATTR_DIR)) break;
|
887 |
if ((dta->fname[0] != '.') && (dta->attr & DOS_ATTR_DIR)) break;
|
900 |
if (findnext(dta) != 0) goto NOSUBDIR;
|
888 |
if (findnext(dta) != 0) goto NOSUBDIR;
|
901 |
}
|
889 |
}
|
902 |
printf("GOT DIR (/S): '%s'\n", dta->fname);
|
890 |
//printf("GOT DIR (/S): '%s'\n", dta->fname);
|
903 |
/* add dir to path and redo scan */
|
891 |
/* add dir to path and redo scan */
|
904 |
memcpy_ltr(&(buf->dtastack[buf->dtastacklen]), dta, sizeof(struct DTA));
|
892 |
memcpy_ltr(&(buf->dtastack[buf->dtastacklen]), dta, sizeof(struct DTA));
|
905 |
buf->dtastacklen++;
|
893 |
buf->dtastacklen++;
|
906 |
path_add(buf->path, dta->fname);
|
894 |
path_add(buf->path, dta->fname);
|
907 |
goto NEXT_ITER;
|
895 |
goto NEXT_ITER;
|
Line 915... |
Line 903... |
915 |
path_back(buf->path);
|
903 |
path_back(buf->path);
|
916 |
buf->dtastacklen--;
|
904 |
buf->dtastacklen--;
|
917 |
TRYNEXTENTRY:
|
905 |
TRYNEXTENTRY:
|
918 |
if (findnext(&(buf->dtastack[buf->dtastacklen])) != 0) continue;
|
906 |
if (findnext(&(buf->dtastack[buf->dtastacklen])) != 0) continue;
|
919 |
if ((buf->dtastack[buf->dtastacklen].attr & DOS_ATTR_DIR) == 0) goto TRYNEXTENTRY;
|
907 |
if ((buf->dtastack[buf->dtastacklen].attr & DOS_ATTR_DIR) == 0) goto TRYNEXTENTRY;
|
- |
|
908 |
if (buf->dtastack[buf->dtastacklen].fname[0] == '.') goto TRYNEXTENTRY;
|
920 |
/* something found -> add dir to path and redo scan */
|
909 |
/* something found -> add dir to path and redo scan */
|
921 |
path_add(buf->path, buf->dtastack[buf->dtastacklen].fname);
|
910 |
path_add(buf->path, buf->dtastack[buf->dtastacklen].fname);
|
922 |
goto NEXT_ITER;
|
911 |
goto NEXT_ITER;
|
923 |
}
|
912 |
}
|
924 |
|
913 |
|
- |
|
914 |
/* print out disk space available (unless bare output mode) */
|
- |
|
915 |
if (req.format != DIR_OUTPUT_BARE) {
|
- |
|
916 |
/* xxxx bytes free */
|
- |
|
917 |
i = cmd_dir_df(&summary_totsz, drv);
|
- |
|
918 |
if (i != 0) nls_outputnl_doserr(i);
|
- |
|
919 |
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));
|
- |
|
921 |
output(buf->buff64 + i + 1);
|
- |
|
922 |
output(" ");
|
- |
|
923 |
nls_outputnl(37,24); /* "bytes free" */
|
- |
|
924 |
if (req.flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
|
- |
|
925 |
}
|
- |
|
926 |
|
925 |
/* free the buffer memory (if used) */
|
927 |
/* free the buffer memory (if used) */
|
926 |
if (glob_sortcmp_dat.dtabuf_root != NULL) _ffree(glob_sortcmp_dat.dtabuf_root);
|
928 |
if (glob_sortcmp_dat.dtabuf_root != NULL) _ffree(glob_sortcmp_dat.dtabuf_root);
|
927 |
|
929 |
|
928 |
FAIL:
|
930 |
FAIL:
|
929 |
free(buf);
|
931 |
free(buf);
|