$size ) { # # Oops. Asked for too many bytes from the # current position. Re-adjust to how much we # really need to read. # $size = $size - $start; } # # Open the file for reading. # Really should be error checking from here # on down. # $fh = fopen($file, "r"); # # Move to the position where we should begin # reading # fseek($fh, $start); # # Read the requested number of bytes and send # those back to the calling routine # print fread($fh, $length); # # All done. Close the file # fclose($fh); } else { # # The start position in the file is passed the # end of the file. That means we're all done. # print "done"; } } else { # # Really should return some sort of violation error here # print "done: invalid doc type: $file, $start, $length"; } ?>