Subversion Repositories SvarDOS

Rev

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

Rev 501 Rev 528
Line 97... Line 97...
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) */
Line 205... Line 214...
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 {
Line 234... Line 245...
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
 
Line 248... Line 260...
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
 
Line 304... Line 315...
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) */
Line 334... Line 347...
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
}