11#include <QMutexLocker>
39 LOG(VB_FILE, LOG_DEBUG,
"Spawning new delete thread.");
53 QList<DeleteHandler*>::iterator i;
63 LOG(VB_FILE, LOG_DEBUG,
"Delete thread self-terminating due to idle.");
72 QFileInfo finfo(path);
112 QString path = handler->
m_path;
113 QByteArray cpath_ba = handler->
m_path.toLocal8Bit();
114 const char *cpath = cpath_ba.constData();
116 QFileInfo finfo(handler->
m_path);
117 if (finfo.isSymLink())
128 LOG(VB_GENERAL, LOG_ERR,
129 QString(
"Error deleting '%1' -> '%2': ")
145 handler->
m_path = tmppath;
146 cpath_ba = handler->
m_path.toLocal8Bit();
147 cpath = cpath_ba.constData();
155 LOG(VB_GENERAL, LOG_ERR,
156 QString(
"Error deleting '%1': count not unlink ")
171 LOG(VB_FILE, LOG_INFO, QString(
"About to unlink/delete file: '%1'")
173 int fd = open(cpath, O_WRONLY);
176 LOG(VB_FILE, LOG_INFO, QString(
"About to unlink/delete file"));
181 LOG(VB_GENERAL, LOG_ERR,
182 QString(
"Error deleting '%1': is no directory ")
191 else if (unlink(cpath))
193 LOG(VB_GENERAL, LOG_ERR,
194 QString(
"Error deleting '%1': could not unlink ")
206 handler->
m_size = finfo.size();
207 handler->
m_wait = ctime.addSecs(3);
229 if (handler->
m_wait > ctime)
235 int err = ftruncate(handler->
m_fd, handler->
m_size);
239 LOG(VB_GENERAL, LOG_ERR, QString(
"Error truncating '%1'")
virtual void DeleteSucceeded(void)
virtual void DeleteFailed(void)
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
QList< DeleteHandler * > m_newfiles
QList< DeleteHandler * > m_files
bool AddFile(const QString &path)
This is a wrapper around QThread that does several additional things.
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
static void usleep(std::chrono::microseconds time)
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
int GetNumSetting(const QString &key, int defaultval=0)
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
virtual int IncrRef(void)
Increments reference count.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define ENO
This can be appended to the LOG args with "+".
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
bool MythRemoveDirectory(QDir &aDir)
QString getSymlinkTarget(const QString &start_file, QStringList *intermediaries, unsigned maxLinks)
QDateTime current(bool stripped)
Returns current Date and Time in UTC.