Issue 5168: shutil.copystat does not copy the "hidden" flag on windows (original) (raw)

Hi!

While copying hidden files on windows, the hidden flag is lost (surprisingly the read-only flag is copied).

Is this a bug or a feature? The documentation only says that flags are also copied by shutil.copystat, but no details.

See the attached file for an example.

Cheers, Robert

It's neither a bug nor a feature. It's simply not possible to copy the hidden flag (or system flag, for that matter), since there is no API for doing so. copystat only copies Unix attributes.

If you were to copy the hidden flag, you would also have to copy the read-only flag, the access control list, and possible alternative file streams. You better use the CopyFile API function of Windows for that.