MythTV master
fileserverutil.cpp
Go to the documentation of this file.
1#include <unistd.h>
2#include <cstdlib> // for llabs
3
4#include <QtGlobal>
5#ifdef Q_OS_BSD4
6#include <sys/param.h>
7#include <sys/mount.h>
8#elif defined(Q_OS_LINUX)
9#include <sys/vfs.h>
10#endif
11
12#include <QChar> // Fix Qt6 GCC SFINAE warning
13#include <QMutex>
14#include <QFile>
15#include <QMap>
16
18
20
22 ReferenceCounter("DeleteHandler")
23{
24}
25
27 ReferenceCounter(QString("DeleteHandler:%1").arg(filename)),
28 m_path(filename)
29{
30}
31
33{
34 Close();
35}
36
38{
39 if (m_fd >= 0)
40 close(m_fd);
41 m_fd = -1;
42}
43
44static QMap <QString, QString> recordingPathCache;
45static QMutex recordingPathLock;
46
47QString GetPlaybackURL(ProgramInfo *pginfo, bool storePath)
48{
49 QString result = "";
50 QMutexLocker locker(&recordingPathLock);
51 QString cacheKey = QString("%1:%2").arg(pginfo->GetChanID())
53 if ((recordingPathCache.contains(cacheKey)) &&
55 {
56 result = recordingPathCache[cacheKey];
57 if (!storePath)
58 recordingPathCache.remove(cacheKey);
59 }
60 else
61 {
62 locker.unlock();
63 result = pginfo->GetPlaybackURL(false, true);
64 locker.relock();
65 if (storePath && result.startsWith("/"))
66 recordingPathCache[cacheKey] = result;
67 }
68
69 return result;
70}
71
72/* vim: set expandtab tabstop=4 shiftwidth=4: */
void Close(void)
~DeleteHandler(void) override
Holds information on recordings and videos.
Definition: programinfo.h:74
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
Definition: programinfo.h:380
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
Definition: programinfo.h:412
QString GetPlaybackURL(bool checkMaster=false, bool forceCheckLocal=false)
Returns filename or URL to be used to play back this recording.
General purpose reference counter.
#define close
Definition: compat.h:28
static QMutex recordingPathLock
static QMap< QString, QString > recordingPathCache
QString GetPlaybackURL(ProgramInfo *pginfo, bool storePath)
@ ISODate
Default UTC.
Definition: mythdate.h:18
bool exists(str path)
Definition: xbmcvfs.py:51