diff --git a/src/fd_control.c b/src/fd_control.c index 030b8a84746a61d907ab62f1d4dd27fe9cfd3233..941d62f75175f4e8e7d64bb92f7dad538c9cdc74 100644 --- a/src/fd_control.c +++ b/src/fd_control.c @@ -3,6 +3,8 @@ ||| Pike is distributed as GPL (General Public License) ||| See the files COPYING and DISCLAIMER for more information. \*/ +#define _FILE_OFFSET_BITS 64 +#define _LARGEFILE_SOURCE #include <sys/types.h> #ifndef TESTING diff --git a/src/fdlib.c b/src/fdlib.c index fa676e0f10802017130233a02d0e003cb12430e4..ae68f31eed2e40894e0cb4ad344749b5b59513a6 100644 --- a/src/fdlib.c +++ b/src/fdlib.c @@ -1,7 +1,12 @@ +/* For Solaris 2.6 */ +#define _FILE_OFFSET_BITS 64 +#define _LARGEFILE_SOURCE + #include "fdlib.h" #include "error.h" #include <math.h> + #ifdef HAVE_WINSOCK_H #ifdef _REENTRANT diff --git a/src/modules/files/configure.in b/src/modules/files/configure.in index fc773c474bc5a41af2edd2b3d446ce4cc7c85aee..fd9c36ff1de84914d7a869039833d7271c0940a7 100644 --- a/src/modules/files/configure.in +++ b/src/modules/files/configure.in @@ -11,7 +11,7 @@ AC_HEADER_DIRENT AC_CHECK_LIB(bind, __inet_ntoa) AC_CHECK_LIB(socket, socket) -AC_HAVE_FUNCS(getwd perror readdir_r statvfs statfs ustat lstat socketpair) +AC_HAVE_FUNCS(getwd perror readdir_r statvfs statfs ustat lseek64 lstat socketpair) AC_MSG_CHECKING(if mkdir takes 1 or 2 arguments) AC_CACHE_VAL(pike_cv_func_mkdir_args,[ diff --git a/src/modules/files/file.c b/src/modules/files/file.c index 73f362397176e7f0a8ae2650b1adf8ffd096a3da..038fc948c2b215151cda91f19296e91df4c2a00d 100644 --- a/src/modules/files/file.c +++ b/src/modules/files/file.c @@ -1,12 +1,14 @@ -/*\ +/* \ ||| This file a part of Pike, and is copyright by Fredrik Hubinette ||| Pike is distributed as GPL (General Public License) ||| See the files COPYING and DISCLAIMER for more information. -\*/ +\ */ +#define _FILE_OFFSET_BITS 64 +#define _LARGEFILE_SOURCE #define READ_BUFFER 8192 #include "global.h" -RCSID("$Id: file.c,v 1.79 1998/03/22 03:25:25 hubbe Exp $"); +RCSID("$Id: file.c,v 1.80 1998/03/22 04:37:19 per Exp $"); #include "fdlib.h" #include "interpret.h" #include "svalue.h" @@ -657,24 +659,42 @@ static void file_open(INT32 args) static void file_seek(INT32 args) { +#ifdef HAVE_LSEEK64 + long long to; +#else INT32 to; - +#endif if(args<1 || sp[-args].type != T_INT) - error("Bad argument 1 to file->seek().\n"); + error("Bad argument 1 to file->seek(int to).\n"); if(FD < 0) error("File not open.\n"); - + to=sp[-args].u.integer; + if(args>1) + { + if(sp[-args+1].type != T_INT) + error("Bad argument 2 to file->seek(int unit,int mult).\n"); + to *= sp[-args+1].u.integer; + } + if(args>2) + { + if(sp[-args+2].type != T_INT) + error("Bad argument 3 to file->seek(int unit,int mult,int add).\n"); + to += sp[-args+2].u.integer; + } ERRNO=0; +#ifdef HAVE_LSEEK64 + to=lseek64(FD,to,to<0 ? SEEK_END : SEEK_SET); +#else to=fd_lseek(FD,to,to<0 ? SEEK_END : SEEK_SET); - +#endif if(to<0) ERRNO=errno; pop_n_elems(args); - push_int(to); + push_int((INT32)to); } static void file_tell(INT32 args) @@ -1935,7 +1955,7 @@ void pike_module_init(void) add_function("read",file_read,"function(int|void,int|void:int|string)",0); add_function("write",file_write,"function(string,void|mixed...:int)",0); - add_function("seek",file_seek,"function(int:int)",0); + add_function("seek",file_seek,"function(int,int|void,int|void:int)",0); add_function("tell",file_tell,"function(:int)",0); add_function("stat",file_stat,"function(:int *)",0); add_function("errno",file_errno,"function(:int)",0);