Boost logo

Boost :

From: Jeremy Maitin-Shepard (jbms_at_[hidden])
Date: 2003-12-01 17:15:18

"Peter Dimov" <pdimov_at_[hidden]> writes:

> Jeremy Maitin-Shepard wrote:
>> Beman Dawes <bdawes_at_[hidden]> writes:
>>>> unsigned int link_count(path const &ph);
>>>> Returns the number of hard links to the file specified by the
>>>> argument. (On platforms that do not support hard linking, this
>>>> always
>>>> returns 1.) Throws if the path does not exist or is inaccessible.
>>> What are some use cases for this function? Do they degrade
>>> gracefully on platforms which don't support hard linking? Do they
>>> degrade gracefully on platforms which support hard linking on some
>>> file systems and not
>>> others?
>> The use case is programs like tar or du -- a typical use is to store a
>> unique identifier in a hash table for each file with a link count
>> greater than 1, so that the file is only backup up (in the case of tar)
>> or counted (in the case of du) once.

> You need an "unique identifier" function (inode?) for this, not a "link
> count" function. ;-)

The link count function allows for an optimization: only files with
more than one link need to be added to the hash table or tested. Due
to the lack of a unique identifier function, this optimization is
especially important, since the path would have to be tested against
every other file with more than one link.

Jeremy Maitin-Shepard

Boost list run by bdawes at, gregod at, cpdaniel at, john at