From: SourceForge.net <no...@so...> - 2005-05-31 06:13:40
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=3176949 By: shadowmas i'm trying to port a linux application to windows which require pread and pwrite functions. as far as i can see there not defined in the MinGW include files. i tried googling but didnt find anything that was of any help. any tips as to where i can find them or an alternative. thanks ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=290275 |
From: Erik de C. L. <mi...@me...> - 2005-05-31 07:33:41
|
SourceForge.net wrote: > > Read and respond to this message at: > https://sourceforge.net/forum/message.php?msg_id=3176949 > By: shadowmas > > i'm trying to port a linux application to windows which require pread and pwrite > functions. as far as i can see there not defined in the MinGW include files. They aren't in the MinGW include files because win32 doesn't have these functions. > i tried googling but didnt find anything that was of any help. They are part of the Unix98 standard. > any tips as to where i can find them or an alternative. Pread can be implemented as (untested): ssize_t pread(int fd, void *buf, size_t count, off_t offset) { ssize_t retval ; off_t saved_pos = lseek (fd, 0, SEEK_CUR); lseek (fd, offset, SEEK_SET); retval = read (fd, buf, count); lseek (fd, saved_pos, SEEK_SET); return retval; } replacing the lseek/read etc with Win32 ReadFile / SetFilePointer etc. You should probably also add a bunch of error checking and handling. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo no...@me... (Yes it's valid) +-----------------------------------------------------------+ "It has been discovered that C++ provides a remarkable facility for concealing the trival details of a program -- such as where its bugs are." -- David Keppel |