You are here

function File::file in Bibliography Module 7.2

Same name and namespace in other branches
  1. 6.2 modules/marcParse/php-marc.php \File::file()
  2. 6 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($input, $string = FALSE) {
  if (!$string && file_exists($input)) {
    $input = file_get_contents($input);
  }
  elseif (!empty($in) && !file_exists($input) && !$string) {
    return $this
      ->_warn("Invalid input file: {$i}");
  }
  $recs = explode(END_OF_RECORD, $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.
  foreach ($recs as $rec) {
    $this->raw[] = $rec . END_OF_RECORD;
  }
  $this->pointer = 0;
}