Example #1
0
 public function testBagIt_parseEncodingStringFail()
 {
     $data = "BagIt-Version: 0.96\n" . "Tag-File-Character-encoding: UTF-8\n";
     $encoding = BagIt_parseEncodingString($data);
     $this->assertNull($encoding);
 }
Example #2
0
/**
 * This reads the information from the bag it file.
 *
 * @param string $filename The bagit.txt file to read.
 *
 * @return array An array triple of the version, the file encoding, and any 
 * errors encountered.
 */
function BagIt_readBagItFile($filename)
{
    $errors = array();
    if (file_exists($filename)) {
        $data = readFileText($filename, 'UTF-8');
        $versions = BagIt_parseVersionString($data);
        if ($versions === null) {
            array_push($errors, array('bagit', 'Error reading version information from bagit.txt file.'));
        }
        $fileEncoding = BagIt_parseEncodingString($data);
    } else {
        $versions = array('major' => 0, 'minor' => 96);
        $fileEncoding = 'UTF-8';
    }
    return array($versions, $fileEncoding, $errors);
}