# HG changeset patch # User Rob Landley # Date 1169759437 18000 # Node ID 8018c40605d9359737aedc8ec40f4fc5734985c7 # Parent e6332139adae9da5de4208a7db5381b8ad1a730a The fdlength() ioctl apparently doesn't work on files (and the lseek trick doesn't work on some devices, and we can't always tell _when_ it failed), so go to the binary search for now. diff -r e6332139adae -r 8018c40605d9 lib/functions.c --- a/lib/functions.c Tue Jan 23 19:54:01 2007 -0500 +++ b/lib/functions.c Thu Jan 25 16:10:37 2007 -0500 @@ -397,18 +397,6 @@ return itoa_buf; } -off_t fdlength(int fd) -{ - int size; - - if (ioctl(fd, BLKGETSIZE, &size) >= 0) return size*512L; - return -1; -} - -/* - This might be of use or might not. Unknown yet... - - // Return how long the file at fd is, if there's any way to determine it. off_t fdlength(int fd) { @@ -430,7 +418,7 @@ // If we can read from the current location, it's bigger. - if (lseek(fd, pos, 0)>=0 && safe_read(fd, &temp, 1)==1) { + if (lseek(fd, pos, 0)>=0 && read(fd, &temp, 1)==1) { if (bottom == top) bottom = top = (top+1) * 2; else bottom = pos; @@ -447,6 +435,9 @@ return pos + 1; } +/* + This might be of use or might not. Unknown yet... + // Read contents of file as a single freshly allocated nul-terminated string. char *readfile(char *name) {