} } $cmd = implode(' ', $cmd); exec($cmd, $newPot, $result); if ($result) { print "ERROR: xgettext returned with error code {$result}.\n"; print "Command line was:\n\n"; print "{$cmd}\n\n"; exit(1); } print " done.\n"; if (in_array('--force', $_SERVER['argv'])) { $update = true; } else { // Read existing POT file into $oldPot $oldPot = \Library\FileObject::fileGetContentsAsArray($potFileName, FILE_IGNORE_NEW_LINES); // Skip to first message string (strip header and first empty line) $startPos = array_search('', $oldPot, true); if ($startPos === false) { print "WARNING: File {$potFileName} as unexpected content. Skipping.\n"; continue; } $oldPot = array_slice($oldPot, $startPos + 1); $update = $newPot != $oldPot; } if ($update) { \Library\FileObject::FilePutContents($potFileName, sprintf($template, $module, implode("\n", $newPot))); print "Changes written to {$potFileName}.\n"; } else { print "No changes detected for {$potFileName}.\n"; }
public function testFileGetContentsAsArrayError() { $this->setExpectedException('RuntimeException', 'Error reading from file vfs://root/test.txt'); // Force error by requesting nonexistent file FileObject::fileGetContentsAsArray('vfs://root/test.txt'); }