Hi,
I am having some trouble reading a directory that contains files/directories with restrictive permissions. This is my code:
>>>>
let folder = Gio.file_new_for_path( path );
let children = folder.enumerate_children('*', 0, null, null);
while ((file_info = children.next_file(null, null)) !== null) {
if (file_info.get_is_hidden()) { continue; } // skip hidden files
if (isDirectory(file_info)) { dirs.push(file_info); } // is directory
else { files.push(file_info); } // is file
}
children.close(null, null);
>>>>
If there's a file or directory in "path" with restrictive permissions, then line 2 (folder.enumerate_children) throws this error:
(gnome-shell:31408): Gjs-WARNING **: JS ERROR: Gio.IOErrorEnum: Permission denied
and execution stops there.
I can't encapsulate it in a try/catch since I then can't iterate over the rest of the content in "path".
How can I ignore such files/folders in folder.enumerate_children?