Adjust the logic of the `File` class (see #5341)