1# NOTE: This program is not a generalized parser for the output of 'ls'.
2# It's job is to read the output of ls from the gawk source code directory,
3# where we know there are no files with spaces in their file names, etc.
4BEGIN {
5	# analyze results from readdir extension
6	while ((getline x < extout) > 0) {
7		numrec++
8		if ((split(x, f, "/") == 3) && (f[3] == "u"))
9			num_unknown++
10	}
11	close(extout)
12	if ((numrec > 0) && (num_unknown == numrec)) {
13		print "Notice: this filesystem does not appear to support file type information" > "/dev/stderr"
14		ftype_unknown = 1
15	}
16}
17
18BEGIN {
19	for (i = 1; (getline < dirlist) > 0; i++) {
20		# inode number is $1, filename is read of record
21		inode = $1
22		$1 = ""
23		$0 = $0
24		sub(/^ */, "")
25		names[i] = $0
26		ino[names[i]] = inode
27	}
28	close(dirlist)
29
30	for (j = 1; (getline < longlist) > 0; j++) {
31		type_let = substr($0, 1, 1)
32		if (type_let == "-")
33			type_let = "f"
34		if (type_let == "l")
35			type[$(NF-2)] = type_let
36		else
37			type[$NF] = type_let
38	}
39	close(longlist)
40
41	if (i != j)
42		printf("mismatch: %d from `ls -afi' and %d from `ls -lna'\n", i, j) > "/dev/stderr"
43
44	for (i = 1; i in names; i++)
45		printf("%s/%s/%s\n", ino[names[i]], names[i], (ftype_unknown ? "u" : type[names[i]]))
46}
47