diff --git a/src/lib/io.rs b/src/lib/io.rs index 58cb1f8049515c642eaf7c22e90577eba5f77e84..165fe0302d6acd154d75eb89e66002084b5240a9 100644 --- a/src/lib/io.rs +++ b/src/lib/io.rs @@ -24,6 +24,7 @@ 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 @@ } 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);} } diff --git a/src/lib/linux_os.rs b/src/lib/linux_os.rs index 030dcdbc0e59dfbb4c6545c07e199d6069c2dc0f..bce859567e3856aa87f08e426aa97c31d9b7e869 100644 --- a/src/lib/linux_os.rs +++ b/src/lib/linux_os.rs @@ -19,6 +19,7 @@ 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; diff --git a/src/lib/macos_os.rs b/src/lib/macos_os.rs index c2a1bee3ed9ad6d25ae363a23a46e3f84f183859..f9734de3caa694d4dfe7d556bc6ac10bd99debad 100644 --- a/src/lib/macos_os.rs +++ b/src/lib/macos_os.rs @@ -16,6 +16,7 @@ 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; diff --git a/src/lib/win32_os.rs b/src/lib/win32_os.rs index 6885be243e44a3b5e45611f05bdc6ba59ebba3cf..3ca76e77d77e730c53a35d9f025f976875fc895d 100644 --- a/src/lib/win32_os.rs +++ b/src/lib/win32_os.rs @@ -15,6 +15,7 @@ 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; }