本文整理汇总了C++中KTempFile::unlink方法的典型用法代码示例。如果您正苦于以下问题:C++ KTempFile::unlink方法的具体用法?C++ KTempFile::unlink怎么用?C++ KTempFile::unlink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KTempFile
的用法示例。
在下文中一共展示了KTempFile::unlink方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotFileSave
void KgpgApp::slotFileSave()
{
TQString filn=Docname.path();
if (filn.isEmpty()) {
slotFileSaveAs();
return;
}
TQTextCodec*cod=TQTextCodec::codecForName (textEncoding.ascii());
// slotStatusMsg(i18n("Saving file..."));
if (!checkEncoding(cod)) {
KMessageBox::sorry(this,i18n("The document could not been saved, as the selected encoding cannot encode every unicode character in it."));
return;
}
KTempFile tmpfile;
if (Docname.isLocalFile()) {
TQFile f(filn);
if ( !f.open( IO_WriteOnly ) ) {
KMessageBox::sorry(this,i18n("The document could not be saved, please check your permissions and disk space."));
return;
}
TQTextStream t( &f );
t.setCodec(cod);
//t.setEncoding( TQTextStream::Latin1 );
t << view->editor->text();//.utf8();
f.close();
}
else {
/*FIXME use following code:
TQFile f( fName );
00983 if ( !f.open( IO_ReadOnly ) )
00984 return;
00985 TQFileInfo info ( f );
00986 smModificationTime = new TQTime( info.lastModified().time() );
00987 TQTextStream t(&f);
00988 t.setEncoding( TQTextStream::Latin1 );
00989 TQString s = t.readLine();
00990 f.close();
*/
TQTextStream *stream = tmpfile.textStream();
stream->setCodec(cod);
*stream << view->editor->text();//.utf8();
tmpfile.close();
if(!TDEIO::NetAccess::upload(tmpfile.name(), Docname,this)) {
KMessageBox::sorry(this,i18n("The document could not be saved, please check your permissions and disk space."));
tmpfile.unlink();
return;
}
tmpfile.unlink();
}
fileSave->setEnabled(false);
setCaption(Docname.fileName(),false);
}
示例2: infoMessage
void K3bIsoImager::writePathSpecForFile( K3bFileItem* item, QTextStream& stream )
{
stream << escapeGraftPoint( item->writtenPath() )
<< "=";
if( m_doc->bootImages().containsRef( dynamic_cast<K3bBootItem*>(item) ) ) { // boot-image-backup-hack
// create temp file
KTempFile temp;
QString tempPath = temp.name();
temp.unlink();
if( !KIO::NetAccess::copy( KURL(item->localPath()), KURL::fromPathOrURL(tempPath) ) ) {
emit infoMessage( i18n("Failed to backup boot image file %1").arg(item->localPath()), ERROR );
return;
}
static_cast<K3bBootItem*>(item)->setTempPath( tempPath );
m_tempFiles.append(tempPath);
stream << escapeGraftPoint( tempPath ) << "\n";
}
else if( item->isSymLink() && d->usedLinkHandling == Private::FOLLOW )
stream << escapeGraftPoint( K3b::resolveLink( item->localPath() ) ) << "\n";
else
stream << escapeGraftPoint( item->localPath() ) << "\n";
}
示例3: file
void RulesDialog::slotUser2()
{
KURL kurl = KFileDialog::getSaveURL(0, i18n("*.sh|Shell Scripts (*.sh)"), this);
if (kurl.path() == "")
return;
KTempFile temp;
QString fileName = kurl.path();
if (fileName == "")
return;
if (!kurl.isLocalFile())
{
fileName = temp.name();
}
QFile file(fileName);
file.open(IO_WriteOnly);
QTextStream stream(&file);
stream << mRules->text();
file.close();
if (!kurl.isLocalFile())
{
if (!KIO::NetAccess::upload(fileName, kurl, this))
KMessageBox::error(this, i18n("Failed to upload file."));
}
temp.unlink();
}
示例4: slotSave
void KMoneyThingMainWidget::slotSave()
{
KTempFile temp;
QString fileName = mCurrentFile->kurl().path();
if (fileName == "")
{
slotSaveAs();
return;
}
if (!mCurrentFile->kurl().isLocalFile())
{
fileName = temp.name();
}
emit(setStatus(i18n("Saving file...")));
QByteArray dump = qCompress(mCurrentFile->dump());
QFile file(fileName);
file.open(IO_WriteOnly);
QDataStream stream(&file);
stream << (QString) "KMoneyThingFile" << dump;
file.close();
if (!mCurrentFile->kurl().isLocalFile())
{
emit(setStatus(i18n("Uploading file...")));
if (!KIO::NetAccess::upload(fileName, mCurrentFile->kurl(), this))
KMessageBox::error(this, i18n("Failed to upload file."));
}
temp.unlink();
emit(setStatus(i18n("Ready.")));
}
示例5: saveFile
bool KMiniEdit::saveFile(KURL newurl)
{
if (newurl.isEmpty())
newurl = KFileDialog::getSaveURL();
if (newurl.isEmpty())
return false;
if (newurl.isMalformed())
{
QString text = i18n("<b>THe URL %1 is not correct!</b>");
KMessageBox::sorry(this, text.arg(newurl.prettyURL()));
return false;
}
if (newurl.isLocalFile())
{
QFile file(newurl.path());
file.open(IO_WriteOnly);
saveToLocalFile(&file);
}
else
{
KTempFile tempfile;
saveToLocalFile(tempfile.file());
if (!KIO::NetAccess::upload(tempfile.name(), newurl))
{
QString text = i18n("<b>Error uploading %1!</b>");
KMessageBox::sorry(this, text.arg(newurl.prettyURL()));
tempfile.unlink();
return false;
}
tempfile.unlink();
}
url = newurl;
addURLtoRecent();
resetEdited();
return true;
}