affile: affile_open_file() refactoring

This splits up the large affile_open_file() function into smaller, more
readable private functions, that makes it easier to understand the
control flow.

Signed-off-by: Budai Laszlo <lbudai@balabit.hu>