[cs631apue] Some questions on midterm....

Tejas Nadkarni tnadkarn at stevens.edu
Sat Oct 5 14:29:22 EDT 2013


Thanks for the response.

I'm working on the formatting but I wanted to leave that as the last thing
and focus on all the functionality first. Again 9/10 times it's fine it's
that 1 other time that I need to fix.

The -d example you gave makes more sense as a use case and I see the
differences.

On the recursive, the latter output is what mine does which is the problem.
I think it's because I'm purely using fts_read in my program and haven't
used fts_children. I can see how using fts_children could allow the output
to be formatted that way since you're reading one directory at a time where
as with fts_read you're reading the hierarchy as it traverses. I'll have to
redo some of my code and approach to handle being able to output correctly.



On Sat, Oct 5, 2013 at 2:17 PM, Jan Schaumann <jschauma at stevens.edu> wrote:

> Tejas Nadkarni <tnadkarn at stevens.edu> wrote:
>
> > - How important is variable column width that's dynamic to the content
> like
> > the system 'ls' implementation does - this is specific to the -l
> > longformat. Is this required and will points be deducted? Mine uses fixed
> > widths which work for nearly every condition but obviously large file
> sizes
> > will throw it off. Want to check before I invest more time in it
>
> It's not functionally crucial, but you should try to make an effort to
> handle this.
>
> As noted before, we are writing system tools conceptually suitable for
> inclusion in the OS as a core component.  If you used the command
> provided by the system, and it garbled the output or took obvious short
> cuts, you'd likely think less of the system.  Formatting etc. tends to
> reflect on the overall care paid to the program.
>
> > - What is the point of the '-d' flag?
>
> The '-d' flag is useful when you want to display certain entries without
> recursing into them should they happen to be directories.  Suppose you
> want to get the long listing information of all entries starting with
> the letter 'b' under '/':
>
> ls -l /b*
>
> will open the /bin directory and instead give you the information about
> the files in that directory.
>
> ls -ld /b*
>
> will do the right thing.
>
>
> > It's not clear if all we're doing is printing out the path or cwd and
> > exiting?
>
> You should, as the manual page states, list directories encountered as
> plain files (and not list their contents, as you would without the '-d'
> flag) and not follow symbolic links given as arguments.
>
> ln -s / foo
> ls foo
> ls -ld foo
> ls -d foo
>
> > - the extra credit to implement -c that's for ls with the short format
> > right? i.e. not -l because we have to multi-column output for '-l'
> already.
> > I'm assuming then that -c is only valid without -l
>
> Correct.  '-c' changes the default output format of your program from
> '-1' to match that of the system provided ls(1).
>
>
> > Currently mine just prints out the files/directories as it traverses
> > based on sort. Any thoughts?
>
> I'm not sure I understand your question correctly, but: Your program
> needs to show the user which files belong to which directory.  That is,
> a single list of all files without any indication of what subdirectory
> they were found in would not be reasonable.
>
> For example:
>
> mkdir -p dir/subdir/subsubdir
> touch dir/file dir/subdir/file dir/subdir/subsubdir/file
> ls -R
> .:
> dir
>
> ./dir:
> file  subdir
>
> ./dir/subdir:
> file  subsubdir
>
> ./dir/subdir/subsubdir:
> file
>
>
> allows the user to see which files exist where.  If you printed
>
> ls -R
> dir
> file  subdir
> file  subsubdir
> file
>
> then it would be confusing for the user to figure out which 'file'
> resides where.
>
>
> If you meant something else, perhaps show examples of your program's
> output versus the system command's.
>
> -Jan
> _______________________________________________
> cs631apue mailing list
> cs631apue at lists.stevens.edu
> https://lists.stevens.edu/mailman/listinfo/cs631apue
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.stevens.edu/pipermail/cs631apue/attachments/20131005/53ff165a/attachment-0001.html>


More information about the cs631apue mailing list