Skip to content

gfileinfo: Document required attributes for helper getters

Philip Withnall requested to merge pwithnall/glib:2907-file-info-docs into main

It doesn’t make sense to (for example) call g_file_info_get_name() if the GFileInfo doesn’t contain G_FILE_ATTRIBUTE_STANDARD_NAME, given that building the GFileInfo is typically a static process and entirely under the control of the programmer.

By being this restrictive, we avoid having to return ‘unknown’ values for some of these standard APIs, particularly the numeric ones such as g_file_info_get_size(). If APIs like that were to work correctly in the face of a GFileInfo without G_FILE_ATTRIBUTE_STANDARD_SIZE specified, they’d have to be able to return a value to indicate the attribute is missing. Returning 0 or G_MAXSIZE to indicate that would be ambiguous.

Signed-off-by: Philip Withnall pwithnall@endlessos.org

Fixes: #2907 (closed)

Closes #2907 (closed)

Merge request reports