posix: handle non-NULL filename with environment-based directories