|
Boost : |
From: Jeremy Maitin-Shepard (jbms_at_[hidden])
Date: 2003-12-01 17:27: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. ;-)
A more compelling reason for needing link_count is for use in a program
such as a text editor that makes backups when saving: it can check to
see if the link count is 1, in which case it can rename instead of
copying to make the backup.
-- Jeremy Maitin-Shepard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk