Hard Links

Scott Palmer swpalmer at gmail.com
Fri May 13 09:28:15 PDT 2011


On 2011-05-13, at 11:58 AM, Alan Bateman wrote:

> Scott Palmer wrote:
>> :
>> 
>> There are many cases where you would want to break hard links when you need to make changes to a file (some sort of copy-on-write semantics), but you can't code it if you don't know if the file is linked.  I see the isSymbolicLink method, but nothing similar for hard links.
>> 
>> Scott
> The API doesn't have a method specifically for this but our implementation can return the number of links with Files.getAttribute(path, "unix:nlink").

Thanks Alan,

What about for Windows?  It seems that the JRE should abstract this, if possible, so I don't need OS specific bits in my code unless absolutely necessary. It is odd to have this implementation-specific and OS-specific thing when the decision to support hard links was already made with the addition of the createLink API.  I assume since the early docs referenced a linkCount() API that there was a conscious decision to remove it, I'm curious about the reasons for that. Or maybe it was just something that accidentally got lost when the API was juggled around and FileRef went away?

Is there are reason this isn't part of the "basic" view?

Scott


More information about the nio-discuss mailing list