[ Version ( since = "2.18" ) ]
public FileType query_file_type (FileQueryInfoFlags flags, Cancellable? cancellable = null)
Utility function to inspect the FileType of a file.
This is implemented using query_info and as such does blocking I/O.
The primary use case of this method is to check if a file is a regular file, directory, or symlink.
Example: Inspect the FileType:
public static int main (string[] args) {
if (args.length != 2) {
print ("%s FILE\n", args[0]);
return 0;
}
File file = File.new_for_commandline_arg (args[1]);
FileType type = file.query_file_type (FileQueryInfoFlags.NOFOLLOW_SYMLINKS);
print ("%s\n", type.to_string ());
return 0;
}
valac --pkg gio-2.0 GLib.File.query_file_type.vala
this |
input File |
flags |
a set of FileQueryInfoFlags passed to query_info |
cancellable |
optional Cancellable object, null to ignore |
The FileType of the file and g_file_type_unknown if the file does not exist |