srp@ethz.UUCP (Scott Presnell) (11/24/86)
Hello, I have an interest in a program that will display the oragnization of a directory tree in UNIX (or MSDOS). This program would hopefully handle links, etc. If possible the program should be written in 'C'. I am mainly interested in the algorithm to parse and display such a tree so any program that sounds similar would be of interest to me too. Barterers welcome. -- ----------- Scott Presnell Eidgnoessische Technische Hochschule, Zuerich (ETH-Zentrum) Labor Fuer Organische Chemie Universitaetsstrasse 16 CH-8092 Zuerich Switzerland. uucp: ...seismo!mcvax!cernvax!ethz!srp (srp@ethz.uucp) earn/bitnet: Benner@CZHETH5A
jaymin@tcdmath.UUCP (Joe Jaquinta) (11/27/86)
In article <415@ethz.UUCP> srp@ethz.UUCP (Scott Presnell) writes: >Hello, >I have an interest in a program that will display the oragnization of a >directory tree in UNIX (or MSDOS)... Not exactly what you want but I find it *very* useful as a general program. j^2 To unbundle, run sh on this file... -----------------><--><--><------------------------- #!/bin/sh echo x - flst.1 sed 's/^X//' > flst.1 << '!End!Of!Sharchive!' X.TH flst 1 "Trinity College Dublin" X.SH NAME Xflst - fast listing sub-tree X.SH SYNOPSIS Xflst [directory(s)] X.SH DESCRIPTION X.I Flst Xlists a tree file system or systems specified in the argument Xwith indentation reflecting the level Xof nesting of the file in the file system. If no argument is Xgiven X.I flst Xtakes the current directory as default. X.SH SEE ALSO Xls(1), lstree(1) X.SH DIAGNOSTICS X.br XIt cannot list files nested more than twenty levels. !End!Of!Sharchive! echo x - flst.c sed 's/^X//' > flst.c << '!End!Of!Sharchive!' X#include <stdio.h> X#include <sys/types.h> X#include <sys/dir.h> X#include <sys/stat.h> X Xint siz, level; Xchar tabs[] = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; X Xmain(argc, argv) Xint argc; Xchar **argv; X{ X X level = 0; X siz = sizeof(struct direct); X if (argc == 1) X pdir(); X else while (*++argv) X if (chdir(*argv) >= 0) X pdir(); X else X iprint("Cannot access directory"); X} X Xpdir() X{ X struct direct entry; X struct stat filetyp; X int fp; X X fp = open(".", 0); X if (fp < 0) X { X iprint("Bad Open"); X return; X } X while (read(fp, &entry, siz)) X if (entry.d_ino) X { X stat(entry.d_name, &filetyp); X if (!strcmp(entry.d_name, ".q")) X continue; X if (!strcmp(entry.d_name, "..")) X continue; X if (!strcmp(entry.d_name, ".")) X continue; X iprint(entry.d_name); X if (filetyp.st_mode & S_IFDIR) X { X level++; X if (chdir(entry.d_name) >= 0) X pdir(); X else X iprint("Cannot access directory"); X level--; X } X } X close(fp); X chdir(".."); X} X Xiprint(string) Xchar *string; X{ X write(1, tabs, level); X write(1, string, strlen(string)); X write(1, "\n", 1); X} !End!Of!Sharchive! -- ...{decvax,seismo}!mcvax!ukc!einode!tcdmath!jaymin Io, the greek goddess of input and output. -- D. E. Knuth
dennisg@pwcs.StPaul.GOV (Dennis Grittner) (12/03/86)
In article <415@ethz.UUCP> srp@ethz.UUCP (Scott Presnell) writes: >Hello, >I have an interest in a program that will display the oragnization of a >directory tree in UNIX (or MSDOS). This program would hopefully handle >links, etc. If possible the program should be written in 'C'. >I am mainly interested in the algorithm to parse and display such a tree >so any program that sounds similar would be of interest to me too. I would like this code as well - a handy ( and dandy ) piece of software to help out unix users who don't want to use find and other fun toys... -- Dennis Grittner, Computer Services Manager, St. Paul Public Works U.S.Mail: Room 700 City Hall Annex, 25 W. 4th St., St. Paul, Minn., 55102 A.T.&T.: (612)-298-4402 UUCP:{your path to:}ihnp4!mmm!quest!pwcs!dennisg "developing nuclear arms for peace is like fu**ing for chastity"
lenoil@apple.UUCP (Robert Lenoil) (12/04/86)
In article <415@ethz.UUCP> srp@ethz.UUCP (Scott Presnell) writes: >Hello, >I have an interest in a program that will display the oragnization of a >directory tree in UNIX (or MSDOS)... There is a wonderful public domain program for MSDOS called TREED, whose banner says that it is written by "R A Flavin". It graphically displays the directory structure of a disk, with output like this: ___BIN | |_DOC___RELEASED | |_WORKING | |_SRC ... I wish I knew where you could download it from; I got my copy from a friend who doesn't remember where his came from. Perhaps someone on the net can provide this information. Robert Lenoil
jc@piaget.UUCP (John Cornelius) (12/04/86)
In article <766@pwcs.StPaul.GOV> dennisg@pwcs.StPaul.GOV (Dennis Grittner) writes: >In article <415@ethz.UUCP> srp@ethz.UUCP (Scott Presnell) writes: >>Hello, >>I have an interest in a program that will display the oragnization of a >>directory tree in UNIX (or MSDOS). This program would hopefully handle . . >I would like this code as well - a handy ( and dandy ) piece of >software to help out unix users who don't want to use find and >other fun toys... > The file tree.c produces a program that does what you want except that it does not offer link information (as far as I know). I believe that it has been posted to sources several times. John Cornelius (...!sdcsvax!piaget!jc)