extract common code

@DeepDiver1975 @MTGap @karlitschek @schiesbn @icewind1991 @bartv2 This unifies the code path used to add entries to the fileList table.