Property definitions

core $ FileStat :: defaultinit
# Information on a file
#
# Created by `Path::stat` and `Path::link_stat`.
#
# The information within this class is gathered when the instance is initialized
# it will not be updated if the targeted file is modified.
class FileStat
	super Finalizable

	# TODO private init

	# The low-level status of a file
	#
	# See: POSIX stat(2)
	private var stat: NativeFileStat

	private var finalized = false

	redef fun finalize
	do
		if not finalized then
			stat.free
			finalized = true
		end
	end

	# Returns the last access time in seconds since Epoch
	fun last_access_time: Int
	do
		assert not finalized
		return stat.atime
	end

	# Returns the last access time
	#
	# alias for `last_access_time`
	fun atime: Int do return last_access_time

	# Returns the last modification time in seconds since Epoch
	fun last_modification_time: Int
	do
		assert not finalized
		return stat.mtime
	end

	# Returns the last modification time
	#
	# alias for `last_modification_time`
	fun mtime: Int do return last_modification_time


	# Size of the file at `path`
	fun size: Int
	do
		assert not finalized
		return stat.size
	end

	# Is self a regular file and not a device file, pipe, socket, etc.?
	fun is_file: Bool
	do
		assert not finalized
		return stat.is_reg
	end

	# Alias for `is_file`
	fun is_reg: Bool do return is_file

	# Is this a directory?
	fun is_dir: Bool
	do
		assert not finalized
		return stat.is_dir
	end

	# Is this a symbolic link?
	fun is_link: Bool
	do
		assert not finalized
		return stat.is_lnk
	end

	# FIXME Make the following POSIX only? or implement in some other way on Windows

	# Returns the last status change time in seconds since Epoch
	fun last_status_change_time: Int
	do
		assert not finalized
		return stat.ctime
	end

	# Returns the last status change time
	#
	# alias for `last_status_change_time`
	fun ctime: Int do return last_status_change_time

	# Returns the permission bits of file
	fun mode: Int
	do
		assert not finalized
		return stat.mode
	end

	# Is this a character device?
	fun is_chr: Bool
	do
		assert not finalized
		return stat.is_chr
	end

	# Is this a block device?
	fun is_blk: Bool
	do
		assert not finalized
		return stat.is_blk
	end

	# Is this a FIFO pipe?
	fun is_fifo: Bool
	do
		assert not finalized
		return stat.is_fifo
	end

	# Is this a UNIX socket
	fun is_sock: Bool
	do
		assert not finalized
		return stat.is_sock
	end
end
lib/core/file.nit:760,1--890,3