MythTV
master
libs
libmythprotoserver
requesthandler
fileserverutil.cpp
Go to the documentation of this file.
1
#include <unistd.h>
2
#include <cstdlib>
// for llabs
3
4
#include "mythconfig.h"
5
#if CONFIG_DARWIN || defined(__FreeBSD__)
6
#include <sys/param.h>
7
#include <sys/mount.h>
8
#elif __linux__
9
#include <sys/vfs.h>
10
#endif
11
12
#include <QMutex>
13
#include <QFile>
14
#include <QMap>
15
16
#include "
requesthandler/fileserverutil.h
"
17
#include "
programinfo.h
"
18
19
DeleteHandler::DeleteHandler
(
void
) :
20
ReferenceCounter
(
"DeleteHandler"
)
21
{
22
}
23
24
DeleteHandler::DeleteHandler
(
const
QString&
filename
) :
25
ReferenceCounter
(QString(
"DeleteHandler:%1"
).
arg
(
filename
)),
26
m_path(
filename
)
27
{
28
}
29
30
DeleteHandler::~DeleteHandler
()
31
{
32
Close
();
33
}
34
35
void
DeleteHandler::Close
(
void
)
36
{
37
if
(
m_fd
>= 0)
38
close
(
m_fd
);
39
m_fd
= -1;
40
}
41
42
static
QMap <QString, QString>
recordingPathCache
;
43
static
QMutex
recordingPathLock
;
44
45
QString
GetPlaybackURL
(
ProgramInfo
*pginfo,
bool
storePath)
46
{
47
QString result =
""
;
48
QMutexLocker locker(&
recordingPathLock
);
49
QString cacheKey = QString(
"%1:%2"
).arg(pginfo->
GetChanID
())
50
.arg(pginfo->
GetRecordingStartTime
(
MythDate::ISODate
));
51
if
((
recordingPathCache
.contains(cacheKey)) &&
52
(QFile::exists(
recordingPathCache
[cacheKey])))
53
{
54
result =
recordingPathCache
[cacheKey];
55
if
(!storePath)
56
recordingPathCache
.remove(cacheKey);
57
}
58
else
59
{
60
locker.unlock();
61
result = pginfo->
GetPlaybackURL
(
false
,
true
);
62
locker.relock();
63
if
(storePath && result.startsWith(
"/"
))
64
recordingPathCache
[cacheKey] = result;
65
}
66
67
return
result;
68
}
69
70
/* vim: set expandtab tabstop=4 shiftwidth=4: */
DeleteHandler::m_fd
int m_fd
Definition:
fileserverutil.h:40
arg
arg(title).arg(filename).arg(doDelete))
recordingPathLock
static QMutex recordingPathLock
Definition:
fileserverutil.cpp:43
DeleteHandler::DeleteHandler
DeleteHandler(void)
Definition:
fileserverutil.cpp:19
ProgramInfo::GetRecordingStartTime
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
Definition:
programinfo.h:402
close
#define close
Definition:
compat.h:17
fileserverutil.h
programinfo.h
GetPlaybackURL
QString GetPlaybackURL(ProgramInfo *pginfo, bool storePath)
Definition:
fileserverutil.cpp:45
filename
QString filename
Definition:
mythplugins/mytharchive/mytharchivehelper/main.cpp:637
ProgramInfo::GetChanID
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
Definition:
programinfo.h:370
ProgramInfo
Holds information on recordings and videos.
Definition:
programinfo.h:67
recordingPathCache
static QMap< QString, QString > recordingPathCache
Definition:
fileserverutil.cpp:42
ProgramInfo::GetPlaybackURL
QString GetPlaybackURL(bool checkMaster=false, bool forceCheckLocal=false)
Returns filename or URL to be used to play back this recording.
Definition:
programinfo.cpp:2444
MythDate::ISODate
@ ISODate
Default UTC.
Definition:
mythdate.h:14
DeleteHandler::~DeleteHandler
~DeleteHandler(void) override
Definition:
fileserverutil.cpp:30
DeleteHandler::Close
void Close(void)
Definition:
fileserverutil.cpp:35
ReferenceCounter
General purpose reference counter.
Definition:
referencecounter.h:26
Generated on Wed Jan 13 2021 03:17:35 for MythTV by
1.8.17