@@ -228,8 +228,8 @@ extension FileManager {
228228
229229 try _contentsOfDir ( atPath: path, { ( entryName, entryType) throws in
230230 contents. append ( entryName)
231- if entryType & FILE_ATTRIBUTE_DIRECTORY == FILE_ATTRIBUTE_DIRECTORY
232- && entryType & FILE_ATTRIBUTE_REPARSE_POINT != FILE_ATTRIBUTE_REPARSE_POINT {
231+ if DWORD ( entryType) & FILE_ATTRIBUTE_DIRECTORY == FILE_ATTRIBUTE_DIRECTORY
232+ && DWORD ( entryType) & FILE_ATTRIBUTE_REPARSE_POINT != FILE_ATTRIBUTE_REPARSE_POINT {
233233 let subPath : String = joinPath ( prefix: path, suffix: entryName)
234234 let entries = try subpathsOfDirectory ( atPath: subPath)
235235 contents. append ( contentsOf: entries. map { joinPath ( prefix: entryName, suffix: $0) . standardizingPath } )
@@ -313,7 +313,7 @@ extension FileManager {
313313 guard let faAttributes = try ? windowsFileAttributes ( atPath: resolvedDest) else {
314314 throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: true , paths: [ path, destPath] )
315315 }
316- if faAttributes. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_DIRECTORY) == DWORD ( FILE_ATTRIBUTE_DIRECTORY) {
316+ if faAttributes. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY == FILE_ATTRIBUTE_DIRECTORY {
317317 dwFlags |= DWORD ( SYMBOLIC_LINK_FLAG_DIRECTORY)
318318 }
319319 }
@@ -327,7 +327,7 @@ extension FileManager {
327327
328328 internal func _destinationOfSymbolicLink( atPath path: String ) throws -> String {
329329 let faAttributes = try windowsFileAttributes ( atPath: path)
330- guard faAttributes. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_REPARSE_POINT) == DWORD ( FILE_ATTRIBUTE_REPARSE_POINT) else {
330+ guard faAttributes. dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT == FILE_ATTRIBUTE_REPARSE_POINT else {
331331 throw _NSErrorWithWindowsError ( DWORD ( ERROR_BAD_ARGUMENTS) , reading: false )
332332 }
333333
@@ -484,12 +484,12 @@ extension FileManager {
484484
485485 internal func _copySymlink( atPath srcPath: String , toPath dstPath: String , variant: String = " Copy " ) throws {
486486 let faAttributes : WIN32_FILE_ATTRIBUTE_DATA = try windowsFileAttributes ( atPath: srcPath)
487- guard faAttributes. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_REPARSE_POINT) == DWORD ( FILE_ATTRIBUTE_REPARSE_POINT) else {
487+ guard faAttributes. dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT == FILE_ATTRIBUTE_REPARSE_POINT else {
488488 throw _NSErrorWithErrno ( EINVAL, reading: true , path: srcPath, extraUserInfo: extraErrorInfo ( srcPath: srcPath, dstPath: dstPath, userVariant: variant) )
489489 }
490490
491491 let destination = try destinationOfSymbolicLink ( atPath: srcPath)
492- let isDir = try windowsFileAttributes ( atPath: srcPath) . dwFileAttributes & DWORD ( FILE_ATTRIBUTE_DIRECTORY) == DWORD ( FILE_ATTRIBUTE_DIRECTORY)
492+ let isDir = try windowsFileAttributes ( atPath: srcPath) . dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY == FILE_ATTRIBUTE_DIRECTORY
493493 if fileExists ( atPath: dstPath) {
494494 try removeItem ( atPath: dstPath)
495495 }
@@ -585,15 +585,15 @@ extension FileManager {
585585 }
586586 }
587587
588- if faAttributes. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY {
588+ if faAttributes. dwFileAttributes & FILE_ATTRIBUTE_READONLY == FILE_ATTRIBUTE_READONLY {
589589 if try ! FileManager. default. _fileSystemRepresentation ( withPath: path, {
590- SetFileAttributesW ( $0, faAttributes. dwFileAttributes & ~ DWORD ( FILE_ATTRIBUTE_READONLY) )
590+ SetFileAttributesW ( $0, faAttributes. dwFileAttributes & ~ FILE_ATTRIBUTE_READONLY)
591591 } ) {
592592 throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: false , paths: [ path] )
593593 }
594594 }
595595
596- if faAttributes. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_DIRECTORY) == 0 {
596+ if faAttributes. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY == 0 {
597597 if try ! FileManager. default. _fileSystemRepresentation ( withPath: path, DeleteFileW) {
598598 throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: false , paths: [ path] )
599599 }
@@ -635,15 +635,15 @@ extension FileManager {
635635 }
636636
637637 itemPath = " \( currentDir) \\ \( file) "
638- if ffd. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY {
638+ if ffd. dwFileAttributes & FILE_ATTRIBUTE_READONLY == FILE_ATTRIBUTE_READONLY {
639639 if try ! FileManager. default. _fileSystemRepresentation ( withPath: itemPath, {
640- SetFileAttributesW ( $0, ffd. dwFileAttributes & ~ DWORD ( FILE_ATTRIBUTE_READONLY) )
640+ SetFileAttributesW ( $0, ffd. dwFileAttributes & ~ FILE_ATTRIBUTE_READONLY)
641641 } ) {
642642 throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: false , paths: [ file] )
643643 }
644644 }
645645
646- if ( ffd. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_DIRECTORY) != 0 ) {
646+ if ( ffd. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY != 0 ) {
647647 if file != " . " && file != " .. " {
648648 dirStack. append ( itemPath)
649649 }
@@ -682,7 +682,7 @@ extension FileManager {
682682 internal func _fileExists( atPath path: String , isDirectory: UnsafeMutablePointer < ObjCBool > ? ) -> Bool {
683683 var faAttributes : WIN32_FILE_ATTRIBUTE_DATA = WIN32_FILE_ATTRIBUTE_DATA ( )
684684 do { faAttributes = try windowsFileAttributes ( atPath: path) } catch { return false }
685- if faAttributes. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_REPARSE_POINT) == DWORD ( FILE_ATTRIBUTE_REPARSE_POINT) {
685+ if faAttributes. dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT == FILE_ATTRIBUTE_REPARSE_POINT {
686686 let handle : HANDLE = ( try ? FileManager . default. _fileSystemRepresentation ( withPath: path) {
687687 CreateFileW ( $0, /* dwDesiredAccess= */ DWORD ( 0 ) ,
688688 DWORD ( FILE_SHARE_READ) , /* lpSecurityAttributes= */ nil ,
@@ -695,11 +695,11 @@ extension FileManager {
695695 if let isDirectory = isDirectory {
696696 var info : BY_HANDLE_FILE_INFORMATION = BY_HANDLE_FILE_INFORMATION ( )
697697 GetFileInformationByHandle ( handle, & info)
698- isDirectory. pointee = ObjCBool ( info. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_DIRECTORY) == DWORD ( FILE_ATTRIBUTE_DIRECTORY) )
698+ isDirectory. pointee = ObjCBool ( info. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY == FILE_ATTRIBUTE_DIRECTORY)
699699 }
700700 } else {
701701 if let isDirectory = isDirectory {
702- isDirectory. pointee = ObjCBool ( faAttributes. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_DIRECTORY) == DWORD ( FILE_ATTRIBUTE_DIRECTORY) )
702+ isDirectory. pointee = ObjCBool ( faAttributes. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY == FILE_ATTRIBUTE_DIRECTORY)
703703 }
704704 }
705705 return true
@@ -713,7 +713,7 @@ extension FileManager {
713713
714714 internal func _isWritableFile( atPath path: String ) -> Bool {
715715 guard let faAttributes: WIN32_FILE_ATTRIBUTE_DATA = try ? windowsFileAttributes ( atPath: path) else { return false }
716- return faAttributes. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_READONLY) != DWORD ( FILE_ATTRIBUTE_READONLY)
716+ return faAttributes. dwFileAttributes & FILE_ATTRIBUTE_READONLY != FILE_ATTRIBUTE_READONLY
717717 }
718718
719719 internal func _isExecutableFile( atPath path: String ) -> Bool {
@@ -730,12 +730,12 @@ extension FileManager {
730730 let parent = path. _nsObject. deletingLastPathComponent
731731 var faAttributes : WIN32_FILE_ATTRIBUTE_DATA = WIN32_FILE_ATTRIBUTE_DATA ( )
732732 do { faAttributes = try windowsFileAttributes ( atPath: parent) } catch { return false }
733- if faAttributes. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_READONLY) == DWORD ( FILE_ATTRIBUTE_READONLY) {
733+ if faAttributes. dwFileAttributes & FILE_ATTRIBUTE_READONLY == FILE_ATTRIBUTE_READONLY {
734734 return false
735735 }
736736
737737 do { faAttributes = try windowsFileAttributes ( atPath: path) } catch { return false }
738- if faAttributes. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_READONLY) == DWORD ( FILE_ATTRIBUTE_READONLY) {
738+ if faAttributes. dwFileAttributes & FILE_ATTRIBUTE_READONLY == FILE_ATTRIBUTE_READONLY {
739739 return false
740740 }
741741
@@ -785,15 +785,15 @@ extension FileManager {
785785 statInfo. st_ino = 0
786786 statInfo. st_rdev = _dev_t ( info. dwVolumeSerialNumber)
787787
788- let isReparsePoint = info. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_REPARSE_POINT) != 0
789- let isDir = info. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_DIRECTORY) != 0
788+ let isReparsePoint = info. dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT != 0
789+ let isDir = info. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY != 0
790790 let fileMode = isDir ? _S_IFDIR : _S_IFREG
791791 // On a symlink to a directory, Windows sets both the REPARSE_POINT and
792792 // DIRECTORY attributes. Since Windows doesn't provide S_IFLNK and we
793793 // want unix style "symlinks to directories are not directories
794794 // themselves, we say symlinks are regular files
795795 statInfo. st_mode = UInt16 ( isReparsePoint ? _S_IFREG : fileMode)
796- let isReadOnly = info. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_READONLY) != 0
796+ let isReadOnly = info. dwFileAttributes & FILE_ATTRIBUTE_READONLY != 0
797797 statInfo. st_mode |= UInt16 ( isReadOnly ? _S_IREAD : ( _S_IREAD | _S_IWRITE) )
798798 statInfo. st_mode |= UInt16 ( _S_IEXEC)
799799
@@ -860,21 +860,21 @@ extension FileManager {
860860
861861 let path1Attrs = path1FileInfo. dwFileAttributes
862862 let path2Attrs = path2FileInfo. dwFileAttributes
863- if path1Attrs & DWORD ( FILE_ATTRIBUTE_REPARSE_POINT) == FILE_ATTRIBUTE_REPARSE_POINT
864- || path2Attrs & DWORD ( FILE_ATTRIBUTE_REPARSE_POINT) == FILE_ATTRIBUTE_REPARSE_POINT {
865- guard path1Attrs & DWORD ( FILE_ATTRIBUTE_REPARSE_POINT) == FILE_ATTRIBUTE_REPARSE_POINT
866- && path2Attrs & DWORD ( FILE_ATTRIBUTE_REPARSE_POINT) == FILE_ATTRIBUTE_REPARSE_POINT else {
863+ if path1Attrs & FILE_ATTRIBUTE_REPARSE_POINT == FILE_ATTRIBUTE_REPARSE_POINT
864+ || path2Attrs & FILE_ATTRIBUTE_REPARSE_POINT == FILE_ATTRIBUTE_REPARSE_POINT {
865+ guard path1Attrs & FILE_ATTRIBUTE_REPARSE_POINT == FILE_ATTRIBUTE_REPARSE_POINT
866+ && path2Attrs & FILE_ATTRIBUTE_REPARSE_POINT == FILE_ATTRIBUTE_REPARSE_POINT else {
867867 return false
868868 }
869869 guard let pathDest1 = try ? _destinationOfSymbolicLink ( atPath: path1) ,
870870 let pathDest2 = try ? _destinationOfSymbolicLink ( atPath: path2) else {
871871 return false
872872 }
873873 return pathDest1 == pathDest2
874- } else if DWORD ( FILE_ATTRIBUTE_DIRECTORY) & path1Attrs == DWORD ( FILE_ATTRIBUTE_DIRECTORY)
875- || DWORD ( FILE_ATTRIBUTE_DIRECTORY) & path2Attrs == DWORD ( FILE_ATTRIBUTE_DIRECTORY) {
876- guard DWORD ( FILE_ATTRIBUTE_DIRECTORY) & path1Attrs == DWORD ( FILE_ATTRIBUTE_DIRECTORY)
877- && DWORD ( FILE_ATTRIBUTE_DIRECTORY) & path2Attrs == FILE_ATTRIBUTE_DIRECTORY else {
874+ } else if FILE_ATTRIBUTE_DIRECTORY & path1Attrs == FILE_ATTRIBUTE_DIRECTORY
875+ || FILE_ATTRIBUTE_DIRECTORY & path2Attrs == FILE_ATTRIBUTE_DIRECTORY {
876+ guard FILE_ATTRIBUTE_DIRECTORY & path1Attrs == FILE_ATTRIBUTE_DIRECTORY
877+ && FILE_ATTRIBUTE_DIRECTORY & path2Attrs == FILE_ATTRIBUTE_DIRECTORY else {
878878 return false
879879 }
880880 return _compareDirectories ( atPath: path1, andPath: path2)
@@ -966,8 +966,8 @@ extension FileManager {
966966 return firstValidItem ( )
967967 }
968968
969- let isDir = attrs. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_DIRECTORY) == DWORD ( FILE_ATTRIBUTE_DIRECTORY) &&
970- attrs. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_REPARSE_POINT) == 0
969+ let isDir = attrs. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY == FILE_ATTRIBUTE_DIRECTORY &&
970+ attrs. dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT == 0
971971 if isDir && ( level == 0 || !_options. contains ( . skipsSubdirectoryDescendants) ) {
972972 var ffd = WIN32_FIND_DATAW ( )
973973 let capacity = MemoryLayout . size ( ofValue: ffd. cFileName)
@@ -986,7 +986,7 @@ extension FileManager {
986986 }
987987 if file == " . " || file == " .. " { continue }
988988 if _options. contains ( . skipsHiddenFiles) &&
989- ffd. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_HIDDEN) == DWORD ( FILE_ATTRIBUTE_HIDDEN) {
989+ ffd. dwFileAttributes & FILE_ATTRIBUTE_HIDDEN == FILE_ATTRIBUTE_HIDDEN {
990990 continue
991991 }
992992 _stack. append ( URL ( fileURLWithPath: file, relativeTo: _lastReturned) )
0 commit comments