You are here

public function File::__construct in Bibliography Module 7

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

1 method overrides File::__construct()
USMARC::__construct in modules/marcParse/php-marc.php
Read raw MARC string for decoding.

File

modules/marcParse/php-marc.php, line 213
@package PHP-MARC

Class

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

Code

public function __construct($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}");
  }
}