core: Deduplicate code converting struct stat -> GFileInfo

We were doing the same thing in a number of places, make a helper
function.