Subversion Repositories SvarDOS

Rev

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

Rev 542 Rev 990
Line 1... Line 1...
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-2022 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,
Line 183... Line 183...
183
  #define DIR_OUTPUT_WIDE 2
183
  #define DIR_OUTPUT_WIDE 2
184
  #define DIR_OUTPUT_BARE 3
184
  #define DIR_OUTPUT_BARE 3
185
  unsigned char format = DIR_OUTPUT_NORM;
185
  unsigned char format = DIR_OUTPUT_NORM;
186
 
186
 
187
  if (cmd_ishlp(p)) {
187
  if (cmd_ishlp(p)) {
188
    outputnl("Displays a list of files and subdirectories in a directory");
188
    nls_outputnl(37,0); /* "Displays a list of files and subdirectories in a directory" */
189
    outputnl("");
189
    outputnl("");
190
    outputnl("DIR [drive:][path][filename] [/P] [/W] [/A[:]attributes] [/O[[:]sortorder]] [/S] [/B] [/L]");
190
    nls_outputnl(37,1); /* "DIR [drive:][path][filename] [/P] [/W] [/A[:]attributes] [/O[[:]sortorder]] [/S] [/B] [/L]" */
191
    outputnl("");
191
    outputnl("");
192
    outputnl("/P Pauses after each screenful of information");
192
    nls_outputnl(37,2); /* "/P Pauses after each screenful of information" */
193
    outputnl("/W Uses wide list format");
193
    nls_outputnl(37,3); /* "/W Uses wide list format" */
194
    outputnl("");
194
    outputnl("");
195
    outputnl("/A Displays files with specified attributes:");
195
    nls_outputnl(37,4); /* "/A Displays files with specified attributes:" */
196
    outputnl("    D Directories            R Read-only files        H Hidden files");
196
    nls_outputnl(37,5); /* "    D Directories            R Read-only files        H Hidden files" */
197
    outputnl("    A Ready for archiving    S System files           - prefix meaning \"not\"");
197
    nls_outputnl(37,6); /* "    A Ready for archiving    S System files           - prefix meaning "not"" */
198
    outputnl("");
198
    outputnl("");
199
    outputnl("/O List files in sorted order:");
199
    nls_outputnl(37,7); /* "/O List files in sorted order:" */
200
    outputnl("    N by name                S by size                E by extension");
200
    nls_outputnl(37,8); /* "    N by name                S by size                E by extension" */
201
    outputnl("    D by date                G group dirs first       - prefix to reverse order");
201
    nls_outputnl(37,9); /* "    D by date                G group dirs first       - prefix to reverse order" */
202
    outputnl("");
202
    outputnl("");
203
    outputnl("/S Displays files in specified directory and all subdirectories");
203
    nls_outputnl(37,10); /* "/S Displays files in specified directory and all subdirectories" */
204
    outputnl("/B Uses bare format (no heading information or summary)");
204
    nls_outputnl(37,11); /* "/B Uses bare format (no heading information or summary)" */
205
    outputnl("/L Uses lowercases");
205
    nls_outputnl(37,12); /* "/L Uses lowercases" */
206
    return(CMD_OK);
206
    return(CMD_OK);
207
  }
207
  }
208
 
208
 
209
  i = nls_getpatterns(nls);
209
  i = nls_getpatterns(nls);
210
  if (i != 0) nls_outputnl_doserr(i);
210
  if (i != 0) nls_outputnl_doserr(i);
Line 310... Line 310...
310
      drv -= 'a';
310
      drv -= 'a';
311
    } else {
311
    } else {
312
      drv -= 'A';
312
      drv -= 'A';
313
    }
313
    }
314
    cmd_vol_internal(drv, buff2);
314
    cmd_vol_internal(drv, buff2);
315
    sprintf(buff2, "Directory of %s", p->BUFFER);
315
    sprintf(buff2, svarlang_str(37,20)/*"Directory of %s"*/, p->BUFFER);
316
    /* trim at first '?', if any */
316
    /* trim at first '?', if any */
317
    for (i = 0; buff2[i] != 0; i++) if (buff2[i] == '?') buff2[i] = 0;
317
    for (i = 0; buff2[i] != 0; i++) if (buff2[i] == '?') buff2[i] = 0;
318
    outputnl(buff2);
318
    outputnl(buff2);
319
    outputnl("");
319
    outputnl("");
320
    availrows -= 3;
320
    availrows -= 3;
Line 363... Line 363...
363
        }
363
        }
364
        output(" ");
364
        output(" ");
365
        /* either <DIR> or right aligned 10-chars byte size */
365
        /* either <DIR> or right aligned 10-chars byte size */
366
        memset(buff2, ' ', 10);
366
        memset(buff2, ' ', 10);
367
        if (dta->attr & DOS_ATTR_DIR) {
367
        if (dta->attr & DOS_ATTR_DIR) {
368
          strcpy(buff2 + 10, "<DIR>");
368
          strcpy(buff2 + 10, svarlang_str(37,21));
369
        } else {
369
        } else {
370
          _ultoa(dta->size, buff2 + 10, 10); /* OpenWatcom extension */
370
          _ultoa(dta->size, buff2 + 10, 10); /* OpenWatcom extension */
371
        }
371
        }
372
        output(buff2 + strlen(buff2) - 10);
372
        output(buff2 + strlen(buff2) - 10);
373
        /* two spaces and NLS DATE */
373
        /* two spaces and NLS DATE */
Line 418... Line 418...
418
  if (format != DIR_OUTPUT_BARE) {
418
  if (format != DIR_OUTPUT_BARE) {
419
    unsigned short alignpos;
419
    unsigned short alignpos;
420
    /* x file(s) */
420
    /* x file(s) */
421
    memset(buff2, ' ', 13); /* 13 is the max len of a 32 bit number with thousand separators (4'000'000'000) */
421
    memset(buff2, ' ', 13); /* 13 is the max len of a 32 bit number with thousand separators (4'000'000'000) */
422
    i = nls_format_number(buff2 + 13, summary_fcount, nls);
422
    i = nls_format_number(buff2 + 13, summary_fcount, nls);
423
    alignpos = sprintf(buff2 + 13 + i, " %s ", "file(s)");
423
    alignpos = sprintf(buff2 + 13 + i, " %s ", svarlang_str(37,22)/*"file(s)"*/);
424
    output(buff2 + i);
424
    output(buff2 + i);
425
    /* xxxx bytes */
425
    /* xxxx bytes */
426
    i = nls_format_number(buff2 + 13, summary_totsz, nls);
426
    i = nls_format_number(buff2 + 13, summary_totsz, nls);
427
    output(buff2 + i);
427
    output(buff2 + i);
428
    output(" ");
428
    output(" ");
429
    outputnl("bytes");
429
    nls_outputnl(37,23); /* "bytes" */
430
    if (flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
430
    if (flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
431
    /* xxxx bytes free */
431
    /* xxxx bytes free */
432
    i = cmd_dir_df(&summary_totsz, drv);
432
    i = cmd_dir_df(&summary_totsz, drv);
433
    if (i != 0) nls_outputnl_doserr(i);
433
    if (i != 0) nls_outputnl_doserr(i);
434
    alignpos += 13 + 13;
434
    alignpos += 13 + 13;
435
    memset(buff2, ' ', alignpos); /* align the freebytes value to same column as totbytes */
435
    memset(buff2, ' ', alignpos); /* align the freebytes value to same column as totbytes */
436
    i = nls_format_number(buff2 + alignpos, summary_totsz, nls);
436
    i = nls_format_number(buff2 + alignpos, summary_totsz, nls);
437
    output(buff2 + i);
437
    output(buff2 + i);
438
    output(" ");
438
    output(" ");
439
    outputnl("bytes free");
439
    nls_outputnl(37,24); /* "bytes free" */
440
    if (flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
440
    if (flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
441
  }
441
  }
442
 
442
 
443
  return(CMD_OK);
443
  return(CMD_OK);
444
}
444
}