Set file ownership with Gio

Hi all:

I’m trying to set the file owner and group using Gio. I tried both with:

let info = new Gio.FileInfo();
info.set_attribute_string (Gio.FILE_ATTRIBUTE_OWNER_USER, user);
info.set_attribute_string (Gio.FILE_ATTRIBUTE_OWNER_GROUP, user);
destination_file.set_attributes_from_info(info, Gio.FILE_QUERY_INFO_NONE, null);


destination_file.set_attribute_string(Gio.FILE_ATTRIBUTE_OWNER_USER, user, Gio.FILE_QUERY_INFO_NONE, null);
destination_file.set_attribute_string(Gio.FILE_ATTRIBUTE_OWNER_GROUP, user, Gio.FILE_QUERY_INFO_NONE, null);

but the result is always that “setting the attribute owner::user isn’t supported”.

How can I do it?


The attributes you must use are FILE_ATTRIBUTE_UNIX_UID and FILE_ATTRIBUTE_UNIX_GID along with the uid and gid number.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.