MythTV
master
|
#include <libmythbase/remotefile.h>
Public Member Functions | |
RemoteFile (QString url="", bool write=false, bool usereadahead=true, std::chrono::milliseconds timeout=2s, const QStringList *possibleAuxiliaryFiles=nullptr) | |
~RemoteFile () | |
bool | ReOpen (const QString &newFilename) |
long long | Seek (long long pos, int whence, long long curpos=-1) |
QDateTime | LastModified (void) const |
int | Write (const void *data, int size) |
int | Read (void *data, int size) |
void | Reset (void) |
bool | SetBlocking (bool m_block=true) |
Set write blocking mode for the ThreadedFileWriter instance. More... | |
bool | SaveAs (QByteArray &data) |
void | SetTimeout (bool fast) |
bool | isOpen (void) const |
bool | isLocal (void) const |
long long | GetFileSize (void) const |
GetFileSize: returns the remote file's size at the time it was first opened Will query the server in order to get the size. More... | |
long long | GetRealFileSize (void) |
GetRealFileSize: returns the current remote file's size. More... | |
QStringList | GetAuxiliaryFiles (void) const |
Static Public Member Functions | |
static bool | DeleteFile (const QString &url) |
static bool | Exists (const QString &url, struct stat *fileinfo) |
static bool | Exists (const QString &url) |
static QString | GetFileHash (const QString &url) |
static QDateTime | LastModified (const QString &url) |
static QString | FindFile (const QString &filename, const QString &host, const QString &storageGroup, bool useRegex=false, bool allowFallback=false) |
Search all BE's for a file in the give storage group. More... | |
static QStringList | FindFileList (const QString &filename, const QString &host, const QString &storageGroup, bool useRegex=false, bool allowFallback=false) |
Search all BE's for files in the give storage group. More... | |
static bool | CopyFile (const QString &src, const QString &dst, bool overwrite=false, bool verify=false) |
static bool | MoveFile (const QString &src, const QString &dst, bool overwrite=false) |
static bool | isLocal (const QString &path) |
Private Member Functions | |
bool | Open (void) |
bool | OpenInternal (void) |
Attempts to resume from a disconnected step. More... | |
void | Close (bool haslock=false) |
bool | CheckConnection (bool repos=true) |
Check current connection and re-establish it if lost. More... | |
bool | IsConnected (void) |
Check if both the control and data sockets are currently connected. More... | |
bool | Resume (bool repos=true) |
Attempts to resume from a disconnected step. More... | |
long long | SeekInternal (long long pos, int whence, long long curpos=-1) |
MythSocket * | openSocket (bool control) |
Private Attributes | |
QString | m_path |
bool | m_useReadAhead {true} |
std::chrono::milliseconds | m_timeoutMs {2s} |
long long | m_fileSize {-1} |
bool | m_timeoutIsFast {false} |
long long | m_readPosition {0LL} |
long long | m_lastPosition {0LL} |
bool | m_canResume {false} |
int | m_recorderNum {0} |
QMutex | m_lock |
MythSocket * | m_controlSock {nullptr} |
MythSocket * | m_sock {nullptr} |
QString | m_query {"QUERY_FILETRANSFER %1"} |
bool | m_writeMode {false} |
bool | m_completed {false} |
MythTimer | m_lastSizeCheck |
QStringList | m_possibleAuxFiles |
QStringList | m_auxFiles |
int | m_localFile {-1} |
ThreadedFileWriter * | m_fileWriter {nullptr} |
Definition at line 17 of file remotefile.h.
|
explicit |
Definition at line 68 of file remotefile.cpp.
RemoteFile::~RemoteFile | ( | ) |
Definition at line 91 of file remotefile.cpp.
bool RemoteFile::ReOpen | ( | const QString & | newFilename | ) |
Definition at line 338 of file remotefile.cpp.
Referenced by MythFileBuffer::ReOpen().
long long RemoteFile::Seek | ( | long long | pos, |
int | whence, | ||
long long | curpos = -1 |
||
) |
Definition at line 758 of file remotefile.cpp.
Referenced by ArchiveRemoteAVFormatContext::Open(), RemoteAVFormatContext::Open(), MythMediaBuffer::ReadDirect(), MythFileBuffer::SafeRead(), and MythFileBuffer::SeekInternal().
|
static |
Definition at line 417 of file remotefile.cpp.
Referenced by CopyFile(), ThemeChooser::customEvent(), Ripper::deleteExistingTrack(), VideoMetadataImp::DeleteFile(), NetBase::DoDeleteVideo(), MoveFile(), MetadataImageDownload::run(), and transUnlink().
|
static |
Definition at line 460 of file remotefile.cpp.
Referenced by ThemeUpdateChecker::checkForUpdate(), CheckRecordings(), CopyFile(), MythMediaBuffer::Create(), discover_program_info_type(), NetBase::DoDownloadAndPlay(), Exists(), V2Content::GetAlbumArt(), MusicMetadata::getAlbumArtFile(), GetFileSize(), getNameWithExtension(), GetRealFileSize(), MoveFile(), MythFileExists(), MythFileStat(), OpenInternal(), MetadataImageDownload::run(), VideoMetadataImp::saveToDatabase(), NetSearch::ShowMenu(), VideoSetupWizard::testHDVideo(), VideoSetupWizard::testSDVideo(), and VideoSelector::titleChanged().
|
static |
Definition at line 451 of file remotefile.cpp.
|
static |
Definition at line 552 of file remotefile.cpp.
Referenced by UpdateHashes(), and VideoMetadata::VideoFileHash().
|
static |
Definition at line 1233 of file remotefile.cpp.
QDateTime RemoteFile::LastModified | ( | void | ) | const |
Definition at line 1271 of file remotefile.cpp.
Referenced by MythUIThemeCache::LoadCacheImage().
|
static |
Search all BE's for a file in the give storage group.
filename | the partial path and filename to look for |
host | search this host first if given or default to the master BE if empty |
storageGroup | the name of the storage group to search |
useRegex | if true filename is assumed to be a regex expression of files to find |
allowFallback | if false only 'host' will be searched otherwise all host will be searched until a match is found |
Definition at line 1285 of file remotefile.cpp.
Referenced by MusicMetadata::Filename(), MythImage::Load(), and ImportCoverArtDialog::updateStatus().
|
static |
Search all BE's for files in the give storage group.
filename | the partial path and filename to look for or regular espression (QRegularExpression) |
host | search this host first if given or default to the master BE if empty |
storageGroup | the name of the storage group to search |
useRegex | if true filename is assumed to be a regex expression of files to find |
allowFallback | if false only 'host' will be searched otherwise all host will be searched until a match is found |
Definition at line 1306 of file remotefile.cpp.
Referenced by FindFile(), and findIcon().
|
static |
Definition at line 586 of file remotefile.cpp.
Referenced by ImportCoverArtDialog::copyPressed(), EditAlbumartDialog::doCopyImageToTag(), MoveFile(), FileCopyThread::run(), CDRipperThread::run(), and TransferThread::run().
|
static |
Definition at line 676 of file remotefile.cpp.
Referenced by TransferThread::run().
int RemoteFile::Write | ( | const void * | data, |
int | size | ||
) |
Definition at line 835 of file remotefile.cpp.
Referenced by CopyFile(), MetadataImageDownload::run(), and MythMediaBuffer::Write().
int RemoteFile::Read | ( | void * | data, |
int | size | ||
) |
Definition at line 937 of file remotefile.cpp.
Referenced by CopyFile(), ArchiveRemoteAVFormatContext::Open(), RemoteAVFormatContext::Open(), RemoteFileWrapper::Read(), ArchiveRemoteAVFormatContext::ReadFunc(), RemoteAVFormatContext::ReadFunc(), MythFileBuffer::SafeRead(), and SaveAs().
void RemoteFile::Reset | ( | void | ) |
Definition at line 745 of file remotefile.cpp.
Set write blocking mode for the ThreadedFileWriter instance.
block | false if not blocking, true if blocking |
Definition at line 1392 of file remotefile.cpp.
Referenced by CopyFile(), and OpenInternal().
bool RemoteFile::SaveAs | ( | QByteArray & | data | ) |
Definition at line 1183 of file remotefile.cpp.
Referenced by V2Content::GetAlbumArt().
void RemoteFile::SetTimeout | ( | bool | fast | ) |
Definition at line 1196 of file remotefile.cpp.
bool RemoteFile::isOpen | ( | void | ) | const |
Definition at line 244 of file remotefile.cpp.
Referenced by CopyFile(), GetFileSize(), ArchiveRemoteAVFormatContext::isOpen(), RemoteFileWrapper::isOpen(), MythFileBuffer::MythFileBuffer(), ArchiveRemoteAVFormatContext::Open(), RemoteAVFormatContext::Open(), Open(), MythFileBuffer::OpenFile(), Read(), ReOpen(), MetadataImageDownload::run(), SeekInternal(), and Write().
|
static |
Definition at line 106 of file remotefile.cpp.
bool RemoteFile::isLocal | ( | void | ) | const |
Definition at line 114 of file remotefile.cpp.
Referenced by Close(), DeleteFile(), Exists(), GetFileHash(), GetFileSize(), GetRealFileSize(), isOpen(), LastModified(), MoveFile(), OpenInternal(), Read(), ReOpen(), Reset(), SeekInternal(), SetTimeout(), and Write().
long long RemoteFile::GetFileSize | ( | void | ) | const |
GetFileSize: returns the remote file's size at the time it was first opened Will query the server in order to get the size.
If file isn't being modified by the server, that value will be cached
Definition at line 1094 of file remotefile.cpp.
Referenced by CheckRecordings(), CopyFile(), RemoteFileWrapper::GetFileSize(), GetFileSize(), GetRealFileSize(), ArchiveRemoteAVFormatContext::SeekFunc(), RemoteAVFormatContext::SeekFunc(), and MythFileBuffer::SeekInternal().
long long RemoteFile::GetRealFileSize | ( | void | ) |
GetRealFileSize: returns the current remote file's size.
Will query the server in order to get the size. If file isn't being modified by the server, that value will be cached. A QUERY_SIZE myth request will be made. If the server doesn't support this command the size will be queried using a QUERY_FILE_EXISTS request Avoid using GetRealFileSize from the GUI thread
Definition at line 1122 of file remotefile.cpp.
Referenced by MythFileBuffer::GetRealFileSizeInternal(), and SaveAs().
|
inline |
Definition at line 64 of file remotefile.h.
Referenced by MythFileBuffer::OpenFile().
|
private |
Definition at line 253 of file remotefile.cpp.
Referenced by RemoteFile(), and ReOpen().
|
private |
Attempts to resume from a disconnected step.
Must have lock
Definition at line 266 of file remotefile.cpp.
Definition at line 373 of file remotefile.cpp.
Referenced by CopyFile(), OpenInternal(), ReOpen(), Resume(), and ~RemoteFile().
Check current connection and re-establish it if lost.
repos | Bool indicating if we are to reposition to the last known location if reconnection is required |
Definition at line 1407 of file remotefile.cpp.
Referenced by GetRealFileSize(), Read(), ReOpen(), SeekInternal(), SetTimeout(), and Write().
|
private |
Check if both the control and data sockets are currently connected.
Definition at line 1424 of file remotefile.cpp.
Referenced by CheckConnection().
Attempts to resume from a disconnected step.
Must have lock
repos | Bool indicating if we are to reposition to the last known location |
Definition at line 1435 of file remotefile.cpp.
Referenced by CheckConnection(), and Read().
|
private |
Definition at line 765 of file remotefile.cpp.
|
private |
Definition at line 119 of file remotefile.cpp.
Referenced by OpenInternal().
|
private |
Definition at line 78 of file remotefile.h.
Referenced by GetFileSize(), GetRealFileSize(), isLocal(), LastModified(), OpenInternal(), openSocket(), RemoteFile(), ReOpen(), and SeekInternal().
Definition at line 79 of file remotefile.h.
Referenced by openSocket(), and RemoteFile().
|
private |
Definition at line 80 of file remotefile.h.
Referenced by openSocket(), and RemoteFile().
|
private |
Definition at line 81 of file remotefile.h.
Referenced by GetFileSize(), GetRealFileSize(), and openSocket().
Definition at line 82 of file remotefile.h.
Referenced by SetTimeout().
|
private |
Definition at line 83 of file remotefile.h.
Referenced by Resume(), and SeekInternal().
|
private |
Definition at line 84 of file remotefile.h.
Referenced by Read(), Resume(), SeekInternal(), and Write().
Definition at line 85 of file remotefile.h.
Referenced by CheckConnection(), and OpenInternal().
|
private |
Definition at line 86 of file remotefile.h.
Referenced by Close(), GetRealFileSize(), openSocket(), Read(), ReOpen(), SeekInternal(), SetTimeout(), and Write().
|
mutableprivate |
Definition at line 88 of file remotefile.h.
Referenced by Close(), GetFileSize(), GetRealFileSize(), Open(), Read(), ReOpen(), Reset(), Seek(), SetTimeout(), and Write().
|
private |
Definition at line 89 of file remotefile.h.
Referenced by Close(), GetRealFileSize(), IsConnected(), isOpen(), OpenInternal(), Read(), ReOpen(), SeekInternal(), SetTimeout(), Write(), and ~RemoteFile().
|
private |
Definition at line 90 of file remotefile.h.
Referenced by Close(), IsConnected(), isOpen(), OpenInternal(), Read(), Reset(), SeekInternal(), Write(), and ~RemoteFile().
|
private |
Definition at line 91 of file remotefile.h.
Referenced by Close(), GetRealFileSize(), Read(), ReOpen(), SeekInternal(), SetTimeout(), and Write().
Definition at line 93 of file remotefile.h.
Referenced by GetFileSize(), isOpen(), OpenInternal(), openSocket(), Read(), RemoteFile(), SeekInternal(), and Write().
Definition at line 94 of file remotefile.h.
Referenced by GetRealFileSize().
|
private |
Definition at line 95 of file remotefile.h.
Referenced by GetRealFileSize().
|
private |
Definition at line 97 of file remotefile.h.
Referenced by openSocket(), and RemoteFile().
|
private |
Definition at line 98 of file remotefile.h.
Referenced by openSocket().
|
private |
Definition at line 99 of file remotefile.h.
Referenced by Close(), isOpen(), OpenInternal(), Read(), and SeekInternal().
|
private |
Definition at line 100 of file remotefile.h.
Referenced by Close(), GetFileSize(), isOpen(), OpenInternal(), SeekInternal(), SetBlocking(), and Write().