/
remotefile.h
75 lines (55 loc) · 1.76 KB
/
remotefile.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef REMOTEFILE_H_
#define REMOTEFILE_H_
#include <sys/stat.h>
#include <QDateTime>
#include <QStringList>
#include <QMutex>
#include "mythbaseexp.h"
class MythSocket;
class MBASE_PUBLIC RemoteFile
{
public:
RemoteFile(const QString &url = "",
bool write = false,
bool usereadahead = true,
int timeout_ms = 2000/*RingBuffer::kDefaultOpenTimeout*/,
const QStringList *possibleAuxiliaryFiles = NULL);
~RemoteFile();
bool ReOpen(QString newFilename);
long long Seek(long long pos, int whence, long long curpos = -1);
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);
int Write(const void *data, int size);
int Read(void *data, int size);
void Reset(void);
bool SaveAs(QByteArray &data);
void SetTimeout(bool fast);
bool isOpen(void) const
{ return sock && controlSock; }
long long GetFileSize(void) const
{ return filesize; }
QStringList GetAuxiliaryFiles(void) const
{ return auxfiles; }
private:
bool Open();
void Close(void);
MythSocket *openSocket(bool control);
QString path;
bool usereadahead;
int timeout_ms;
long long filesize;
bool timeoutisfast;
long long readposition;
int recordernum;
mutable QMutex lock;
MythSocket *controlSock;
MythSocket *sock;
QString query;
bool writemode;
QStringList possibleauxfiles;
QStringList auxfiles;
};
#endif