source: buchla-68k/orig/GEMDOS/DIRTEST2.C

Last change on this file was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Imported original source code.

  • Property mode set to 100755
File size: 903 bytes
Line 
1#include "stdio.h"
2#include "dir.h"
3
4extern int alphasort();
5
6char pattern[80];
7
8int
9select(dirptr)
10struct direct *dirptr;
11{
12 return(fmatch(dirptr->d_name, pattern));
13}
14
15main(argc, argv)
16int argc;
17char *argv[];
18{
19 struct direct **namelist;
20 int num, ii;
21 char *ptr, *strrchr();
22
23 if(argc < 2) {
24
25 argv[1] = ".";
26 strcpy(pattern, "*.*");
27
28 } else if((ptr = strrchr(argv[1], '/')) == NULL) {
29
30 strcpy(pattern, argv[1]);
31 argv[1] = ".";
32
33 } else {
34
35 strcpy(pattern, ptr + 1);
36 *ptr = '\0';
37 }
38
39 if((num = scandir(argv[1], &namelist, select, alphasort)) <= 0) {
40
41 fprintf(stderr, "dirtest2: ");
42 perror(argv[1]);
43 exit(1);
44 }
45
46 if(num == 0) {
47
48 printf("%s: Not found\n", pattern);
49 exit(1);
50 }
51
52 for(ii = 0; ii < num; ii++) {
53
54 printf("%s, size = %ld\n",
55 namelist[ii]->d_name, namelist[ii]->d_size);
56 }
57
58 freedir(namelist, num);
59}
Note: See TracBrowser for help on using the repository browser.