Re: possible optimization



On Mon, 2006-02-27 at 12:31 -0600, Federico Mena Quintero wrote:
> On Mon, 2006-02-27 at 18:59 +0100, Alexander Larsson wrote:
> > > You don't even need the names.  stat("/some/directory") will give you
> > > the number of entries in the directory in the st_nlink field.  An empty
> > > directory has st_nlink=2 because of "." and "..".  This is useful for
> > > non-deep counts.
> > 
> > Hmm. This is interesting. How portable is this amongst filesystems? (Of
> > course, it'll only work for file:/// files.)
> 
> Crap, I lied :)  st_nlink for a directory gives you the number of
> *subdirectories*, including . and ..
> 
> This is what we used in GMC to know when to display an expander in the
> folder tree.

But does this work with e.g. a smbfs filesystem, since smb doesn't have
the hard links that unix filesystems have.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a world-famous alcoholic romance novelist who hides his scarred face 
behind a mask. She's a scantily clad green-skinned bodyguard from a different 
time and place. They fight crime! 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]