Add a binding to ftell()
This commit is contained in:
parent
ea1321fcdd
commit
71de17d38e
@ -24,6 +24,7 @@ type reader =
|
||||
impure fn read_le_int(uint size) -> int;
|
||||
|
||||
impure fn seek(int offset, seek_style whence);
|
||||
impure fn tell() -> uint; // TODO: eventually u64
|
||||
};
|
||||
|
||||
state obj FILE_reader(os.libc.FILE f, bool must_close) {
|
||||
@ -97,6 +98,9 @@ state obj FILE_reader(os.libc.FILE f, bool must_close) {
|
||||
}
|
||||
check(os.libc.fseek(f, offset, wh) == 0);
|
||||
}
|
||||
impure fn tell() -> uint {
|
||||
ret os.libc.ftell(f) as uint;
|
||||
}
|
||||
drop {
|
||||
if (must_close) {os.libc.fclose(f);}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ native mod libc = "libc.so.6" {
|
||||
fn ungetc(int c, FILE f);
|
||||
fn fread(vbuf buf, uint size, uint n, FILE f) -> uint;
|
||||
fn fseek(FILE f, int offset, int whence) -> int;
|
||||
fn ftell(FILE f) -> int;
|
||||
|
||||
type dir;
|
||||
fn opendir(sbuf d) -> dir;
|
||||
|
@ -16,6 +16,7 @@ native mod libc = "libc.dylib" {
|
||||
fn ungetc(int c, FILE f);
|
||||
fn fread(vbuf buf, uint size, uint n, FILE f) -> uint;
|
||||
fn fseek(FILE f, int offset, int whence) -> int;
|
||||
fn ftell(FILE f) -> int;
|
||||
|
||||
type dir;
|
||||
fn opendir(sbuf d) -> dir;
|
||||
|
@ -15,6 +15,7 @@ native mod libc = "msvcrt.dll" {
|
||||
fn ungetc(int c, FILE f);
|
||||
fn fread(vbuf buf, uint size, uint n, FILE f) -> uint;
|
||||
fn fseek(FILE f, int offset, int whence) -> int;
|
||||
fn ftell(FILE f) -> int;
|
||||
|
||||
fn _pipe(vbuf fds, uint size, int mode) -> int;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user