@@ -15,12 +15,6 @@ import Darwin
15
15
import Glibc
16
16
#endif
17
17
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
-
24
18
open class FileHandle : NSObject , NSSecureCoding {
25
19
internal var _fd : Int32
26
20
internal var _closeOnDealloc : Bool
@@ -77,7 +71,7 @@ open class FileHandle : NSObject, NSSecureCoding {
77
71
}
78
72
}
79
73
} else {
80
- let offset = lseek ( _fd, 0 , L_INCR )
74
+ let offset = lseek ( _fd, 0 , SEEK_CUR )
81
75
if offset < 0 {
82
76
fatalError ( " Unable to fetch current file offset " )
83
77
}
@@ -134,19 +128,19 @@ open class FileHandle : NSObject, NSSecureCoding {
134
128
// TODO: Error handling.
135
129
136
130
open var offsetInFile : UInt64 {
137
- return UInt64 ( lseek ( _fd, 0 , L_INCR ) )
131
+ return UInt64 ( lseek ( _fd, 0 , SEEK_CUR ) )
138
132
}
139
133
140
134
open func seekToEndOfFile( ) -> UInt64 {
141
- return UInt64 ( lseek ( _fd, 0 , L_XTND ) )
135
+ return UInt64 ( lseek ( _fd, 0 , SEEK_END ) )
142
136
}
143
137
144
138
open func seek( toFileOffset offset: UInt64 ) {
145
- lseek ( _fd, off_t ( offset) , L_SET )
139
+ lseek ( _fd, off_t ( offset) , SEEK_SET )
146
140
}
147
141
148
142
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 {
150
144
ftruncate ( _fd, off_t ( offset) )
151
145
}
152
146
}
0 commit comments