Subversion Repositories SvarDOS

Rev

Rev 501 | Rev 533 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 501 Rev 528
1
/* This file is part of the SvarCOM project and is published under the terms
1
/* This file is part of the SvarCOM project and is published under the terms
2
 * of the MIT license.
2
 * of the MIT license.
3
 *
3
 *
4
 * Copyright (C) 2021 Mateusz Viste
4
 * Copyright (C) 2021 Mateusz Viste
5
 *
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 * copy of this software and associated documentation files (the "Software"),
7
 * copy of this software and associated documentation files (the "Software"),
8
 * to deal in the Software without restriction, including without limitation
8
 * to deal in the Software without restriction, including without limitation
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
 * and/or sell copies of the Software, and to permit persons to whom the
10
 * and/or sell copies of the Software, and to permit persons to whom the
11
 * Software is furnished to do so, subject to the following conditions:
11
 * Software is furnished to do so, subject to the following conditions:
12
 *
12
 *
13
 * The above copyright notice and this permission notice shall be included in
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
14
 * all copies or substantial portions of the Software.
15
 *
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
 * DEALINGS IN THE SOFTWARE.
22
 * DEALINGS IN THE SOFTWARE.
23
 */
23
 */
24
 
24
 
25
/*
25
/*
26
 * dir
26
 * dir
27
 *
27
 *
28
 * Displays a list of files and subdirectories in a directory.
28
 * Displays a list of files and subdirectories in a directory.
29
 *
29
 *
30
 * DIR [drive:][path][filename] [/P] [/W] [/A[:]attributes] [/O[[:]sortorder]] [/S] [/B] [/L]
30
 * DIR [drive:][path][filename] [/P] [/W] [/A[:]attributes] [/O[[:]sortorder]] [/S] [/B] [/L]
31
 *
31
 *
32
 * /P Pauses after each screenful of information.
32
 * /P Pauses after each screenful of information.
33
 * /W Uses wide list format.
33
 * /W Uses wide list format.
34
 *
34
 *
35
 * /A Displays file with specified attributes:
35
 * /A Displays file with specified attributes:
36
 *     D Directories           R Read-only files     H Hidden files
36
 *     D Directories           R Read-only files     H Hidden files
37
 *     A Ready for archiving   S System files        - prefix meaning "not"
37
 *     A Ready for archiving   S System files        - prefix meaning "not"
38
 *
38
 *
39
 * /O List files in sorted order:
39
 * /O List files in sorted order:
40
 *     N by name            S by size              E by extension
40
 *     N by name            S by size              E by extension
41
 *     D by date            G group dirs first     - prefix to reverse order
41
 *     D by date            G group dirs first     - prefix to reverse order
42
 *
42
 *
43
 * /S Displays files in specified directory and all subdirectories.
43
 * /S Displays files in specified directory and all subdirectories.
44
 * /B Uses bare format (no heading information or summary)
44
 * /B Uses bare format (no heading information or summary)
45
 * /L Uses lowercases
45
 * /L Uses lowercases
46
 */
46
 */
47
 
47
 
48
/* NOTE: /A attributes are matched in an exclusive way, ie. only files with
48
/* NOTE: /A attributes are matched in an exclusive way, ie. only files with
49
 *       the specified attributes are matched. This is different from how DOS
49
 *       the specified attributes are matched. This is different from how DOS
50
 *       itself matches attributes hence DIR cannot rely on the attributes
50
 *       itself matches attributes hence DIR cannot rely on the attributes
51
 *       filter within FindFirst.
51
 *       filter within FindFirst.
52
 *
52
 *
53
 * NOTE: Multiple /A are not supported - only the last one is significant.
53
 * NOTE: Multiple /A are not supported - only the last one is significant.
54
 */
54
 */
55
 
55
 
56
#define WCOLWIDTH 15  /* width of a column in wide mode output */
56
#define WCOLWIDTH 15  /* width of a column in wide mode output */
57
 
57
 
58
 
58
 
59
/* fills freebytes with free bytes for drv (A=0, B=1, etc)
59
/* fills freebytes with free bytes for drv (A=0, B=1, etc)
60
 * returns DOS ERR code on failure */
60
 * returns DOS ERR code on failure */
61
static unsigned short cmd_dir_df(unsigned long *freebytes, unsigned char drv) {
61
static unsigned short cmd_dir_df(unsigned long *freebytes, unsigned char drv) {
62
  unsigned short res = 0;
62
  unsigned short res = 0;
63
  unsigned short sects_per_clust = 0, avail_clusts = 0, bytes_per_sect = 0;
63
  unsigned short sects_per_clust = 0, avail_clusts = 0, bytes_per_sect = 0;
64
 
64
 
65
  _asm {
65
  _asm {
66
    push ax
66
    push ax
67
    push bx
67
    push bx
68
    push cx
68
    push cx
69
    push dx
69
    push dx
70
 
70
 
71
    mov ah, 0x36  /* DOS 2+ -- Get Disk Free Space */
71
    mov ah, 0x36  /* DOS 2+ -- Get Disk Free Space */
72
    mov dl, [drv] /* A=1, B=2, etc (0 = DEFAULT DRIVE) */
72
    mov dl, [drv] /* A=1, B=2, etc (0 = DEFAULT DRIVE) */
73
    inc dl
73
    inc dl
74
    int 0x21      /* AX=sects_per_clust, BX=avail_clusts, CX=bytes_per_sect, DX=tot_clusters */
74
    int 0x21      /* AX=sects_per_clust, BX=avail_clusts, CX=bytes_per_sect, DX=tot_clusters */
75
    cmp ax, 0xffff /* AX=0xffff on error (invalid drive) */
75
    cmp ax, 0xffff /* AX=0xffff on error (invalid drive) */
76
    jne COMPUTEDF
76
    jne COMPUTEDF
77
    mov [res], 0x0f /* fill res with DOS error code 15 ("invalid drive") */
77
    mov [res], 0x0f /* fill res with DOS error code 15 ("invalid drive") */
78
    jmp DONE
78
    jmp DONE
79
 
79
 
80
    COMPUTEDF:
80
    COMPUTEDF:
81
    /* freebytes = AX * BX * CX */
81
    /* freebytes = AX * BX * CX */
82
    mov [sects_per_clust], ax
82
    mov [sects_per_clust], ax
83
    mov [avail_clusts], bx
83
    mov [avail_clusts], bx
84
    mov [bytes_per_sect], cx
84
    mov [bytes_per_sect], cx
85
 
85
 
86
    DONE:
86
    DONE:
87
    pop dx
87
    pop dx
88
    pop cx
88
    pop cx
89
    pop bx
89
    pop bx
90
    pop ax
90
    pop ax
91
  }
91
  }
92
 
92
 
93
  /* multiple steps to avoid uint16 overflow */
93
  /* multiple steps to avoid uint16 overflow */
94
  *freebytes = sects_per_clust;
94
  *freebytes = sects_per_clust;
95
  *freebytes *= avail_clusts;
95
  *freebytes *= avail_clusts;
96
  *freebytes *= bytes_per_sect;
96
  *freebytes *= bytes_per_sect;
97
 
97
 
98
  return(res);
98
  return(res);
99
}
99
}
100
 
100
 
101
 
101
 
-
 
102
static void dir_pagination(unsigned short *availrows) {
-
 
103
  *availrows -= 1;
-
 
104
  if (*availrows == 0) {
-
 
105
    press_any_key();
-
 
106
    *availrows = screen_getheight() - 1;
-
 
107
  }
-
 
108
}
-
 
109
 
-
 
110
 
102
static int cmd_dir(struct cmd_funcparam *p) {
111
static int cmd_dir(struct cmd_funcparam *p) {
103
  const char *filespecptr = NULL;
112
  const char *filespecptr = NULL;
104
  struct DTA *dta = (void *)0x80; /* set DTA to its default location at 80h in PSP */
113
  struct DTA *dta = (void *)0x80; /* set DTA to its default location at 80h in PSP */
105
  unsigned short i;
114
  unsigned short i;
106
  unsigned short availrows;  /* counter of available rows on display (used for /P) */
115
  unsigned short availrows;  /* counter of available rows on display (used for /P) */
107
  unsigned short wcols = screen_getwidth() / WCOLWIDTH; /* number of columns in wide mode */
116
  unsigned short wcols = screen_getwidth() / WCOLWIDTH; /* number of columns in wide mode */
108
  unsigned char wcolcount;
117
  unsigned char wcolcount;
109
  struct nls_patterns *nls = (void *)(p->BUFFER + (p->BUFFERSZ / 2));
118
  struct nls_patterns *nls = (void *)(p->BUFFER + (p->BUFFERSZ / 2));
110
  char *buff2 = p->BUFFER + (p->BUFFERSZ / 2) + sizeof(*nls);
119
  char *buff2 = p->BUFFER + (p->BUFFERSZ / 2) + sizeof(*nls);
111
  unsigned long summary_fcount = 0;
120
  unsigned long summary_fcount = 0;
112
  unsigned long summary_totsz = 0;
121
  unsigned long summary_totsz = 0;
113
  unsigned char drv = 0;
122
  unsigned char drv = 0;
114
 
123
 
115
  #define DIR_FLAG_PAUSE  1
124
  #define DIR_FLAG_PAUSE  1
116
  #define DIR_FLAG_RECUR  4
125
  #define DIR_FLAG_RECUR  4
117
  #define DIR_FLAG_LCASE  8
126
  #define DIR_FLAG_LCASE  8
118
  unsigned char flags = 0;
127
  unsigned char flags = 0;
119
 
128
 
120
  #define DIR_OUTPUT_NORM 1
129
  #define DIR_OUTPUT_NORM 1
121
  #define DIR_OUTPUT_WIDE 2
130
  #define DIR_OUTPUT_WIDE 2
122
  #define DIR_OUTPUT_BARE 3
131
  #define DIR_OUTPUT_BARE 3
123
  unsigned char format = DIR_OUTPUT_NORM;
132
  unsigned char format = DIR_OUTPUT_NORM;
124
 
133
 
125
  if (cmd_ishlp(p)) {
134
  if (cmd_ishlp(p)) {
126
    outputnl("Displays a list of files and subdirectories in a directory");
135
    outputnl("Displays a list of files and subdirectories in a directory");
127
    outputnl("");
136
    outputnl("");
128
    outputnl("DIR [drive:][path][filename] [/P] [/W] [/A[:]attributes] [/O[[:]sortorder]] [/S] [/B] [/L]");
137
    outputnl("DIR [drive:][path][filename] [/P] [/W] [/A[:]attributes] [/O[[:]sortorder]] [/S] [/B] [/L]");
129
    outputnl("");
138
    outputnl("");
130
    outputnl("/P Pauses after each screenful of information");
139
    outputnl("/P Pauses after each screenful of information");
131
    outputnl("/W Uses wide list format");
140
    outputnl("/W Uses wide list format");
132
    outputnl("");
141
    outputnl("");
133
    outputnl("/A Displays files with specified attributes:");
142
    outputnl("/A Displays files with specified attributes:");
134
    outputnl("    D Directories            R Read-only files        H Hidden files");
143
    outputnl("    D Directories            R Read-only files        H Hidden files");
135
    outputnl("    A Ready for archiving    S System files           - prefix meaning \"not\"");
144
    outputnl("    A Ready for archiving    S System files           - prefix meaning \"not\"");
136
    outputnl("");
145
    outputnl("");
137
    outputnl("/O List files in sorted order:");
146
    outputnl("/O List files in sorted order:");
138
    outputnl("    N by name                S by size                E by extension");
147
    outputnl("    N by name                S by size                E by extension");
139
    outputnl("    D by date                G group dirs first       - prefix to reverse order");
148
    outputnl("    D by date                G group dirs first       - prefix to reverse order");
140
    outputnl("");
149
    outputnl("");
141
    outputnl("/S Displays files in specified directory and all subdirectories");
150
    outputnl("/S Displays files in specified directory and all subdirectories");
142
    outputnl("/B Uses bare format (no heading information or summary)");
151
    outputnl("/B Uses bare format (no heading information or summary)");
143
    outputnl("/L Uses lowercases");
152
    outputnl("/L Uses lowercases");
144
    return(-1);
153
    return(-1);
145
  }
154
  }
146
 
155
 
147
  i = nls_getpatterns(nls);
156
  i = nls_getpatterns(nls);
148
  if (i != 0) outputnl(doserr(i));
157
  if (i != 0) outputnl(doserr(i));
149
 
158
 
150
  /* parse command line */
159
  /* parse command line */
151
  for (i = 0; i < p->argc; i++) {
160
  for (i = 0; i < p->argc; i++) {
152
    if (p->argv[i][0] == '/') {
161
    if (p->argv[i][0] == '/') {
153
      char arg;
162
      char arg;
154
      char neg = 0;
163
      char neg = 0;
155
      /* detect negations and get actual argument */
164
      /* detect negations and get actual argument */
156
      if (p->argv[i][1] == '-') neg = 1;
165
      if (p->argv[i][1] == '-') neg = 1;
157
      arg = p->argv[i][1 + neg];
166
      arg = p->argv[i][1 + neg];
158
      /* */
167
      /* */
159
      switch (arg) {
168
      switch (arg) {
160
        case 'a':
169
        case 'a':
161
        case 'A':
170
        case 'A':
162
          /* TODO */
171
          /* TODO */
163
          outputnl("/A NOT IMPLEMENTED YET");
172
          outputnl("/A NOT IMPLEMENTED YET");
164
          return(-1);
173
          return(-1);
165
          break;
174
          break;
166
        case 'b':
175
        case 'b':
167
        case 'B':
176
        case 'B':
168
          format = DIR_OUTPUT_BARE;
177
          format = DIR_OUTPUT_BARE;
169
          break;
178
          break;
170
        case 'l':
179
        case 'l':
171
        case 'L':
180
        case 'L':
172
          flags |= DIR_FLAG_LCASE;
181
          flags |= DIR_FLAG_LCASE;
173
          break;
182
          break;
174
        case 'o':
183
        case 'o':
175
        case 'O':
184
        case 'O':
176
          /* TODO */
185
          /* TODO */
177
          outputnl("/O NOT IMPLEMENTED YET");
186
          outputnl("/O NOT IMPLEMENTED YET");
178
          return(-1);
187
          return(-1);
179
          break;
188
          break;
180
        case 'p':
189
        case 'p':
181
        case 'P':
190
        case 'P':
182
          flags |= DIR_FLAG_PAUSE;
191
          flags |= DIR_FLAG_PAUSE;
183
          if (neg) flags &= (0xff ^ DIR_FLAG_PAUSE);
192
          if (neg) flags &= (0xff ^ DIR_FLAG_PAUSE);
184
          break;
193
          break;
185
        case 's':
194
        case 's':
186
        case 'S':
195
        case 'S':
187
          /* TODO */
196
          /* TODO */
188
          outputnl("/S NOT IMPLEMENTED YET");
197
          outputnl("/S NOT IMPLEMENTED YET");
189
          return(-1);
198
          return(-1);
190
          break;
199
          break;
191
        case 'w':
200
        case 'w':
192
        case 'W':
201
        case 'W':
193
          format = DIR_OUTPUT_WIDE;
202
          format = DIR_OUTPUT_WIDE;
194
          break;
203
          break;
195
        default:
204
        default:
196
          outputnl("Invalid switch");
205
          outputnl("Invalid switch");
197
          return(-1);
206
          return(-1);
198
      }
207
      }
199
    } else {  /* filespec */
208
    } else {  /* filespec */
200
      if (filespecptr != NULL) {
209
      if (filespecptr != NULL) {
201
        outputnl("Too many parameters");
210
        outputnl("Too many parameters");
202
        return(-1);
211
        return(-1);
203
      }
212
      }
204
      filespecptr = p->argv[i];
213
      filespecptr = p->argv[i];
205
    }
214
    }
206
  }
215
  }
207
 
216
 
208
  if (filespecptr == NULL) filespecptr = ".";
217
  if (filespecptr == NULL) filespecptr = ".";
209
 
218
 
-
 
219
  availrows = screen_getheight() - 2;
-
 
220
 
210
  /* special case: "DIR drive:" (truename() fails on "C:" under MS-DOS 6.0) */
221
  /* special case: "DIR drive:" (truename() fails on "C:" under MS-DOS 6.0) */
211
  if ((filespecptr[0] != 0) && (filespecptr[1] == ':') && (filespecptr[2] == 0)) {
222
  if ((filespecptr[0] != 0) && (filespecptr[1] == ':') && (filespecptr[2] == 0)) {
212
    if ((filespecptr[0] >= 'a') && (filespecptr[0] <= 'z')) {
223
    if ((filespecptr[0] >= 'a') && (filespecptr[0] <= 'z')) {
213
      p->BUFFER[0] = filespecptr[0] - ('a' - 1);
224
      p->BUFFER[0] = filespecptr[0] - ('a' - 1);
214
    } else {
225
    } else {
215
      p->BUFFER[0] = filespecptr[0] - ('A' - 1);
226
      p->BUFFER[0] = filespecptr[0] - ('A' - 1);
216
    }
227
    }
217
    i = curpathfordrv(p->BUFFER, p->BUFFER[0]);
228
    i = curpathfordrv(p->BUFFER, p->BUFFER[0]);
218
  } else {
229
  } else {
219
    i = file_truename(filespecptr, p->BUFFER);
230
    i = file_truename(filespecptr, p->BUFFER);
220
  }
231
  }
221
  if (i != 0) {
232
  if (i != 0) {
222
    outputnl(doserr(i));
233
    outputnl(doserr(i));
223
    return(-1);
234
    return(-1);
224
  }
235
  }
225
 
236
 
226
  if (format != DIR_OUTPUT_BARE) {
237
  if (format != DIR_OUTPUT_BARE) {
227
    drv = p->BUFFER[0];
238
    drv = p->BUFFER[0];
228
    if (drv >= 'a') {
239
    if (drv >= 'a') {
229
      drv -= 'a';
240
      drv -= 'a';
230
    } else {
241
    } else {
231
      drv -= 'A';
242
      drv -= 'A';
232
    }
243
    }
233
    cmd_vol_internal(drv, buff2);
244
    cmd_vol_internal(drv, buff2);
234
    sprintf(buff2, "Directory of %s", p->BUFFER);
245
    sprintf(buff2, "Directory of %s", p->BUFFER);
235
    /* trim at first '?', if any */
246
    /* trim at first '?', if any */
236
    for (i = 0; buff2[i] != 0; i++) if (buff2[i] == '?') buff2[i] = 0;
247
    for (i = 0; buff2[i] != 0; i++) if (buff2[i] == '?') buff2[i] = 0;
237
    outputnl(buff2);
248
    outputnl(buff2);
238
    outputnl("");
249
    outputnl("");
-
 
250
    availrows -= 3;
239
  }
251
  }
240
 
252
 
241
  /* if dir: append a backslash (also get its len) */
253
  /* if dir: append a backslash (also get its len) */
242
  i = path_appendbkslash_if_dir(p->BUFFER);
254
  i = path_appendbkslash_if_dir(p->BUFFER);
243
 
255
 
244
  /* if ends with a \ then append ????????.??? */
256
  /* if ends with a \ then append ????????.??? */
245
  if (p->BUFFER[i - 1] == '\\') strcat(p->BUFFER, "????????.???");
257
  if (p->BUFFER[i - 1] == '\\') strcat(p->BUFFER, "????????.???");
246
 
258
 
247
  i = findfirst(dta, p->BUFFER, DOS_ATTR_RO | DOS_ATTR_HID | DOS_ATTR_SYS | DOS_ATTR_DIR | DOS_ATTR_ARC);
259
  i = findfirst(dta, p->BUFFER, DOS_ATTR_RO | DOS_ATTR_HID | DOS_ATTR_SYS | DOS_ATTR_DIR | DOS_ATTR_ARC);
248
  if (i != 0) {
260
  if (i != 0) {
249
    outputnl(doserr(i));
261
    outputnl(doserr(i));
250
    return(-1);
262
    return(-1);
251
  }
263
  }
252
 
264
 
253
  availrows = screen_getheight();
-
 
254
  wcolcount = 0; /* may be used for columns counting with wide mode */
265
  wcolcount = 0; /* may be used for columns counting with wide mode */
255
 
266
 
256
  do {
267
  do {
257
    if (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... */
268
    if (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... */
258
 
269
 
259
    summary_fcount++;
270
    summary_fcount++;
260
    if ((dta->attr & DOS_ATTR_DIR) == 0) summary_totsz += dta->size;
271
    if ((dta->attr & DOS_ATTR_DIR) == 0) summary_totsz += dta->size;
261
 
272
 
262
    switch (format) {
273
    switch (format) {
263
      case DIR_OUTPUT_NORM:
274
      case DIR_OUTPUT_NORM:
264
        /* print fname-space-extension (unless it's "." or "..", then print as-is) */
275
        /* print fname-space-extension (unless it's "." or "..", then print as-is) */
265
        if (dta->fname[0] == '.') {
276
        if (dta->fname[0] == '.') {
266
          output(dta->fname);
277
          output(dta->fname);
267
          i = strlen(dta->fname);
278
          i = strlen(dta->fname);
268
          while (i++ < 12) output(" ");
279
          while (i++ < 12) output(" ");
269
        } else {
280
        } else {
270
          file_fname2fcb(buff2, dta->fname);
281
          file_fname2fcb(buff2, dta->fname);
271
          memmove(buff2 + 9, buff2 + 8, 4);
282
          memmove(buff2 + 9, buff2 + 8, 4);
272
          buff2[8] = ' ';
283
          buff2[8] = ' ';
273
          output(buff2);
284
          output(buff2);
274
        }
285
        }
275
        output(" ");
286
        output(" ");
276
        /* either <DIR> or right aligned 10-chars byte size */
287
        /* either <DIR> or right aligned 10-chars byte size */
277
        memset(buff2, ' ', 10);
288
        memset(buff2, ' ', 10);
278
        if (dta->attr & DOS_ATTR_DIR) {
289
        if (dta->attr & DOS_ATTR_DIR) {
279
          strcpy(buff2 + 10, "<DIR>");
290
          strcpy(buff2 + 10, "<DIR>");
280
        } else {
291
        } else {
281
          _ultoa(dta->size, buff2 + 10, 10); /* OpenWatcom extension */
292
          _ultoa(dta->size, buff2 + 10, 10); /* OpenWatcom extension */
282
        }
293
        }
283
        output(buff2 + strlen(buff2) - 10);
294
        output(buff2 + strlen(buff2) - 10);
284
        /* two spaces and NLS DATE */
295
        /* two spaces and NLS DATE */
285
        buff2[0] = ' ';
296
        buff2[0] = ' ';
286
        buff2[1] = ' ';
297
        buff2[1] = ' ';
287
        nls_format_date(buff2 + 2, dta->date_yr + 1980, dta->date_mo, dta->date_dy, nls);
298
        nls_format_date(buff2 + 2, dta->date_yr + 1980, dta->date_mo, dta->date_dy, nls);
288
        output(buff2);
299
        output(buff2);
289
 
300
 
290
        /* one space and NLS TIME */
301
        /* one space and NLS TIME */
291
        nls_format_time(buff2 + 1, dta->time_hour, dta->time_min, 0xff, nls);
302
        nls_format_time(buff2 + 1, dta->time_hour, dta->time_min, 0xff, nls);
292
        outputnl(buff2);
303
        outputnl(buff2);
293
        break;
304
        break;
294
 
305
 
295
      case DIR_OUTPUT_WIDE: /* display in columns of 12 chars per item */
306
      case DIR_OUTPUT_WIDE: /* display in columns of 12 chars per item */
296
        i = strlen(dta->fname);
307
        i = strlen(dta->fname);
297
        if (dta->attr & DOS_ATTR_DIR) {
308
        if (dta->attr & DOS_ATTR_DIR) {
298
          i += 2;
309
          i += 2;
299
          output("[");
310
          output("[");
300
          output(dta->fname);
311
          output(dta->fname);
301
          output("]");
312
          output("]");
302
        } else {
313
        } else {
303
          output(dta->fname);
314
          output(dta->fname);
304
        }
315
        }
305
        while (i++ < WCOLWIDTH) output(" ");
316
        while (i++ < WCOLWIDTH) output(" ");
306
        if (++wcolcount == wcols) {
317
        if (++wcolcount == wcols) {
307
          wcolcount = 0;
318
          wcolcount = 0;
308
          outputnl("");
319
          outputnl("");
-
 
320
        } else {
-
 
321
          availrows++; /* wide mode is the only one that does not write one line per file */
309
        }
322
        }
310
        break;
323
        break;
311
 
324
 
312
      case DIR_OUTPUT_BARE:
325
      case DIR_OUTPUT_BARE:
313
        outputnl(dta->fname);
326
        outputnl(dta->fname);
314
        break;
327
        break;
315
    }
328
    }
316
 
329
 
317
    if ((flags & DIR_FLAG_PAUSE) && (--availrows < 2)) {
330
    if (flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
318
      press_any_key();
-
 
319
      availrows = screen_getheight();
-
 
320
    }
-
 
321
 
331
 
322
  } while (findnext(dta) == 0);
332
  } while (findnext(dta) == 0);
323
 
333
 
-
 
334
  if (wcolcount != 0) {
324
  if (wcolcount != 0) outputnl(""); /* in wide mode make sure to end on a clear row */
335
    outputnl(""); /* in wide mode make sure to end on a clear row */
-
 
336
    if (flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
-
 
337
  }
325
 
338
 
326
  /* print out summary (unless bare output mode) */
339
  /* print out summary (unless bare output mode) */
327
  if (format != DIR_OUTPUT_BARE) {
340
  if (format != DIR_OUTPUT_BARE) {
328
    unsigned short alignpos;
341
    unsigned short alignpos;
329
    /* x file(s) */
342
    /* x file(s) */
330
    memset(buff2, ' ', 13); /* 13 is the max len of a 32 bit number with thousand separators (4'000'000'000) */
343
    memset(buff2, ' ', 13); /* 13 is the max len of a 32 bit number with thousand separators (4'000'000'000) */
331
    i = nls_format_number(buff2 + 13, summary_fcount, nls);
344
    i = nls_format_number(buff2 + 13, summary_fcount, nls);
332
    alignpos = sprintf(buff2 + 13 + i, " %s ", "file(s)");
345
    alignpos = sprintf(buff2 + 13 + i, " %s ", "file(s)");
333
    output(buff2 + i);
346
    output(buff2 + i);
334
    /* xxxx bytes */
347
    /* xxxx bytes */
335
    i = nls_format_number(buff2 + 13, summary_totsz, nls);
348
    i = nls_format_number(buff2 + 13, summary_totsz, nls);
336
    output(buff2 + i);
349
    output(buff2 + i);
337
    output(" ");
350
    output(" ");
338
    outputnl("bytes");
351
    outputnl("bytes");
-
 
352
    if (flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
339
    /* xxxx bytes free */
353
    /* xxxx bytes free */
340
    i = cmd_dir_df(&summary_totsz, drv);
354
    i = cmd_dir_df(&summary_totsz, drv);
341
    if (i != 0) outputnl(doserr(i));
355
    if (i != 0) outputnl(doserr(i));
342
    alignpos += 13 + 13;
356
    alignpos += 13 + 13;
343
    memset(buff2, ' ', alignpos); /* align the freebytes value to same column as totbytes */
357
    memset(buff2, ' ', alignpos); /* align the freebytes value to same column as totbytes */
344
    i = nls_format_number(buff2 + alignpos, summary_totsz, nls);
358
    i = nls_format_number(buff2 + alignpos, summary_totsz, nls);
345
    output(buff2 + i);
359
    output(buff2 + i);
346
    output(" ");
360
    output(" ");
347
    outputnl("bytes free");
361
    outputnl("bytes free");
-
 
362
    if (flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
348
  }
363
  }
349
 
364
 
350
  return(-1);
365
  return(-1);
351
}
366
}
352
 
367