Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!boulder!panos From: panos@boulder.Colorado.EDU (Panos Tsirigotis) Newsgroups: comp.unix.wizards Subject: Re: Dot files always first in directory? Message-ID: <8600@boulder.Colorado.EDU> Date: 5 May 89 04:37:41 GMT References: <11108@bloom-beacon.MIT.EDU> <672@mitisft.Convergent.COM> Sender: news@boulder.Colorado.EDU Reply-To: panos@boulder.Colorado.EDU (Panos Tsirigotis) Organization: University of Colorado, Boulder Lines: 34 In article <672@mitisft.Convergent.COM> kemnitz@mitisft.Convergent.COM (Gregory Kemnitz) writes: >In article <11108@bloom-beacon.MIT.EDU>, jik@athena.mit.edu (Jonathan I. Kamens) writes: >> >> It it safe to assume when writing a program which manipulates >> directories that . and .. will always be the first two entries in a >> directory? >> >> If I can't assume that, then I've got to compare every file in the >> directory to "." and "..", and this would probably slow the program >> down even more than it already is. >> > >After checks on our file system, I found that this assumption is PROBABLY >correct. However, this type of thing is EXTREMELY DANGEROUS, unless it is >part of the definition of the directory structure (It might well be - if it >is ignore this message and I'll be eating flames). This type of assumption >usually leades to unportable code. (will your code run on UNIX forever??) >... Copying from dir(5) of the BSD programmer's manual: -> By convention, the first two entries in each directory are -> for `.' and `..'. So, as long as the file system is maintained by UNIX it is safe to assume that the first 2 entries are for for "." and ".." (I assume that System V follows the same convention; I don't have those manuals available). Panos Tsirigotis ---------------------------------------------------- | Email address: panos@boulder.colorado.edu | ----------------------------------------------------