file_length.bak

final_realms_fluffos_v1/lib/secure/simul_efun/file_length.bak · 499 B

From the archive final_realms_fluffos_v1.zip

Download the archive   « Back to the archive contents

/*
 * returns the number of lines in a file.
 */
int file_length(string file_name) {
  int top, bottom;

  if ((top = file_size(file_name)) < 0) return top;
  top = top / 46;
  if(top < 2)
    top = 2;
  bottom = 1;
  while (read_file(file_name, top)) {
    top = top + top/2; /* top *= 1.5; */
  }
  while (top > bottom+1) {
    if (read_file(file_name, (top+bottom)/2)) {
      bottom = (top+bottom)/2;
    } else {
      top = (top+bottom)/2;
    }
  }
   return bottom -2;
} /* file_length() */

Site Stats

Snippets: 1791
Codebases: 571