@@ -41,7 +41,7 @@ extension FileManager {
41
41
var wszPathNames : UnsafeMutableBufferPointer < WCHAR > = UnsafeMutableBufferPointer< WCHAR> . allocate( capacity: Int ( dwCChReturnLength + 1 ) )
42
42
defer { wszPathNames. deallocate ( ) }
43
43
44
- if GetVolumePathNamesForVolumeNameW ( wszVolumeName. baseAddress, wszPathNames. baseAddress, DWORD ( wszPathNames. count) , & dwCChReturnLength) == FALSE {
44
+ if ! GetVolumePathNamesForVolumeNameW( wszVolumeName. baseAddress, wszPathNames. baseAddress, DWORD ( wszPathNames. count) , & dwCChReturnLength) {
45
45
// TODO(compnerd) handle error
46
46
continue
47
47
}
@@ -55,7 +55,7 @@ extension FileManager {
55
55
urls. append ( URL ( fileURLWithPath: path, isDirectory: true ) )
56
56
pPath += DWORD ( path. length + 1 )
57
57
} while pPath < dwCChReturnLength
58
- } while FindNextVolumeW ( hVolumes, wszVolumeName. baseAddress, DWORD ( wszVolumeName. count) ) != FALSE
58
+ } while FindNextVolumeW ( hVolumes, wszVolumeName. baseAddress, DWORD ( wszVolumeName. count) )
59
59
return urls
60
60
}
61
61
internal func _urls( for directory: SearchPathDirectory , in domainMask: SearchPathDomainMask ) -> [ URL ] {
@@ -174,13 +174,13 @@ extension FileManager {
174
174
var saAttributes : SECURITY_ATTRIBUTES =
175
175
SECURITY_ATTRIBUTES ( nLength: DWORD ( MemoryLayout< SECURITY_ATTRIBUTES> . size) ,
176
176
lpSecurityDescriptor: nil ,
177
- bInheritHandle: FALSE )
177
+ bInheritHandle: false )
178
178
let psaAttributes : UnsafeMutablePointer < SECURITY_ATTRIBUTES > =
179
179
UnsafeMutablePointer < SECURITY_ATTRIBUTES > ( & saAttributes)
180
180
181
181
182
182
try path. withCString ( encodedAs: UTF16 . self) {
183
- if CreateDirectoryW ( $0, psaAttributes) == FALSE {
183
+ if ! CreateDirectoryW( $0, psaAttributes) {
184
184
// FIXME(compnerd) pass along path
185
185
throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: false )
186
186
}
@@ -208,7 +208,7 @@ extension FileManager {
208
208
}
209
209
210
210
try closure ( path, Int32 ( ffd. dwFileAttributes) )
211
- } while FindNextFileW ( hDirectory, & ffd) != FALSE
211
+ } while FindNextFileW ( hDirectory, & ffd)
212
212
}
213
213
}
214
214
@@ -229,7 +229,7 @@ extension FileManager {
229
229
internal func windowsFileAttributes( atPath path: String ) throws -> WIN32_FILE_ATTRIBUTE_DATA {
230
230
var faAttributes : WIN32_FILE_ATTRIBUTE_DATA = WIN32_FILE_ATTRIBUTE_DATA ( )
231
231
return try path. withCString ( encodedAs: UTF16 . self) {
232
- if GetFileAttributesExW ( $0, GetFileExInfoStandard, & faAttributes) == FALSE {
232
+ if ! GetFileAttributesExW( $0, GetFileExInfoStandard, & faAttributes) {
233
233
throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: true )
234
234
}
235
235
return faAttributes
@@ -244,14 +244,14 @@ extension FileManager {
244
244
let szVolumePath : UnsafeMutableBufferPointer < WCHAR > = UnsafeMutableBufferPointer< WCHAR> . allocate( capacity: Int ( dwLength + 1 ) )
245
245
defer { szVolumePath. deallocate ( ) }
246
246
247
- guard GetVolumePathNameW ( $0, szVolumePath. baseAddress, dwLength) != FALSE else {
247
+ guard GetVolumePathNameW ( $0, szVolumePath. baseAddress, dwLength) else {
248
248
throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: true )
249
249
}
250
250
251
251
var liTotal : ULARGE_INTEGER = ULARGE_INTEGER ( )
252
252
var liFree : ULARGE_INTEGER = ULARGE_INTEGER ( )
253
253
254
- guard GetDiskFreeSpaceExW ( szVolumePath. baseAddress, nil , & liTotal, & liFree) != FALSE else {
254
+ guard GetDiskFreeSpaceExW ( szVolumePath. baseAddress, nil , & liTotal, & liFree) else {
255
255
throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: true )
256
256
}
257
257
@@ -271,7 +271,7 @@ extension FileManager {
271
271
272
272
try path. withCString ( encodedAs: UTF16 . self) { name in
273
273
try destPath. withCString ( encodedAs: UTF16 . self) { dest in
274
- guard CreateSymbolicLinkW ( name, dest, dwFlags) != FALSE else {
274
+ guard CreateSymbolicLinkW ( name, dest, dwFlags) != 0 else {
275
275
throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: false )
276
276
}
277
277
}
@@ -303,7 +303,7 @@ extension FileManager {
303
303
internal func _copyRegularFile( atPath srcPath: String , toPath dstPath: String , variant: String = " Copy " ) throws {
304
304
try srcPath. withCString ( encodedAs: UTF16 . self) { src in
305
305
try dstPath. withCString ( encodedAs: UTF16 . self) { dst in
306
- if CopyFileW ( src, dst, FALSE ) == FALSE {
306
+ if ! CopyFileW( src, dst, false ) {
307
307
throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: false )
308
308
}
309
309
}
@@ -365,7 +365,7 @@ extension FileManager {
365
365
366
366
try srcPath. withCString ( encodedAs: UTF16 . self) { src in
367
367
try dstPath. withCString ( encodedAs: UTF16 . self) { dst in
368
- if MoveFileExW ( src, dst, DWORD ( MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH) ) == FALSE {
368
+ if ! MoveFileExW( src, dst, DWORD ( MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH) ) {
369
369
throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: false )
370
370
}
371
371
}
@@ -383,7 +383,7 @@ extension FileManager {
383
383
case . typeRegular:
384
384
try srcPath. withCString ( encodedAs: UTF16 . self) { src in
385
385
try dstPath. withCString ( encodedAs: UTF16 . self) { dst in
386
- if CreateHardLinkW ( src, dst, nil ) == FALSE {
386
+ if ! CreateHardLinkW( src, dst, nil ) {
387
387
throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: false )
388
388
}
389
389
}
@@ -408,7 +408,7 @@ extension FileManager {
408
408
}
409
409
let faAttributes = try ! windowsFileAttributes ( atPath: path)
410
410
if faAttributes. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_DIRECTORY) == 0 {
411
- if path. withCString ( encodedAs: UTF16 . self, DeleteFileW) == 0 {
411
+ if ! path. withCString ( encodedAs: UTF16 . self, DeleteFileW) {
412
412
throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: false )
413
413
}
414
414
return
@@ -421,7 +421,7 @@ extension FileManager {
421
421
guard alreadyConfirmed || shouldRemoveItemAtPath ( itemPath, isURL: isURL) else {
422
422
continue
423
423
}
424
- guard path. withCString ( encodedAs: UTF16 . self, RemoveDirectoryW) == 0 else {
424
+ guard ! path. withCString ( encodedAs: UTF16 . self, RemoveDirectoryW) else {
425
425
continue
426
426
}
427
427
guard GetLastError ( ) == ERROR_DIR_NOT_EMPTY else {
@@ -451,11 +451,11 @@ extension FileManager {
451
451
guard alreadyConfirmed || shouldRemoveItemAtPath ( itemPath, isURL: isURL) else {
452
452
continue
453
453
}
454
- if itemPath. withCString ( encodedAs: UTF16 . self, DeleteFileW) == 0 {
454
+ if ! itemPath. withCString ( encodedAs: UTF16 . self, DeleteFileW) {
455
455
throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: false )
456
456
}
457
457
}
458
- } while ( FindNextFileW ( h, & ffd) != 0 )
458
+ } while FindNextFileW ( h, & ffd)
459
459
} catch {
460
460
if !shouldProceedAfterError( error, removingItemAtPath: itemPath, isURL: isURL) {
461
461
throw error
@@ -475,7 +475,7 @@ extension FileManager {
475
475
476
476
@discardableResult
477
477
internal func _changeCurrentDirectoryPath( _ path: String ) -> Bool {
478
- return path. withCString ( encodedAs: UTF16 . self) { SetCurrentDirectoryW ( $0) != FALSE }
478
+ return path. withCString ( encodedAs: UTF16 . self) { SetCurrentDirectoryW ( $0) }
479
479
}
480
480
481
481
internal func _fileExists( atPath path: String , isDirectory: UnsafeMutablePointer < ObjCBool > ? ) -> Bool {
@@ -597,7 +597,7 @@ extension FileManager {
597
597
internal func _appendSymlinkDestination( _ dest: String , toPath: String ) -> String {
598
598
var isAbsolutePath : Bool = false
599
599
dest. withCString ( encodedAs: UTF16 . self) {
600
- isAbsolutePath = PathIsRelativeW ( $0) == FALSE
600
+ isAbsolutePath = ! PathIsRelativeW( $0)
601
601
}
602
602
603
603
if isAbsolutePath {
@@ -645,7 +645,7 @@ extension FileManager {
645
645
|| ( ffd. dwFileAttributes & DWORD ( FILE_ATTRIBUTE_HIDDEN) == 0 ) ) {
646
646
files. append ( URL ( fileURLWithPath: joinPath ( prefix: dirFSR, suffix: file) ) )
647
647
}
648
- } while ( FindNextFileW ( h, & ffd) != 0 )
648
+ } while FindNextFileW ( h, & ffd)
649
649
return files
650
650
}
651
651
while let url = _stack. popLast ( ) {
@@ -699,18 +699,16 @@ extension FileManager.NSPathDirectoryEnumerator {
699
699
( fsr. flatMap { String ( utf8String: $0) } ) ? . withCString ( encodedAs: UTF16 . self) { f ( $0) }
700
700
}
701
701
}
702
- let result = withURLCString ( url: baseURL) { pszFrom -> BOOL ? in
702
+ guard withURLCString ( url: baseURL, { pszFrom -> Bool ? in
703
703
withURLCString ( url: url) { pszTo in
704
704
let fromAttrs = GetFileAttributesW ( pszFrom)
705
705
let toAttrs = GetFileAttributesW ( pszTo)
706
706
guard fromAttrs != INVALID_FILE_ATTRIBUTES, toAttrs != INVALID_FILE_ATTRIBUTES else {
707
- return FALSE
707
+ return false
708
708
}
709
709
return PathRelativePathToW ( relativePath. baseAddress, pszFrom, fromAttrs, pszTo, toAttrs)
710
710
}
711
- }
712
-
713
- guard result == TRUE, let ( path, _) = String . decodeCString ( relativePath. baseAddress, as: UTF16 . self) else {
711
+ } ) == true , let ( path, _) = String . decodeCString ( relativePath. baseAddress, as: UTF16 . self) else {
714
712
return nil
715
713
}
716
714
_currentItemPath = path
0 commit comments