@@ -888,12 +888,10 @@ struct alignas(long long) _Aligned_file_attrs {
888
888
return _Last_error;
889
889
}
890
890
891
- constexpr auto _Basic_info_data = __std_fs_stats_flags::_Attributes | __std_fs_stats_flags::_Last_write_time;
892
- constexpr auto _Attribute_tag_info_data = __std_fs_stats_flags::_Attributes | __std_fs_stats_flags::_Reparse_tag;
893
- constexpr auto _Standard_info_data = __std_fs_stats_flags::_File_size | __std_fs_stats_flags::_Link_count;
891
+ constexpr auto _Basic_info_data = __std_fs_stats_flags::_Attributes | __std_fs_stats_flags::_Last_write_time;
892
+ constexpr auto _Standard_info_data = __std_fs_stats_flags::_File_size | __std_fs_stats_flags::_Link_count;
894
893
895
- if (_Flags != _Attribute_tag_info_data && _Bitmask_includes (_Flags, _Basic_info_data)) {
896
- // we have data FileBasicInfo can fill in, that FileAttributeTagInfo wouldn't exactly fill in
894
+ if (_Bitmask_includes (_Flags, _Basic_info_data | __std_fs_stats_flags::_Reparse_tag)) {
897
895
FILE_BASIC_INFO _Info;
898
896
if (!GetFileInformationByHandleEx (_Handle._Get (), FileBasicInfo, &_Info, sizeof (_Info))) {
899
897
return __std_win_error{GetLastError ()};
@@ -902,17 +900,21 @@ struct alignas(long long) _Aligned_file_attrs {
902
900
_Stats->_Attributes = __std_fs_file_attr{_Info.FileAttributes };
903
901
_Stats->_Last_write_time = _Info.LastWriteTime .QuadPart ;
904
902
_Flags &= ~_Basic_info_data;
905
- }
903
+ if (_Bitmask_includes (_Flags, __std_fs_stats_flags::_Reparse_tag)) {
904
+ // Calling GetFileInformationByHandleEx with FileAttributeTagInfo fails on FAT file system with
905
+ // ERROR_INVALID_PARAMETER. We avoid calling this for non-reparse-points.
906
+ if (_Info.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
907
+ FILE_ATTRIBUTE_TAG_INFO _TagInfo;
908
+ if (!GetFileInformationByHandleEx (_Handle._Get (), FileAttributeTagInfo, &_TagInfo, sizeof (_TagInfo))) {
909
+ return __std_win_error{GetLastError ()};
910
+ }
906
911
907
- if (_Bitmask_includes (_Flags, _Attribute_tag_info_data)) {
908
- FILE_ATTRIBUTE_TAG_INFO _Info;
909
- if (!GetFileInformationByHandleEx (_Handle._Get (), FileAttributeTagInfo, &_Info, sizeof (_Info))) {
910
- return __std_win_error{GetLastError ()};
912
+ _Stats->_Reparse_point_tag = __std_fs_reparse_tag{_TagInfo.ReparseTag };
913
+ } else {
914
+ _Stats->_Reparse_point_tag = __std_fs_reparse_tag::_None;
915
+ }
916
+ _Flags &= ~__std_fs_stats_flags::_Reparse_tag;
911
917
}
912
-
913
- _Stats->_Attributes = __std_fs_file_attr{_Info.FileAttributes };
914
- _Stats->_Reparse_point_tag = __std_fs_reparse_tag{_Info.ReparseTag };
915
- _Flags &= ~_Attribute_tag_info_data;
916
918
}
917
919
918
920
if (_Bitmask_includes (_Flags, _Standard_info_data)) {
0 commit comments