core: Create directory before real_path [GH-2196]