Skip to content

Commit 94fa6bd

Browse files
FileOperations: Add Windows implementation for FileDescriptor.resize(to:) (#89)
* FileOperations: Add Windows implementation for FileDescriptor.resize(to:) Replace _chsize with _chsize_s on Windows
1 parent a552fda commit 94fa6bd

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Sources/System/FileOperations.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ extension FileDescriptor {
401401
}
402402
#endif
403403

404-
#if !os(Windows)
405404
/*System 1.2.0, @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)*/
406405
extension FileDescriptor {
407406
/// Truncate or extend the file referenced by this file descriptor.
@@ -447,4 +446,3 @@ extension FileDescriptor {
447446
}
448447
}
449448
}
450-
#endif

Sources/System/Internals/WindowsSyscallAdapters.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,11 @@ internal func pwrite(
105105
return Int(nNumberOfBytesWritten)
106106
}
107107

108+
@inline(__always)
109+
internal func ftruncate(
110+
_ fd: Int32,
111+
_ length: off_t
112+
) -> Int32 {
113+
_chsize_s(fd, numericCast(length))
114+
}
108115
#endif

0 commit comments

Comments
 (0)