Skip to content

Commit 546cad2

Browse files
committed
move to SEEK_* macros
1 parent 9bc98b0 commit 546cad2

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

Foundation/NSFileHandle.swift

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ import Darwin
1515
import Glibc
1616
#endif
1717

18-
#if os(Android) // legacy constants
19-
let L_SET = SEEK_SET
20-
let L_INCR = SEEK_CUR
21-
let L_XTND = SEEK_END
22-
#endif
23-
2418
open class FileHandle : NSObject, NSSecureCoding {
2519
internal var _fd: Int32
2620
internal var _closeOnDealloc: Bool
@@ -77,7 +71,7 @@ open class FileHandle : NSObject, NSSecureCoding {
7771
}
7872
}
7973
} else {
80-
let offset = lseek(_fd, 0, L_INCR)
74+
let offset = lseek(_fd, 0, SEEK_CUR)
8175
if offset < 0 {
8276
fatalError("Unable to fetch current file offset")
8377
}
@@ -134,19 +128,19 @@ open class FileHandle : NSObject, NSSecureCoding {
134128
// TODO: Error handling.
135129

136130
open var offsetInFile: UInt64 {
137-
return UInt64(lseek(_fd, 0, L_INCR))
131+
return UInt64(lseek(_fd, 0, SEEK_CUR))
138132
}
139133

140134
open func seekToEndOfFile() -> UInt64 {
141-
return UInt64(lseek(_fd, 0, L_XTND))
135+
return UInt64(lseek(_fd, 0, SEEK_END))
142136
}
143137

144138
open func seek(toFileOffset offset: UInt64) {
145-
lseek(_fd, off_t(offset), L_SET)
139+
lseek(_fd, off_t(offset), SEEK_SET)
146140
}
147141

148142
open func truncateFile(atOffset offset: UInt64) {
149-
if lseek(_fd, off_t(offset), L_SET) == 0 {
143+
if lseek(_fd, off_t(offset), SEEK_SET) == 0 {
150144
ftruncate(_fd, off_t(offset))
151145
}
152146
}

0 commit comments

Comments
 (0)