Unix to Windows Porting Dictionary for HPC

Links

Function List

lseek


Unix

header file: unistd.h

off_t lseek(int fildes, off_t offset, int whence);

Windows

header file: io.h

long _lseek(int fd, long offset, int origin);

Purpose

This function allows the developer to change the file offset of filedes.

Discussion

This function has a one-to-one correspondence with the Windows function _lseek(), so porting should be a simple manner of including the appropriate header file and renaming the function call. Windows also provides the function _lseeki64(), which returns the offset in a 64-bit integer.

Example of Use in Windows

#include <io.h>

 /* Seek the beginning of the file: */
   pos = _lseek( fh, 0L, SEEK_SET );
   if ( pos == -1L )
      perror( "_lseek to beginning failed" );
   else
      printf( "Position for beginning of file seek = %ld\n", pos );
  
blog comments powered by Disqus