summaryrefslogtreecommitdiff
path: root/core
Side-by-side diff
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp45
-rw-r--r--core/launcher/packageslave.cpp48
2 files changed, 49 insertions, 44 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 4bbc62b..1c81a55 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -782,3 +782,3 @@ void TextEdit::showEditTools() {
bool TextEdit::save() {
- QString name, file;
+ QString name, file;
odebug << "saveAsFile " + currentFileName << oendl;
@@ -788,12 +788,11 @@ bool TextEdit::save() {
}
- name = currentFileName;
- if(doc) {
- file = doc->file();
- odebug << "saver file "+file << oendl;
- name = doc->name();
- odebug << "File named "+name << oendl;
- } else {
- file = currentFileName;
+ if(doc) {
+ file = doc->file();
+ odebug << "saver file "+file << oendl;
+ name = doc->name();
+ odebug << "File named "+name << oendl;
+ } else {
+ file = currentFileName;
name = QFileInfo(currentFileName).baseName();
- }
+ }
@@ -809,3 +808,4 @@ bool TextEdit::save() {
mode_t mode;
- stat(file.latin1(), &buf);
+ QFile f(file);
+ fstat(f.handle(), &buf);
mode = buf.st_mode;
@@ -816,3 +816,3 @@ bool TextEdit::save() {
if ( !fm.saveFile( *doc, rt ) ) {
- QMessageBox::message(tr("Text Edit"),tr("Save Failed"));
+ QMessageBox::message(tr("Text Edit"),tr("Save Failed"));
return false;
@@ -821,11 +821,9 @@ bool TextEdit::save() {
odebug << "regular save file" << oendl;
- QFile f(file);
- if( f.open(IO_WriteOnly)) {
- QCString crt = rt.utf8();
- f.writeBlock(crt,crt.length());
- } else {
- QMessageBox::message(tr("Text Edit"),tr("Write Failed"));
- return false;
- }
-
+ if( f.open(IO_WriteOnly)) {
+ QCString crt = rt.utf8();
+ f.writeBlock(crt,crt.length());
+ } else {
+ QMessageBox::message(tr("Text Edit"),tr("Write Failed"));
+ return false;
+ }
}
@@ -835,6 +833,5 @@ bool TextEdit::save() {
if(caption().left(1)=="*")
- setCaption(caption().right(caption().length()-1));
-
+ setCaption(caption().right(caption().length()-1));
- chmod( file.latin1(), mode);
+ fchmod( f.handle(), mode);
}
diff --git a/core/launcher/packageslave.cpp b/core/launcher/packageslave.cpp
index abbc610..965020e 100644
--- a/core/launcher/packageslave.cpp
+++ b/core/launcher/packageslave.cpp
@@ -216,28 +216,36 @@ void PackageHandler::cleanupPackageFiles( const QString &listfile )
if ( f.open(IO_ReadOnly) ) {
- QTextStream ts(&f);
-
- QString s;
- while ( !ts.eof() ) { // until end of file...
- s = ts.readLine(); // line of text excluding '\n'
- // for s, do link/mkdir.
- if ( s.right(1) == "/" ) {
- //should rmdir if empty, after all files have been removed
- } else {
+ QTextStream ts(&f);
+
+ QString s;
+ while ( !ts.eof() ) { // until end of file...
+ s = ts.readLine(); // line of text excluding '\n'
+ // for s, do link/mkdir.
+ // @todo Right now we just move on if the name of the file we
+ // find is actually a directory. What we ought to do is check
+ // to see if the directory is empty and if so remove it.
+ if ( s.right(1) != "/" ) {
#ifndef Q_OS_WIN32
- odebug << "remove symlink for " << s.ascii() << "" << oendl;
- //check if it is a symlink first (don't remove /etc/passwd...)
- char buf[10]; //we don't care about the contents
- if ( ::readlink( s.ascii(),buf, 10 >= 0 ) )
- ::unlink( s.ascii() );
+ odebug << "remove symlink for " << s << oendl;
+ QFile symFile(s);
+ QFileInfo symFileInfo(symFile);
+ //check if it is a symlink first (don't remove /etc/passwd...)
+ if ( !symFileInfo.readLink().isNull())
+ if (!symFile.remove())
+ owarn << "Unable to remove symlink " << symFile.name()
+ << " " << __FILE__ << ":" << __LINE__ << oendl;
#else
- // ### revise
- owarn << "Unable to remove symlink " << __FILE__ << ":" << __LINE__ << "" << oendl;
+ // @todo If we actually want to be portable to other operating
+ // systems we ought to at least have a portable way of removing
+ // their notion of symlinks.
+ owarn << "Unable to remove symlink " << s " " << __FILE__
+ << ":" << __LINE__ << oendl;
#endif
+ }
}
- }
- f.close();
+ f.close();
//remove the list file
- ::unlink( listfile.ascii() );
-
+ if (!f.remove())
+ owarn << "Unable to remove list file " << f.name() << " "
+ << __FILE__ << ":" << __LINE__ << oendl;
}