@@ -647,22 +647,21 @@ extension FileManager {
647
647
648
648
@discardableResult
649
649
internal func _changeCurrentDirectoryPath( _ path: String ) -> Bool {
650
- guard let bResult = try ? FileManager . default. _fileSystemRepresentation ( withPath: path, {
650
+ return ( try ? FileManager . default. _fileSystemRepresentation ( withPath: path) {
651
651
SetCurrentDirectoryW ( $0)
652
- } ) else { return false }
653
- return bResult
652
+ } ) ?? false
654
653
}
655
654
656
655
internal func _fileExists( atPath path: String , isDirectory: UnsafeMutablePointer < ObjCBool > ? ) -> Bool {
657
656
var faAttributes : WIN32_FILE_ATTRIBUTE_DATA = WIN32_FILE_ATTRIBUTE_DATA ( )
658
657
do { faAttributes = try windowsFileAttributes ( atPath: path) } catch { return false }
659
658
if faAttributes. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_REPARSE_POINT) == DWORD ( FILE_ATTRIBUTE_REPARSE_POINT) {
660
- guard let handle: HANDLE = try ? FileManager . default. _fileSystemRepresentation ( withPath: path, {
659
+ let handle : HANDLE = ( try ? FileManager . default. _fileSystemRepresentation ( withPath: path) {
661
660
CreateFileW ( $0, /* dwDesiredAccess= */ DWORD ( 0 ) ,
662
661
DWORD ( FILE_SHARE_READ) , /* lpSecurityAttributes= */ nil ,
663
662
DWORD ( OPEN_EXISTING) ,
664
663
DWORD ( FILE_FLAG_BACKUP_SEMANTICS) , /* hTemplateFile= */ nil )
665
- } ) else { return false }
664
+ } ) ?? INVALID_HANDLE_VALUE
666
665
if handle == INVALID_HANDLE_VALUE { return false }
667
666
defer { CloseHandle ( handle) }
668
667
@@ -775,23 +774,23 @@ extension FileManager {
775
774
}
776
775
777
776
internal func _contentsEqual( atPath path1: String , andPath path2: String ) -> Bool {
778
- guard let path1Handle: HANDLE = try ? FileManager . default. _fileSystemRepresentation ( withPath: path1, {
777
+ let path1Handle : HANDLE = ( try ? FileManager . default. _fileSystemRepresentation ( withPath: path1) {
779
778
CreateFileW ( $0, GENERIC_READ,
780
779
DWORD ( FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE) ,
781
780
nil , DWORD ( OPEN_EXISTING) ,
782
781
DWORD ( FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS) ,
783
782
nil )
784
- } ) else { return false }
783
+ } ) ?? INVALID_HANDLE_VALUE
785
784
if path1Handle == INVALID_HANDLE_VALUE { return false }
786
785
defer { CloseHandle ( path1Handle) }
787
786
788
- guard let path2Handle: HANDLE = try ? FileManager . default. _fileSystemRepresentation ( withPath: path2, {
787
+ let path2Handle : HANDLE = ( try ? FileManager . default. _fileSystemRepresentation ( withPath: path2) {
789
788
CreateFileW ( $0, GENERIC_READ,
790
789
DWORD ( FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE) ,
791
790
nil , DWORD ( OPEN_EXISTING) ,
792
791
DWORD ( FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS) ,
793
792
nil )
794
- } ) else { return false }
793
+ } ) ?? INVALID_HANDLE_VALUE
795
794
if path2Handle == INVALID_HANDLE_VALUE { return false }
796
795
defer { CloseHandle ( path2Handle) }
797
796
@@ -937,9 +936,9 @@ extension FileManager {
937
936
var ffd = WIN32_FIND_DATAW ( )
938
937
let capacity = MemoryLayout . size ( ofValue: ffd. cFileName)
939
938
940
- guard let handle = try ? FileManager . default. _fileSystemRepresentation ( withPath: joinPath ( prefix: _lastReturned. path, suffix: " * " ) , {
939
+ let handle = ( try ? FileManager . default. _fileSystemRepresentation ( withPath: joinPath ( prefix: _lastReturned. path, suffix: " * " ) ) {
941
940
FindFirstFileW ( $0, & ffd)
942
- } ) else { return firstValidItem ( ) }
941
+ } ) ?? INVALID_HANDLE_VALUE
943
942
if handle == INVALID_HANDLE_VALUE { return firstValidItem ( ) }
944
943
defer { FindClose ( handle) }
945
944
0 commit comments