1 #include <lib/system/file_eraser.h>
2 #include <lib/system/init.h>
3 #include <lib/system/init_num.h>
9 eBackgroundFileEraser
*eBackgroundFileEraser::instance
;
11 eBackgroundFileEraser::eBackgroundFileEraser()
16 CONNECT(messages
.recv_msg
, eBackgroundFileEraser::gotMessage
);
20 eBackgroundFileEraser::~eBackgroundFileEraser()
22 messages
.send(Message::quit
);
23 if ( thread_running() )
29 void eBackgroundFileEraser::thread()
35 void eBackgroundFileEraser::erase(const char *filename
)
37 messages
.send(Message(Message::erase
, filename
?strdup(filename
):0));
40 void eBackgroundFileEraser::gotMessage(const Message
&msg
)
47 if ( ::unlink(msg
.filename
) < 0 )
48 eDebug("remove file %s failed (%m)", msg
.filename
);
50 eDebug("file %s erased", msg
.filename
);
51 free((char*)msg
.filename
);
58 eDebug("unhandled thread message");
62 eAutoInitP0
<eBackgroundFileEraser
> init_eBackgroundFilEraser(eAutoInitNumbers::configuration
+1, "Background File Eraser");