Subject: "." as the first entry..
To: None <netbsd-users@netbsd.org>
From: Jorgen Lundman <lundman@lundman.net>
List: netbsd-users
Date: 02/19/2003 16:03:48
Just a curious question. Writing some generic recursion code which 
currently relies on that there is a "." entry when I start a new 
sub-directory..

So, if I go:

dirp = opendir(path);

if (dirp) {

    dirt = readdir(dirp);

    if (dirt) {

Here, being the _first_ call to readdir(9 on a directory, I generally 
find that d_name is for "." (followed by ".." on a subsequent call).

Now, readdir() makes no promise that this is always the case, but, in 
Unix, can you "reasonably" safely assume this is the case? I would 
assume when you create a directory, "." (and "..") is always created in 
slot 0 and 1 of the directory, and in a healthy filesystem, remain in 
that position?

Unless you manage to delete and re-create it.

true for BSD? For Unix?

Lund


-- 
Jorgen Lundman       | <lundman@lundman.net>
Unix Administrator   | +81 (0)3 -5456-2687 ext 1017 (work)
Shibuya-ku, Tokyo    | +81 (0)90-5578-8500          (cell)
Japan                | +81 (0)3 -3375-1767          (home)