Package: gio

Function gio:file-query-info

Lambda List

gio:file-query-info (file attributes flags &optional cancellable)

Arguments

file -- a g:file instance
attributes -- an attribute query string
flags -- a g:file-query-info-flags value
cancellable -- an optional g:cancellable instance

Return Value

The g:file-info instance for the given file or nil on error.

Details

Gets the requested information about the specified file. The result is a g:file-info instance that contains key-value attributes, such as the type or size of the file.

The attributes value is a string that specifies the file attributes that should be gathered. It is not an error if it is not possible to read a particular requested attribute from a file, it just will not be set. The attributes argument should be a comma-separated list of attributes or attribute wildcards. The wildcard "" means all attributes, and a wildcard like "standard::" means all attributes in the standard namespace. An example attribute query be "standard::*,owner::user".

If the cancellable argument is not nil, then the operation can be cancelled by triggering the cancellable instance from another thread.

For symlinks, normally the information about the target of the symlink is returned, rather than information about the symlink itself. However if you pass :nofollow-symlinks in flags the information about the symlink itself will be returned. Also, for symlinks that point to non-existing files the information about the symlink itself will be returned.

Examples

Query and list the file attributes for a Lisp file in the test directory:
(let* ((path (glib-sys:sys-path "test/rtest-gio-file.lisp" "cl-cffi-glib"))
       (file (g:file-new-for-path path))
       (info (g:file-query-info file "standard::*" :none)))
  (g:file-info-list-attributes info))
=> ("standard::type" "standard::is-hidden" "standard::is-backup"
    "standard::is-symlink" "standard::name" "standard::display-name"
    "standard::edit-name" "standard::copy-name" "standard::icon"
    "standard::content-type" "standard::fast-content-type"
    "standard::size" "standard::allocated-size" "standard::symbolic-icon")    
 

See also

2026-03-21