Ejemplo n.º 1
0
 public function testBagIt_parseVersionStringFail()
 {
     $data = "BagIt-Versions: 0.96\n" . "Tag-File-Character-Encoding: UTF-8\n";
     $versions = BagIt_parseVersionString($data);
     $this->assertNull($versions);
 }
Ejemplo n.º 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);
}