utils: Cache get_real_path to improve performance, make API more const