(#14599) Handle ENOTDIR in file type
If a file resource is used with a path where a component of path is not
a directory, the stat systemcall can raise the error Errno::ENOTDIR
which was not handled by the file type.
This can lead to the following error (if e.g /tmp/xx is a normal file)
err: /Stage[main]//File[/tmp/xx/yy/zz/1]: Could not evaluate: Not a directory - /tmp/xx/yy/zz/1
Catch the error and return nil in the stat method like we do for absent
files or file where we do not have the permission to stat.
Puppet will still raise errors when trying to create such a file of
course like
err: /Stage[main]//File[/etc/fstab/foo]/ensure: change from absent to file failed: Could not set 'file on ensure: Not a directory - /etc/fstab/foo at line
But something like
puppet apply -ve 'file { "/etc/fstab/foo": ensure => absent}'
will now work without errors because /etc/fstab/foo is indeed absent.