You are here

function File::file in Bibliography Module 6.2

Same name and namespace in other branches
  1. 6 marcParse/php-marc.php \File::file()
  2. 7.2 modules/marcParse/php-marc.php \File::file()

Read in MARC record file

This function will read in MARC record files that either contain a single MARC record, or numerous records.

Parameters

string Name of the file:

Return value

string Returns warning if issued during read

File

modules/marcParse/php-marc.php, line 195

Class

File
Class File Class to read MARC records from file(s)

Code

function file($in) {
  if (file_exists($in)) {
    $input = file($in);
    $recs = explode(END_OF_RECORD, join("", $input));

    // Append END_OF_RECORD as we lost it when splitting
    // Last is not record, as it is empty because every record ends
    // with END_OF_RECORD.
    for ($i = 0; $i < count($recs) - 1; $i++) {
      $this->raw[] = $recs[$i] . END_OF_RECORD;
    }
    $this->pointer = 0;
  }
  else {
    return $this
      ->_warn("Invalid input file: {$i}");
  }
}