Last change
on this file since f40d52b was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago |
Imported original source code.
|
-
Property mode
set to
100755
|
File size:
592 bytes
|
Line | |
---|
1 | #include "stdio.h"
|
---|
2 | #include "dir.h"
|
---|
3 |
|
---|
4 | main(argc, argv)
|
---|
5 | int argc;
|
---|
6 | char *argv[];
|
---|
7 | {
|
---|
8 | DIR *dirptr;
|
---|
9 | struct direct *ent;
|
---|
10 | char *ptr, *strrchr();
|
---|
11 |
|
---|
12 | if(argc < 2) {
|
---|
13 |
|
---|
14 | argv[1] = ".";
|
---|
15 |
|
---|
16 | } else if((ptr = strrchr(argv[1], '/')) == NULL) {
|
---|
17 |
|
---|
18 | argv[1] = ".";
|
---|
19 |
|
---|
20 | } else if(ptr != argv[1]) {
|
---|
21 |
|
---|
22 | *ptr = '\0';
|
---|
23 | }
|
---|
24 |
|
---|
25 | if((dirptr = opendir(argv[1])) == (DIR *)0) {
|
---|
26 |
|
---|
27 | fprintf(stderr, "dirtest1: ");
|
---|
28 | perror(argv[1]);
|
---|
29 | exit(1);
|
---|
30 | }
|
---|
31 |
|
---|
32 | while((ent = readdir(dirptr)) != (struct direct *)0) {
|
---|
33 |
|
---|
34 | printf("%s, size = %ld\n",
|
---|
35 | ent->d_name, ent->d_size);
|
---|
36 | }
|
---|
37 |
|
---|
38 | closedir(dirptr);
|
---|
39 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.