struct

File::Info

Inherits Crystal::System::FileInfo / Struct / Value / Object

A File::Info contains metadata regarding a file. It is returned by File.info, File#info and File.info?.

Class methods

executable?(path : Path | String) : Bool

Returns true if path is executable by the real user id of this process else returns false.

File.write("foo", "foo")
File::Info.executable?("foo") # => false

This method returns the readable property as reported by the file system which provides no indication of whether Process.execute would be a valid operation because it applies to all file types, including directories (which typically are executable to signal it's allowed to list their contents).

Source
readable?(path : Path | String) : Bool

Returns true if path is readable by the real user id of this process else returns false.

File.write("foo", "foo")
File::Info.readable?("foo") # => true

This method returns the readable property as reported by the file system which provides no indication of whether File.read would be a valid operation because it applies to all file types, including directories.

Source
writable?(path : Path | String) : Bool

Returns true if path is writable by the real user id of this process else returns false.

File.write("foo", "foo")
File::Info.writable?("foo") # => true

This method returns the readable property as reported by the file system which provides no indication of whether File.write would be a valid operation because it applies to all file types, including directories.

Source

Instance methods

directory?

Returns true if this Info represents a directory. Shortcut for type.directory?.

Source
file?

Returns true if this Info represents a standard file. Shortcut for type.file?.

Source
flags

The special flags this file has set.

Source
group_id

The group ID that the file belongs to.

Source
modification_time

The last time this file was modified.

Source
owner_id

The user ID that the file belongs to.

Source
permissions

The permissions of the file.

Source
same_file?(other : self) : Bool

Returns true if this Info and other are of the same file.

On Unix-like systems, this compares device and inode fields, and will compare equal for hard linked files.

Source
size

Size of the file, in bytes.

Source
type

The type of the file.

Source