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#if defined(Q_OS_DARWIN) || defined(__FreeBSD__)
6#include <sys/param.h>
7#include <sys/mount.h>
8#elif defined(__linux__)
9#include <sys/vfs.h>
10#endif
11
12#include <QMutex>
13#include <QFile>
14#include <QMap>
15
17
19
21 ReferenceCounter("DeleteHandler")
22{
23}
24
26 ReferenceCounter(QString("DeleteHandler:%1").arg(filename)),
27 m_path(filename)
28{
29}
30
32{
33 Close();
34}
35
37{
38 if (m_fd >= 0)
39 close(m_fd);
40 m_fd = -1;
41}
42
43static QMap <QString, QString> recordingPathCache;
44static QMutex recordingPathLock;
45
46QString GetPlaybackURL(ProgramInfo *pginfo, bool storePath)
47{
48 QString result = "";
49 QMutexLocker locker(&recordingPathLock);
50 QString cacheKey = QString("%1:%2").arg(pginfo->GetChanID())
52 if ((recordingPathCache.contains(cacheKey)) &&
54 {
55 result = recordingPathCache[cacheKey];
56 if (!storePath)
57 recordingPathCache.remove(cacheKey);
58 }
59 else
60 {
61 locker.unlock();
62 result = pginfo->GetPlaybackURL(false, true);
63 locker.relock();
64 if (storePath && result.startsWith("/"))
65 recordingPathCache[cacheKey] = result;
66 }
67
68 return result;
69}
70
71/* vim: set expandtab tabstop=4 shiftwidth=4: */
void Close(void)
~DeleteHandler(void) override
Holds information on recordings and videos.
Definition: programinfo.h:70
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
Definition: programinfo.h:375
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
Definition: programinfo.h:407
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:30
static QMutex recordingPathLock
static QMap< QString, QString > recordingPathCache
QString GetPlaybackURL(ProgramInfo *pginfo, bool storePath)
@ ISODate
Default UTC.
Definition: mythdate.h:17
bool exists(str path)
Definition: xbmcvfs.py:51