Skip to content

Commit 7ac80cc

Browse files
committed
Fix a build failure on Windows, where NAME_MAX doesn't exist.
1 parent bccbd93 commit 7ac80cc

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Sources/TSCBasic/Lock.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ public final class FileLock {
182182
if lockFileName.hasPrefix(AbsolutePath.root.pathString) {
183183
lockFileName = String(lockFileName.dropFirst(AbsolutePath.root.pathString.count))
184184
}
185+
#if !os(Windows)
185186
// back off until it occupies at most `NAME_MAX` UTF-8 bytes but without splitting scalars
186187
// (we might split clusters but it's not worth the effort to keep them together as long as we get a valid file name)
187188
var lockFileUTF8 = lockFileName.utf8.suffix(Int(NAME_MAX))
@@ -191,6 +192,7 @@ public final class FileLock {
191192
}
192193
// we will never end up with nil since we have ASCII characters at the end
193194
lockFileName = String(lockFileUTF8) ?? lockFileName
195+
#endif
194196
let lockFilePath = lockFilesDirectory.appending(component: lockFileName)
195197

196198
let lock = FileLock(at: lockFilePath)

0 commit comments

Comments
 (0)