added fseek2/ftell2 (large file support)
@@ -152,6 +152,24 @@ HL_PRIM int hl_file_tell( hl_fdesc *f ) {
return ftell(f->f);
}
+HL_PRIM bool hl_file_seek2( hl_fdesc *f, double pos, int kind ) {
+ if( !f ) return false;
+# ifdef HL_WIN
+ return _fseeki64(f->f,(__int64)pos,kind) == 0;
+# else
+ return fseeko64(f->f,(int64)pos,kind) == 0;
+# endif
+}
+
+HL_PRIM double hl_file_tell2( hl_fdesc *f ) {
+ if( !f ) return -1;
+# ifdef HL_WIN
+ return (double)_ftelli64(f->f);
+# else
+ return (double)ftello64(f->f);
+# endif
+}
+
HL_PRIM bool hl_file_eof( hl_fdesc *f ) {
if( !f ) return true;
return (bool)feof(f->f);
@@ -224,6 +242,8 @@ DEFINE_PRIM(_BOOL, file_write_char, _FILE _I32);
DEFINE_PRIM(_I32, file_read_char, _FILE);
DEFINE_PRIM(_BOOL, file_seek, _FILE _I32 _I32);
DEFINE_PRIM(_I32, file_tell, _FILE);
+DEFINE_PRIM(_BOOL, file_seek2, _FILE _F64 _I32);
+DEFINE_PRIM(_F64, file_tell2, _FILE);
DEFINE_PRIM(_BOOL, file_eof, _FILE);
DEFINE_PRIM(_BOOL, file_flush, _FILE);
DEFINE_PRIM(_FILE, file_stdin, _NO_ARG);
