1997-09-03 07:38:02 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Objective Caml */
|
|
|
|
/* */
|
|
|
|
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
|
|
/* */
|
|
|
|
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
1999-11-17 10:59:06 -08:00
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
2001-12-07 05:41:02 -08:00
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../../LICENSE. */
|
1997-09-03 07:38:02 -07:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
#include <mlvalues.h>
|
|
|
|
#include "unixsupport.h"
|
|
|
|
|
|
|
|
#ifdef HAS_UNISTD
|
|
|
|
#include <unistd.h>
|
|
|
|
#else
|
|
|
|
#define SEEK_SET 0
|
|
|
|
#define SEEK_CUR 1
|
|
|
|
#define SEEK_END 2
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int seek_command_table[] = {
|
|
|
|
FILE_BEGIN, FILE_CURRENT, FILE_END
|
|
|
|
};
|
|
|
|
|
2001-08-28 07:47:48 -07:00
|
|
|
CAMLprim value unix_lseek(value fd, value ofs, value cmd)
|
1997-09-03 07:38:02 -07:00
|
|
|
{
|
|
|
|
long ret;
|
|
|
|
ret = SetFilePointer(Handle_val(fd), Long_val(ofs), NULL,
|
|
|
|
seek_command_table[Int_val(cmd)]);
|
|
|
|
if (ret == -1) {
|
2001-08-28 07:47:48 -07:00
|
|
|
win32_maperr(GetLastError());
|
1997-09-03 07:38:02 -07:00
|
|
|
uerror("lseek", Nothing);
|
|
|
|
}
|
|
|
|
return Val_long(ret);
|
|
|
|
}
|