RFE: provide an efficient way to retrieve Unix ctime (changed-time)

Marc Strapetz marc.strapetz at syntevo.com
Thu Oct 12 14:45:51 UTC 2017


On 12.10.2017 15:25, Alan Bateman wrote:
> On 12/10/2017 13:38, Marc Strapetz wrote:
>> During a Files.walkFileTree(), UnixFileAttributes seem to be populated 
>> with all available file system information, especially st_ctime_sec 
>> and st_ctime_nsec, but currently there is no way to access this 
>> information (except of using reflection-based hacks).
>>
>> As suggested in a comment by Alan Bateman on stackoverflow.com[1], 
>> this information could be made available directly through 
>> PosixFileAttributes.
>>
> Right, there's no type safe way to get this through the standard API 
> although it can be obtained by attribute name using 
> Files.getAttribute(file, "unix:ctime").

Thanks for pointing me to this method. I've tried this now and it's 
surprisingly fast:

For my test tree with 35K files, a Files.walkFileTree() with 
SimpleFileVisitor takes on average 115ms. When 
SimpleFileVisitor.visitFile is additionally calling 
Files.getAttribute(file, "unix:ctime"), it takes 170ms.

 From the method signature (Path, String) I would have expected a 
significantly higher overhead.

-Marc





More information about the nio-dev mailing list