changed _read_file parameter from $end to $lines

This commit is contained in:
mohrt
2001-11-05 21:24:49 +00:00
parent 3dec11ad08
commit dfdfbf441c
2 changed files with 14 additions and 14 deletions

View File

@@ -1068,17 +1068,17 @@ function _run_insert_handler($args)
/*======================================================================*\ /*======================================================================*\
Function: _read_file() Function: _read_file()
Purpose: read in a file from line $start to line $end. Purpose: read in a file from line $start for $lines.
read the entire file if $start and $end are null read the entire file if $start and $lines are null.
\*======================================================================*/ \*======================================================================*/
function _read_file($filename,$start=null,$end=null) function _read_file($filename,$start=null,$lines=null)
{ {
if (!($fd = @fopen($filename, 'r'))) { if (!($fd = @fopen($filename, 'r'))) {
$this->_trigger_error_msg("problem reading '$filename.'"); $this->_trigger_error_msg("problem reading '$filename.'");
return false; return false;
} }
flock($fd, LOCK_SH); flock($fd, LOCK_SH);
if($start == null && $end == null) { if($start == null && $lines == null) {
// read the entire file // read the entire file
$contents = fread($fd, filesize($filename)); $contents = fread($fd, filesize($filename));
} else { } else {
@@ -1088,14 +1088,14 @@ function _run_insert_handler($args)
fgets($fd,65536); fgets($fd,65536);
} }
} }
if( $end == null ) { if( $lines == null ) {
// read the rest of the file // read the rest of the file
while(!feof($fd)) { while(!feof($fd)) {
$contents .= fgets($fd,65536); $contents .= fgets($fd,65536);
} }
} else { } else {
// read up to $end lines // read up to $lines lines
for ($loop=$start; $loop <= $end; $loop++) { for ($loop=0; $loop < $lines; $loop++) {
$contents .= fgets($fd,65536); $contents .= fgets($fd,65536);
if(feof($fd)) { if(feof($fd)) {
break; break;

View File

@@ -1068,17 +1068,17 @@ function _run_insert_handler($args)
/*======================================================================*\ /*======================================================================*\
Function: _read_file() Function: _read_file()
Purpose: read in a file from line $start to line $end. Purpose: read in a file from line $start for $lines.
read the entire file if $start and $end are null read the entire file if $start and $lines are null.
\*======================================================================*/ \*======================================================================*/
function _read_file($filename,$start=null,$end=null) function _read_file($filename,$start=null,$lines=null)
{ {
if (!($fd = @fopen($filename, 'r'))) { if (!($fd = @fopen($filename, 'r'))) {
$this->_trigger_error_msg("problem reading '$filename.'"); $this->_trigger_error_msg("problem reading '$filename.'");
return false; return false;
} }
flock($fd, LOCK_SH); flock($fd, LOCK_SH);
if($start == null && $end == null) { if($start == null && $lines == null) {
// read the entire file // read the entire file
$contents = fread($fd, filesize($filename)); $contents = fread($fd, filesize($filename));
} else { } else {
@@ -1088,14 +1088,14 @@ function _run_insert_handler($args)
fgets($fd,65536); fgets($fd,65536);
} }
} }
if( $end == null ) { if( $lines == null ) {
// read the rest of the file // read the rest of the file
while(!feof($fd)) { while(!feof($fd)) {
$contents .= fgets($fd,65536); $contents .= fgets($fd,65536);
} }
} else { } else {
// read up to $end lines // read up to $lines lines
for ($loop=$start; $loop <= $end; $loop++) { for ($loop=0; $loop < $lines; $loop++) {
$contents .= fgets($fd,65536); $contents .= fgets($fd,65536);
if(feof($fd)) { if(feof($fd)) {
break; break;