kshred.h
00001 /*--------------------------------------------------------------------------* 00002 KShred.h Copyright (c) 2000 MieTerra LLC. 00003 Credits: Andreas F. Pour <bugs@mieterra.com> 00004 00005 Permission is hereby granted, free of charge, to any person obtaining a copy 00006 of this software and associated documentation files (the "Software"), to deal 00007 in the Software without restriction, including without limitation the rights 00008 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00009 copies of the Software, and to permit persons to whom the Software is 00010 furnished to do so, subject to the following conditions: 00011 00012 The above copyright notice and this permission notice shall be included in 00013 all copies or substantial portions of the Software. 00014 00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00018 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00019 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00020 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00021 */ 00022 00023 #ifndef kshred_h 00024 #define kshred_h 00025 00026 #include <stdlib.h> 00027 #include <stdio.h> 00028 #include <string.h> 00029 #include <unistd.h> 00030 #include <qstring.h> 00031 #include <qfile.h> 00032 #include <qobject.h> 00033 00034 #include <kio/global.h> 00035 00045 class KIO_EXPORT_DEPRECATED KShred : public QObject { // KDE4: remove 00046 00047 Q_OBJECT 00048 00049 public: 00050 00055 KShred(QString fileName); 00056 00057 /* 00058 * Destructor for the class. 00059 */ 00060 ~KShred(); 00061 00067 bool fill1s(); 00072 bool fill0s(); 00073 00079 bool fillbyte(unsigned int byte); 00080 00085 bool fillrandom(); 00086 00093 bool fillpattern(unsigned char *pattern, unsigned int size); 00094 00101 bool shred(); 00102 00108 static bool shred(QString fileName); 00109 00110 signals: 00115 void processedSize(KIO::filesize_t bytes); 00116 00121 void infoMessage(const QString & message); 00122 00123 private: 00127 bool writeData(unsigned char *data, unsigned int size); 00128 00132 bool flush(); 00133 00137 QFile *file; 00138 00142 KIO::filesize_t fileSize; 00143 00147 unsigned int totalBytes; 00148 unsigned int bytesWritten; 00149 unsigned int lastSignalled; 00150 unsigned int tbpc; 00151 unsigned int fspc; 00152 private: 00153 class KShredPrivate* d; 00154 }; 00155 00156 #endif