Information on the file at self following symbolic links

Returns null if there is no file at self. last_error is updated to contains the error information on error, and null on success.

assert "/etc/".to_path.stat.is_dir
assert "/etc/issue".to_path.stat.is_file
assert "/fail/does not/exist".to_path.stat == null
var p = "/tmp/".to_path
var stat = p.stat
if stat != null then # Does `p` exist?
    print "It's size is {stat.size}"
    if stat.is_dir then print "It's a directory"
else
    print p.last_error.to_s
end

Property definitions

core $ Path :: stat
	# Information on the file at `self` following symbolic links
	#
	# Returns `null` if there is no file at `self`.
	# `last_error` is updated to contains the error information on error, and null on success.
	#
	#     assert "/etc/".to_path.stat.is_dir
	#     assert "/etc/issue".to_path.stat.is_file
	#     assert "/fail/does not/exist".to_path.stat == null
	#
	# ~~~
	# var p = "/tmp/".to_path
	# var stat = p.stat
	# if stat != null then # Does `p` exist?
	#     print "It's size is {stat.size}"
	#     if stat.is_dir then print "It's a directory"
	# else
	#     print p.last_error.to_s
	# end
	# ~~~
	fun stat: nullable FileStat
	do
		var stat = path.to_cstring.file_stat
		if stat.address_is_null then
			last_error = new IOError("Cannot open `{path}`: {sys.errno.strerror}")
			return null
		end
		last_error = null
		return new FileStat(stat)
	end
lib/core/file.nit:448,2--476,4