@@ -37,9 +37,9 @@ enum ProcessLockError: Swift.Error {
3737public final class FileLock {
3838 /// File descriptor to the lock file.
3939 #if os(Windows)
40- private var h : HANDLE ?
40+ private var handle : HANDLE ?
4141 #else
42- private var fd : CInt ?
42+ private var fileDescriptor : CInt ?
4343 #endif
4444
4545 /// Path to the lock file.
@@ -58,7 +58,7 @@ public final class FileLock {
5858 /// Note: This method can throw if underlying POSIX methods fail.
5959 public func lock( ) throws {
6060 #if os(Windows)
61- if h == nil {
61+ if handle == nil {
6262 let h = lockFile. pathString. withCString ( encodedAs: UTF16 . self, {
6363 CreateFileW (
6464 $0,
@@ -69,11 +69,11 @@ public final class FileLock {
6969 DWORD ( FILE_ATTRIBUTE_NORMAL) ,
7070 nil
7171 )
72- } )
73- if h == INVALID_HANDLE_VALUE {
74- throw FileSystemError ( errno: Int32 ( GetLastError ( ) ) )
75- }
76- self . h = h
72+ } )
73+ if h == INVALID_HANDLE_VALUE {
74+ throw FileSystemError ( errno: Int32 ( GetLastError ( ) ) )
75+ }
76+ self . handle = h
7777 }
7878 var overlapped = OVERLAPPED ( )
7979 overlapped. Offset = 0
@@ -84,16 +84,16 @@ public final class FileLock {
8484 }
8585 #else
8686 // Open the lock file.
87- if fd == nil {
87+ if fileDescriptor == nil {
8888 let fd = SPMLibc . open ( lockFile. pathString, O_WRONLY | O_CREAT | O_CLOEXEC, 0o666 )
8989 if fd == - 1 {
9090 throw FileSystemError ( errno: errno)
9191 }
92- self . fd = fd
92+ self . fileDescriptor = fd
9393 }
9494 // Aquire lock on the file.
9595 while true {
96- if flock ( fd !, LOCK_EX) == 0 {
96+ if flock ( fileDescriptor !, LOCK_EX) == 0 {
9797 break
9898 }
9999 // Retry if interrupted.
@@ -112,17 +112,17 @@ public final class FileLock {
112112 overlapped. hEvent = nil
113113 UnlockFileEx ( h, 0 , DWORD ( INT_MAX) , DWORD ( INT_MAX) , & overlapped)
114114 #else
115- guard let fd = fd else { return }
115+ guard let fd = fileDescriptor else { return }
116116 flock ( fd, LOCK_UN)
117117 #endif
118118 }
119119
120120 deinit {
121121 #if os(Windows)
122- guard let h = h else { return }
123- CloseHandle ( h )
122+ guard let handle = handle else { return }
123+ CloseHandle ( handle )
124124 #else
125- guard let fd = fd else { return }
125+ guard let fd = fileDescriptor else { return }
126126 close ( fd)
127127 #endif
128128 }
0 commit comments