remove obsolete .cvsignore files
[enigma2.git] / lib / components / file_eraser.cpp
index bc26bf7..9f92fa4 100644 (file)
@@ -1,4 +1,5 @@
 #include <lib/components/file_eraser.h>
 #include <lib/components/file_eraser.h>
+#include <lib/base/ioprio.h>
 #include <lib/base/eerror.h>
 #include <lib/base/init.h>
 #include <lib/base/init_num.h>
 #include <lib/base/eerror.h>
 #include <lib/base/init.h>
 #include <lib/base/init_num.h>
 eBackgroundFileEraser *eBackgroundFileEraser::instance;
 
 eBackgroundFileEraser::eBackgroundFileEraser()
 eBackgroundFileEraser *eBackgroundFileEraser::instance;
 
 eBackgroundFileEraser::eBackgroundFileEraser()
-       :messages(this,1), stop_thread_timer(this)
+       :messages(this,1), stop_thread_timer(eTimer::create(this))
 {
        if (!instance)
                instance=this;
        CONNECT(messages.recv_msg, eBackgroundFileEraser::gotMessage);
 {
        if (!instance)
                instance=this;
        CONNECT(messages.recv_msg, eBackgroundFileEraser::gotMessage);
-       CONNECT(stop_thread_timer.timeout, eBackgroundFileEraser::idle);
+       CONNECT(stop_thread_timer->timeout, eBackgroundFileEraser::idle);
 }
 
 void eBackgroundFileEraser::idle()
 }
 
 void eBackgroundFileEraser::idle()
@@ -26,18 +27,24 @@ void eBackgroundFileEraser::idle()
 eBackgroundFileEraser::~eBackgroundFileEraser()
 {
        messages.send(Message::quit);
 eBackgroundFileEraser::~eBackgroundFileEraser()
 {
        messages.send(Message::quit);
-       if ( thread_running() )
-               kill();
        if (instance==this)
                instance=0;
        if (instance==this)
                instance=0;
+       kill();  // i dont understand why this is needed .. in ~eThread::eThread is a kill() to..
 }
 
 void eBackgroundFileEraser::thread()
 {
 }
 
 void eBackgroundFileEraser::thread()
 {
+       hasStarted();
+
        nice(5);
        nice(5);
+
+       setIoPrio(IOPRIO_CLASS_BE, 7);
+
        reset();
        reset();
+
        runLoop();
        runLoop();
-       stop_thread_timer.stop();
+
+       stop_thread_timer->stop();
 }
 
 void eBackgroundFileEraser::erase(const char *filename)
 }
 
 void eBackgroundFileEraser::erase(const char *filename)
@@ -45,14 +52,13 @@ void eBackgroundFileEraser::erase(const char *filename)
        if (filename)
        {
                char buf[255];
        if (filename)
        {
                char buf[255];
-               snprintf(buf, 255, "%s.$$$", filename);
+               snprintf(buf, 255, "%s.del", filename);
                if (rename(filename, buf)<0)
                        ;/*perror("rename file failed !!!");*/
                else
                {
                        messages.send(Message(Message::erase, strdup(buf)));
                if (rename(filename, buf)<0)
                        ;/*perror("rename file failed !!!");*/
                else
                {
                        messages.send(Message(Message::erase, strdup(buf)));
-                       if (!thread_running())
-                               run();
+                       run();
                }
        }
 }
                }
        }
 }
@@ -70,7 +76,7 @@ void eBackgroundFileEraser::gotMessage(const Message &msg )
                                        eDebug("file %s erased", msg.filename);
                                free((char*)msg.filename);
                        }
                                        eDebug("file %s erased", msg.filename);
                                free((char*)msg.filename);
                        }
-                       stop_thread_timer.start(2000, true); // stop thread in two seconds
+                       stop_thread_timer->start(1000, true); // stop thread in one seconds
                        break;
                case Message::quit:
                        quit(0);
                        break;
                case Message::quit:
                        quit(0);