mirror of
https://github.com/vlang/v.git
synced 2025-08-04 02:07:28 -04:00
parent
9e10b2392d
commit
c72d77d8a4
@ -148,7 +148,7 @@ fn C.rename(old_filename &char, new_filename &char) int
|
||||
|
||||
fn C.fgets(str &char, n int, stream &C.FILE) int
|
||||
|
||||
fn C._telli64(handle int) isize
|
||||
fn C.fgetpos(&C.FILE, voidptr) int
|
||||
|
||||
@[trusted]
|
||||
fn C.sigemptyset() int
|
||||
|
@ -861,13 +861,15 @@ pub fn (f &File) tell() !i64 {
|
||||
if !f.is_opened {
|
||||
return error_file_not_opened()
|
||||
}
|
||||
mut pos := isize(0)
|
||||
|
||||
mut pos := i64(0)
|
||||
mut ret := 0
|
||||
$if windows {
|
||||
pos = C._telli64(f.fd)
|
||||
ret = C.fgetpos(f.cfile, &pos)
|
||||
} $else {
|
||||
pos = C.ftell(f.cfile)
|
||||
pos = i64(C.ftell(f.cfile))
|
||||
}
|
||||
if pos == -1 {
|
||||
if ret == -1 || pos == -1 {
|
||||
return error(posix_get_error_msg(C.errno))
|
||||
}
|
||||
return pos
|
||||
|
@ -357,6 +357,12 @@ fn test_tell() {
|
||||
mut f := os.open_file(tfile, 'r')!
|
||||
f.seek(-5, .end)!
|
||||
pos := f.tell()!
|
||||
f.seek(0, .start)!
|
||||
c1 := f.tell()!
|
||||
_ := f.read_bytes(8)
|
||||
c2 := f.tell()!
|
||||
assert c1 == 0
|
||||
assert c2 == 8
|
||||
f.close()
|
||||
// dump(pos)
|
||||
assert pos == size - 5
|
||||
|
Loading…
x
Reference in New Issue
Block a user