fileutils: Avoid crash if g_set_prgname() has not been called

While we're here, also squash spaces in the filename to '_'.