Add more check to avoid code enter into wrong state.
drwxr-xr-x - edk2