00001 #include <unistd.h> 00002 #include <cstdlib> // for llabs 00003 00004 #include "mythconfig.h" 00005 #if CONFIG_DARWIN || defined(__FreeBSD__) 00006 #include <sys/param.h> 00007 #include <sys/mount.h> 00008 #elif __linux__ 00009 #include <sys/vfs.h> 00010 #endif 00011 00012 #include <QMutex> 00013 #include <QFile> 00014 #include <QMap> 00015 00016 #include "requesthandler/fileserverutil.h" 00017 #include "programinfo.h" 00018 00019 DeleteHandler::DeleteHandler(void) : 00020 ReferenceCounter(), m_fd(-1), m_size(0) 00021 { 00022 } 00023 00024 DeleteHandler::DeleteHandler(QString filename) : 00025 ReferenceCounter(), m_path(filename), m_fd(-1), m_size(0) 00026 { 00027 } 00028 00029 DeleteHandler::~DeleteHandler() 00030 { 00031 Close(); 00032 } 00033 00034 void DeleteHandler::Close(void) 00035 { 00036 if (m_fd >= 0) 00037 close(m_fd); 00038 m_fd = -1; 00039 } 00040 00041 QMap <QString, QString> recordingPathCache; 00042 00043 QString GetPlaybackURL(ProgramInfo *pginfo, bool storePath) 00044 { 00045 static QMutex recordingPathLock; 00046 QString result = ""; 00047 QMutexLocker locker(&recordingPathLock); 00048 QString cacheKey = QString("%1:%2").arg(pginfo->GetChanID()) 00049 .arg(pginfo->GetRecordingStartTime(ISODate)); 00050 if ((recordingPathCache.contains(cacheKey)) && 00051 (QFile::exists(recordingPathCache[cacheKey]))) 00052 { 00053 result = recordingPathCache[cacheKey]; 00054 if (!storePath) 00055 recordingPathCache.remove(cacheKey); 00056 } 00057 else 00058 { 00059 result = pginfo->GetPlaybackURL(false, true); 00060 if (storePath && result.left(1) == "/") 00061 recordingPathCache[cacheKey] = result; 00062 } 00063 00064 return result; 00065 } 00066 00067 /* vim: set expandtab tabstop=4 shiftwidth=4: */
1.6.3