@@ -531,20 +531,35 @@ extension _FileManagerImpl {
531
531
throw CocoaError . errorWithFilePath ( path, win32: GetLastError ( ) , reading: true )
532
532
}
533
533
534
+ let hFile = CreateFileW ( pwszPath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nil , OPEN_EXISTING, 0 , nil )
535
+ if hFile == INVALID_HANDLE_VALUE {
536
+ throw CocoaError . errorWithFilePath ( path, win32: GetLastError ( ) , reading: true )
537
+ }
538
+ defer { CloseHandle ( hFile) }
539
+
540
+ let dwFileType = GetFileType ( hFile)
541
+ let fatType : FileAttributeType = switch ( dwFileType) {
542
+ case FILE_TYPE_CHAR: FileAttributeType . typeCharacterSpecial
543
+ case FILE_TYPE_DISK: FileAttributeType . typeRegular
544
+ case FILE_TYPE_PIPE: FileAttributeType . typeSocket
545
+ case FILE_TYPE_UNKNOWN: FileAttributeType . typeUnknown
546
+ default : FileAttributeType . typeUnknown
547
+ }
548
+
534
549
let size : UInt64 = ( UInt64 ( faAttributes. nFileSizeHigh) << 32 ) | UInt64 ( faAttributes. nFileSizeLow)
535
550
let creation : Date = Date ( timeIntervalSince1970: faAttributes. ftCreationTime. timeIntervalSince1970)
536
551
let modification : Date = Date ( timeIntervalSince1970: faAttributes. ftLastWriteTime. timeIntervalSince1970)
537
552
return [
538
553
. size: _writeFileAttributePrimitive ( size, as: UInt . self) ,
539
554
. modificationDate: modification,
540
555
. creationDate: creation,
556
+ . type: fatType,
541
557
542
558
// TODO(compnerd) support these attributes, remapping the Windows semantics...
543
559
// .posixPermissions: ...,
544
560
// .referenceCount: ...,
545
561
// .systemNumber: ...,
546
562
// .systemFileNumber: ...,
547
- // .type: ...,
548
563
// .ownerAccountID: ...,
549
564
// .groupownerAccountID: ...,
550
565
// .ownerAccountName: ...,
0 commit comments