177eed0b0b757749adcc17bcc92eb767536e458e markd Fri Jan 10 10:13:42 2020 -0800 added mustSeek function diff --git src/inc/common.h src/inc/common.h index b891d98..ff03488 100644 --- src/inc/common.h +++ src/inc/common.h @@ -1143,30 +1143,33 @@ #define writeOne(file, var) mustWrite((file), &(var), sizeof(var)) /* Write out one variable to file. */ void mustRead(FILE *file, void *buf, size_t size); /* Read size bytes from a file or squawk and die. */ #define mustReadOne(file, var) mustRead((file), &(var), sizeof(var)) /* Read one variable from file or die. */ void mustGetLine(FILE *file, char *buf, int charCount); /* Read at most charCount-1 bytes from file, but stop after newline if one is * encountered. The string in buf is '\0'-terminated. (See man 3 fgets.) * Die if there is an error. */ +void mustSeek(FILE *file, off_t offset, int whence); +/* Seek to given offset, relative to whence (see man fseek) in file or errAbort. */ + int mustOpenFd(char *fileName, int flags); /* Open a file descriptor (see man 2 open) or squawk and die. */ void mustReadFd(int fd, void *buf, size_t size); /* Read size bytes from a file descriptor or squawk and die. */ void mustWriteFd(int fd, void *buf, size_t size); /* Write size bytes to file descriptor fd or die. (See man 2 write.) */ off_t mustLseek(int fd, off_t offset, int whence); /* Seek to given offset, relative to whence (see man lseek) in file descriptor fd or errAbort. * Return final offset (e.g. if this is just an (fd, 0, SEEK_CUR) query for current position). */ void mustCloseFd(int *pFd); /* Close file descriptor *pFd if >= 0, abort if there's an error, set *pFd = -1. */