From: Marko Schulz Date: 2002-03-17T08:31:54+09:00 Subject: Re: Some potential RCRs On Wed, Mar 13, 2002 at 01:39:23PM +0900, Sean O'Dell wrote: > "Bob Alexander" wrote in message > news:3C8EC7F5.A4B702C7@rsv.ricoh.com... > > On the topic of whether ".." and "." should be in our directory > > listings: > > > > Can someone suggest an argument as to why having them in the listed > > entries is useful? > > That's because ls considers files beginning with '.' to be "hidden." It > hides all files beginning with '.' by default. There is no real "hidden" > attribute in unix, so it's accepted that files beginning with '.' are > "hidden" files. At least GNU-ls has a switch to list all files but '.' and '..': ls -A > A good example of their usefulness would be a simple file browser, say an > HTML-based file browser. Each file in a directory displayed shows date, mod > time and size. By simply showing this information for each directory entry, > you can display that information for the current directory and the parent > directory without having to do anything particularly special. Also, if you > attempt to chdir a directory the user selects (in other words, navigate), > and the user selects '..', they can get to the parent directory. That is a very special case. Even though it would be extra effort, such a browser could easily display the parent and current directory additional. BTW: . and .. are not very intuitive names, so a browser would do good to display them in a special way anyhow. > '.' and '..' aren't just artifacts. If the user has selected a directory, > it's easier and more efficient to get your stat information from '.' than > from Dir.cwd(), and it's easier to change to the parent directory by > performing a chdir('..') than to grab the current working dir and parse it > to find the parent to chdir to it. You may use '.' and '..' whether they are returned by Dir::[] or not. Maybe your code becomes a little bit less portable by doing so, but this even worse when you always have to test for '.' and '..' in the return values of Dir::[] or a Dir#each-block. -- marko schulz