Fix: Bad counting of nb of lines

This commit is contained in:
Laurent Destailleur 2012-01-20 10:10:31 +01:00
parent e8c7a37772
commit ade26226f6

View File

@ -344,6 +344,7 @@ function dol_dir_is_emtpy($folder)
/** /**
* Count number of lines in a file * Count number of lines in a file
*
* @param file Filename * @param file Filename
* @return int <0 if KO, Number of lines in files if OK * @return int <0 if KO, Number of lines in files if OK
*/ */
@ -359,7 +360,8 @@ function dol_count_nb_of_line($file)
while (!feof($fp)) while (!feof($fp))
{ {
$line=fgets($fp); $line=fgets($fp);
$nb++; // We increase count only if read was success. We need test because feof return true only after fgets so we do n+1 fgets for a file with n lines.
if (! $line === false) $nb++;
} }
fclose($fp); fclose($fp);
} }