@@ -228,8 +228,8 @@ extension FileManager {
228
228
229
229
try _contentsOfDir ( atPath: path, { ( entryName, entryType) throws in
230
230
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 {
233
233
let subPath : String = joinPath ( prefix: path, suffix: entryName)
234
234
let entries = try subpathsOfDirectory ( atPath: subPath)
235
235
contents. append ( contentsOf: entries. map { joinPath ( prefix: entryName, suffix: $0) . standardizingPath } )
@@ -313,7 +313,7 @@ extension FileManager {
313
313
guard let faAttributes = try ? windowsFileAttributes ( atPath: resolvedDest) else {
314
314
throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: true , paths: [ path, destPath] )
315
315
}
316
- if faAttributes. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_DIRECTORY) == DWORD ( FILE_ATTRIBUTE_DIRECTORY) {
316
+ if faAttributes. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY == FILE_ATTRIBUTE_DIRECTORY {
317
317
dwFlags |= DWORD ( SYMBOLIC_LINK_FLAG_DIRECTORY)
318
318
}
319
319
}
@@ -327,7 +327,7 @@ extension FileManager {
327
327
328
328
internal func _destinationOfSymbolicLink( atPath path: String ) throws -> String {
329
329
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 {
331
331
throw _NSErrorWithWindowsError ( DWORD ( ERROR_BAD_ARGUMENTS) , reading: false )
332
332
}
333
333
@@ -484,12 +484,12 @@ extension FileManager {
484
484
485
485
internal func _copySymlink( atPath srcPath: String , toPath dstPath: String , variant: String = " Copy " ) throws {
486
486
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 {
488
488
throw _NSErrorWithErrno ( EINVAL, reading: true , path: srcPath, extraUserInfo: extraErrorInfo ( srcPath: srcPath, dstPath: dstPath, userVariant: variant) )
489
489
}
490
490
491
491
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
493
493
if fileExists ( atPath: dstPath) {
494
494
try removeItem ( atPath: dstPath)
495
495
}
@@ -585,15 +585,15 @@ extension FileManager {
585
585
}
586
586
}
587
587
588
- if faAttributes. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY {
588
+ if faAttributes. dwFileAttributes & FILE_ATTRIBUTE_READONLY == FILE_ATTRIBUTE_READONLY {
589
589
if try ! FileManager. default. _fileSystemRepresentation ( withPath: path, {
590
- SetFileAttributesW ( $0, faAttributes. dwFileAttributes & ~ DWORD ( FILE_ATTRIBUTE_READONLY) )
590
+ SetFileAttributesW ( $0, faAttributes. dwFileAttributes & ~ FILE_ATTRIBUTE_READONLY)
591
591
} ) {
592
592
throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: false , paths: [ path] )
593
593
}
594
594
}
595
595
596
- if faAttributes. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_DIRECTORY) == 0 {
596
+ if faAttributes. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY == 0 {
597
597
if try ! FileManager. default. _fileSystemRepresentation ( withPath: path, DeleteFileW) {
598
598
throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: false , paths: [ path] )
599
599
}
@@ -635,15 +635,15 @@ extension FileManager {
635
635
}
636
636
637
637
itemPath = " \( currentDir) \\ \( file) "
638
- if ffd. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY {
638
+ if ffd. dwFileAttributes & FILE_ATTRIBUTE_READONLY == FILE_ATTRIBUTE_READONLY {
639
639
if try ! FileManager. default. _fileSystemRepresentation ( withPath: itemPath, {
640
- SetFileAttributesW ( $0, ffd. dwFileAttributes & ~ DWORD ( FILE_ATTRIBUTE_READONLY) )
640
+ SetFileAttributesW ( $0, ffd. dwFileAttributes & ~ FILE_ATTRIBUTE_READONLY)
641
641
} ) {
642
642
throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: false , paths: [ file] )
643
643
}
644
644
}
645
645
646
- if ( ffd. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_DIRECTORY) != 0 ) {
646
+ if ( ffd. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY != 0 ) {
647
647
if file != " . " && file != " .. " {
648
648
dirStack. append ( itemPath)
649
649
}
@@ -682,7 +682,7 @@ extension FileManager {
682
682
internal func _fileExists( atPath path: String , isDirectory: UnsafeMutablePointer < ObjCBool > ? ) -> Bool {
683
683
var faAttributes : WIN32_FILE_ATTRIBUTE_DATA = WIN32_FILE_ATTRIBUTE_DATA ( )
684
684
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 {
686
686
let handle : HANDLE = ( try ? FileManager . default. _fileSystemRepresentation ( withPath: path) {
687
687
CreateFileW ( $0, /* dwDesiredAccess= */ DWORD ( 0 ) ,
688
688
DWORD ( FILE_SHARE_READ) , /* lpSecurityAttributes= */ nil ,
@@ -695,11 +695,11 @@ extension FileManager {
695
695
if let isDirectory = isDirectory {
696
696
var info : BY_HANDLE_FILE_INFORMATION = BY_HANDLE_FILE_INFORMATION ( )
697
697
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)
699
699
}
700
700
} else {
701
701
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)
703
703
}
704
704
}
705
705
return true
@@ -713,7 +713,7 @@ extension FileManager {
713
713
714
714
internal func _isWritableFile( atPath path: String ) -> Bool {
715
715
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
717
717
}
718
718
719
719
internal func _isExecutableFile( atPath path: String ) -> Bool {
@@ -730,12 +730,12 @@ extension FileManager {
730
730
let parent = path. _nsObject. deletingLastPathComponent
731
731
var faAttributes : WIN32_FILE_ATTRIBUTE_DATA = WIN32_FILE_ATTRIBUTE_DATA ( )
732
732
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 {
734
734
return false
735
735
}
736
736
737
737
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 {
739
739
return false
740
740
}
741
741
@@ -785,15 +785,15 @@ extension FileManager {
785
785
statInfo. st_ino = 0
786
786
statInfo. st_rdev = _dev_t ( info. dwVolumeSerialNumber)
787
787
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
790
790
let fileMode = isDir ? _S_IFDIR : _S_IFREG
791
791
// On a symlink to a directory, Windows sets both the REPARSE_POINT and
792
792
// DIRECTORY attributes. Since Windows doesn't provide S_IFLNK and we
793
793
// want unix style "symlinks to directories are not directories
794
794
// themselves, we say symlinks are regular files
795
795
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
797
797
statInfo. st_mode |= UInt16 ( isReadOnly ? _S_IREAD : ( _S_IREAD | _S_IWRITE) )
798
798
statInfo. st_mode |= UInt16 ( _S_IEXEC)
799
799
@@ -860,21 +860,21 @@ extension FileManager {
860
860
861
861
let path1Attrs = path1FileInfo. dwFileAttributes
862
862
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 {
867
867
return false
868
868
}
869
869
guard let pathDest1 = try ? _destinationOfSymbolicLink ( atPath: path1) ,
870
870
let pathDest2 = try ? _destinationOfSymbolicLink ( atPath: path2) else {
871
871
return false
872
872
}
873
873
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 {
878
878
return false
879
879
}
880
880
return _compareDirectories ( atPath: path1, andPath: path2)
@@ -966,8 +966,8 @@ extension FileManager {
966
966
return firstValidItem ( )
967
967
}
968
968
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
971
971
if isDir && ( level == 0 || !_options. contains ( . skipsSubdirectoryDescendants) ) {
972
972
var ffd = WIN32_FIND_DATAW ( )
973
973
let capacity = MemoryLayout . size ( ofValue: ffd. cFileName)
@@ -986,7 +986,7 @@ extension FileManager {
986
986
}
987
987
if file == " . " || file == " .. " { continue }
988
988
if _options. contains ( . skipsHiddenFiles) &&
989
- ffd. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_HIDDEN) == DWORD ( FILE_ATTRIBUTE_HIDDEN) {
989
+ ffd. dwFileAttributes & FILE_ATTRIBUTE_HIDDEN == FILE_ATTRIBUTE_HIDDEN {
990
990
continue
991
991
}
992
992
_stack. append ( URL ( fileURLWithPath: file, relativeTo: _lastReturned) )
0 commit comments