diff options
Diffstat (limited to 'kget/safedelete.cpp')
-rw-r--r-- | kget/safedelete.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/kget/safedelete.cpp b/kget/safedelete.cpp new file mode 100644 index 00000000..c4cb6915 --- /dev/null +++ b/kget/safedelete.cpp @@ -0,0 +1,35 @@ +#include <klocale.h> +#include <kmessagebox.h> +#include <kurl.h> +#include <kio/netaccess.h> + +#include <qfileinfo.h> + +#include "safedelete.h" + +bool SafeDelete::deleteFile( const KURL& url ) +{ + if ( url.isLocalFile() ) + { + QFileInfo info( url.path() ); + if ( info.isDir() ) + { + KMessageBox::information(0L, + i18n("Not deleting\n%1\nas it is a " + "directory.").arg( url.prettyURL() ), + i18n("Not Deleted")); + return false; + } + + KIO::NetAccess::del( url, 0L ); + return true; + } + + else + KMessageBox::information( 0L, + i18n("Not deleting\n%1\nas it is not a local" + " file.").arg( url.prettyURL() ), + i18n("Not Deleted") ); + + return false; +} |