[CS-FSLUG] Need a volunteer to test a program

David Aikema daikema at gmail.com
Sun Nov 13 02:40:09 CST 2005


On 11/12/05, Nathan T. <celerate at gmail.com> wrote:
> Ark it tends to think plain text files are folders and as such it reports
> that it cannot browse the contents of those plain text files as if they were
> folders ( I wonder why ;-) ).

Check the man page for lstat (which you're already using in your
program).  It should show you how to use the st_mode field in the
structure lstat sets up to check whether or not a given file is a
directory.  You can use the same to tell whether or not something is a
symlink or not.

> The program does not yet work with shortcuts such as using ./ instead of the
> current path, or using ~ instead of /home/yourname, if anyone knows how
> other programs implement that kind of thing that would be very helpful :-) .

You could retrieve the name of the current working directory by the
usage of the getcwd system call.  If would involve momentarily
changing to that directory, but that would be one way to figure out
the full pathname.  I suspect that there's probably a better way to do
this though, although I thing that I may have used some method like
that at one point in the past.

BTW, if you just want a list of files in a directory and
subdirectories, you can use "find <directory> [-maxdepth <N>]".  The
command won't do what your "-p" does, although you could accomplish
something similar by piping the output of pipe into something like
perl, awk, or sed.

Hope this helps,
Dave




More information about the Christiansource mailing list