The reason stat doesn't work is that it follows links and ends up reporting on the linked file. File.lstat is the correct call.