permissions checking works for directories but not for creating files within directories