Esempio n. 1
0
 function toPackageFile($where = null, $state = PEAR_VALIDATE_NORMAL, $name = 'package.xml')
 {
     if (!$this->_packagefile->validate($state)) {
         return PEAR::raiseError('PEAR_Packagefile_v2::toPackageFile: invalid package.xml', null, null, null, $this->_packagefile->getValidationWarnings());
     }
     if ($where === null) {
         if (!($where = System::mktemp(array('-d')))) {
             return PEAR::raiseError('PEAR_Packagefile_v2::toPackageFile: mktemp failed');
         }
     } elseif (!@System::mkDir(array('-p', $where))) {
         return PEAR::raiseError('PEAR_Packagefile_v2::toPackageFile: "' . $where . '" could' . ' not be created');
     }
     $newpkgfile = $where . DIRECTORY_SEPARATOR . $name;
     $np = @fopen($newpkgfile, 'wb');
     if (!$np) {
         return PEAR::raiseError('PEAR_Packagefile_v2::toPackageFile: unable to save ' . "{$name} as {$newpkgfile}");
     }
     fwrite($np, $this->toXml($state));
     fclose($np);
     return $newpkgfile;
 }