if (_do_script != "")
{
if ( !_tmp_do_script )
- _tmp_do_script.reset(new filesystem::TmpDir(getZYpp()->tmpPath()));
+ _tmp_do_script.reset(new filesystem::TmpFile(getZYpp()->tmpPath(), "zypp-yum-do-script-"));
Pathname pth = _tmp_do_script->path();
// FIXME check success
ofstream st(pth.asString().c_str());
+
+ if ( !st )
+ {
+ ZYPP_THROW(Exception(N_("Can't write the patch script to a temporary file.")));
+ }
+
st << _do_script << endl;
return pth;
}
if (_undo_script != "")
{
if ( !_tmp_undo_script )
- _tmp_undo_script.reset(new filesystem::TmpDir(getZYpp()->tmpPath()));
+ _tmp_undo_script.reset(new filesystem::TmpFile(getZYpp()->tmpPath(), "zypp-yum-undo-script-"));
Pathname pth = _tmp_undo_script->path();
// FIXME check success
ofstream st(pth.asString().c_str());
+
+ if ( !st )
+ {
+ ZYPP_THROW(Exception(N_("Can't write the patch script to a temporary file.")));
+ }
+
st << _undo_script << endl;
return pth;
}
/** Media number of the undo script */
unsigned _undo_media;
- mutable shared_ptr<filesystem::TmpDir> _tmp_do_script;
- mutable shared_ptr<filesystem::TmpDir> _tmp_undo_script;
+ mutable shared_ptr<filesystem::TmpFile> _tmp_do_script;
+ mutable shared_ptr<filesystem::TmpFile> _tmp_undo_script;
CheckSum _do_checksum;
CheckSum _undo_checksum;
detail::ResImplTraits<XMLScriptImpl>::Ptr impl(new XMLScriptImpl());
ofstream file;
- file.open(impl->_do_script.path().asString().c_str());
+ file.open(impl->_do_script->path().asString().c_str());
+
+ if ( ! file )
+ ZYPP_THROW(Exception(N_("Can't write the patch script to a temporary file.")));
+
file << parsed.do_script;;
file.close();
- file.open(impl->_undo_script.path().asString().c_str());
+ file.open(impl->_undo_script->path().asString().c_str());
+ if ( ! file )
+ ZYPP_THROW(Exception(N_("Can't write the patch script to a temporary file.")));
+
file << parsed.undo_script;;
file.close();
/** Default ctor */
XMLScriptImpl::XMLScriptImpl()
{
- _do_script = TmpFile( TmpPath::defaultLocation(), "zypp-xmlstore-do-script-");
- _undo_script = TmpFile( TmpPath::defaultLocation(), "zypp-xmlstore-undo-script-");
+ _do_script.reset( new TmpFile( TmpPath::defaultLocation(), "zypp-xmlstore-do-script-") );
+ _undo_script.reset( new TmpFile( TmpPath::defaultLocation(), "zypp-xmlstore-undo-script-"));
}
/** Dtor */
{}
Pathname XMLScriptImpl::do_script() const {
- return _do_script.path();
+ return _do_script->path();
}
Pathname XMLScriptImpl::undo_script() const {
- return _undo_script.path();
+ return _undo_script->path();
}
bool XMLScriptImpl::undo_available() const {
- return _undo_script != "";
+ return *_undo_script != "";
}
/////////////////////////////////////////////////////////////////
/** Check whether script to undo the change is available */
virtual bool undo_available() const;
- TmpFile _do_script;
- TmpFile _undo_script;
-
+ mutable shared_ptr<filesystem::TmpFile> _do_script;
+ mutable shared_ptr<filesystem::TmpFile> _undo_script;
+
TranslatedText _summary;
TranslatedText _description;