Dot files always first in directory?
David C Lawrence
tale at pawl.rpi.edu
Sat May 6 01:32:15 AEST 1989
In <11108 at bloom-beacon.MIT.EDU> jik at athena.mit.edu (Jonathan I. Kamens) writes:
jik>It it safe to assume when writing a program which manipulates
jik>directories that . and .. will always be the first two entries in a
jik>directory?
In article <2778 at buengc.BU.EDU> bph at buengc.BU.EDU (Blair P. Houghton) writes:
bph> To beat this horse quite dead, any leading character that would
bph> sort before the period will place the filename before the . and
bph> .. in a directory listing. The ascii characters that will do
bph> this are space, !, ", #, $, %, &, ', (, ), *, +, ,, and -. I
bph> haven't tried it, but I bet you can get the nonprinting ascii
bph> characters to do it too. There are 32 of those.
Now here is where it really matters: are you using a script or C to
get at the directory. Jonathan showed, in either the original posting
or in a follow-up, that he wanted an example in C. Even in the
script, it is only the default output of ls(1) that will sort names
the way you offer; ls -f will give them the way they are arranged in
the block. #.newsrc# currently is the last thing listed in my home
directory by an ls -f.
With Sun machines, . and .. are stated as being the first two entries
in a directory block "by convention". In fact, fsck will complain if
it comes across a d block which first two inodes do not point to
itself and to its parent respectively (exception being the root
directory whose parent does not exist; .. == .). I suspect that if
Jonathan is writing for multiple architectures for Athena then he
should check the manuals for different machines he knows he will have
to support, just to be sure.
--
tale at rpitsmts.bitnet, tale%mts at itsgw.rpi.edu, tale at pawl.rpi.edu
More information about the Comp.unix.wizards
mailing list