Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!cmcl2!adm!xadmx!devusr@relay.nswc.navy.mil From: devusr@relay.nswc.navy.mil Newsgroups: comp.unix.wizards Subject: [Re: Dot files always first in directory?] Message-ID: <19485@adm.BRL.MIL> Date: 5 May 89 20:16:51 GMT Sender: news@adm.BRL.MIL Lines: 33 >> Jonathan I. Kamens : >> >> It it safe to assume when writing a program which manipulates >> directories that . and .. will always be the first two entries in a >> directory? > Michael J. Chinni : >On our systems (DoD Army) we have a program which uses several files that >begin with a "," for storage. These all apear before "." and ".." in the >directory listings. [...] Also, users sometimes create [such] files [...] but michael, just because ls reports the files in that order doesn't mean that they are stored in the directory in that order. no, the "dot and dot-dot come first" assumption is invalid for other reasons: doug gwyn mentioned one, and i can think of other scenarios where .. gets unlinked and relinked to some other inode. however, i think that there is a tradeoff between simple code which is going to work in 98% of the existing environments, and (marginally) more complicated code which will work everywhere :-) folks need to decide just how portable their program should be, and whether the effort to get to that level is warranted. in this case, it doesn't seem to be that hard to cover all the possibilities. BTW, scandir(3) provides an easy way to exclude dot-files. perhaps its use is called for in this case. /dave --- Dave Paulson dpaulso@relay.nswc.navy.mil (703)663-2137 "I've upped my standards; now up yours" -- Pat Paulsen