MythTV  master
remotefile.h
Go to the documentation of this file.
1 #ifndef REMOTEFILE_H_
2 #define REMOTEFILE_H_
3 
4 #include <sys/stat.h>
5 
6 #include <QDateTime>
7 #include <QStringList>
8 #include <QMutex>
9 
10 #include "mythbaseexp.h"
11 #include "mythtimer.h"
12 
13 class MythSocket;
14 class QFile;
15 class ThreadedFileWriter;
16 
18 {
19  public:
20  RemoteFile(const QString &url = "",
21  bool write = false,
22  bool usereadahead = true,
23  int timeout_ms = 2000/*RingBuffer::kDefaultOpenTimeout*/,
24  const QStringList *possibleAuxiliaryFiles = nullptr);
25  ~RemoteFile();
26 
27  bool ReOpen(QString newFilename);
28 
29  long long Seek(long long pos, int whence, long long curpos = -1);
30 
31  static bool DeleteFile(const QString &url);
32  static bool Exists(const QString &url, struct stat *fileinfo);
33  static bool Exists(const QString &url);
34  static QString GetFileHash(const QString &url);
35  static QDateTime LastModified(const QString &url);
36  QDateTime LastModified(void) const;
37  static QString FindFile(const QString &filename, const QString &host,
38  const QString &storageGroup, bool useRegex = false,
39  bool allowFallback = false);
40 
41  static QStringList FindFileList(const QString &filename, const QString &host,
42  const QString &storageGroup, bool useRegex = false,
43  bool allowFallback = false);
44  static bool CopyFile(const QString &src, const QString &dest,
45  bool overwrite = false, bool verify = false);
46  static bool MoveFile(const QString &src, const QString &dest,
47  bool overwrite = false);
48 
49  int Write(const void *data, int size);
50  int Read(void *data, int size);
51  void Reset(void);
52  bool SetBlocking(bool block = true);
53 
54  bool SaveAs(QByteArray &data);
55 
56  void SetTimeout(bool fast);
57 
58  bool isOpen(void) const;
59  static bool isLocal(const QString &path);
60  bool isLocal(void) const;
61  long long GetFileSize(void) const;
62  long long GetRealFileSize(void);
63 
64  QStringList GetAuxiliaryFiles(void) const
65  { return auxfiles; }
66 
67  private:
68  bool Open(void);
69  bool OpenInternal(void);
70  void Close(bool haslock = false);
71  bool CheckConnection(bool repos = true);
72  bool IsConnected(void);
73  bool Resume(bool repos = true);
74  long long SeekInternal(long long pos, int whence, long long curpos = -1);
75 
76  MythSocket *openSocket(bool control);
77 
78  QString path;
81  long long filesize;
83  long long readposition;
84  long long lastposition;
85  bool canresume;
87 
88  mutable QMutex lock;
91  QString query;
92 
93  bool writemode;
94  bool completed;
96 
97  QStringList possibleauxfiles;
98  QStringList auxfiles;
99  int localFile;
101 };
102 
103 #endif
long long filesize
Definition: remotefile.h:81
def write(text, progress=True)
Definition: mythburn.py:279
bool usereadahead
Definition: remotefile.h:79
A QElapsedTimer based timer to replace use of QTime as a timer.
Definition: mythtimer.h:13
long long readposition
Definition: remotefile.h:83
bool timeoutisfast
Definition: remotefile.h:82
bool completed
Definition: remotefile.h:94
int recordernum
Definition: remotefile.h:86
QMutex lock
Definition: remotefile.h:88
int localFile
Definition: remotefile.h:99
bool writemode
Definition: remotefile.h:93
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
long long lastposition
Definition: remotefile.h:84
static int CopyFile(const MythUtilCommandLineParser &cmdline)
Definition: fileutils.cpp:10
QStringList auxfiles
Definition: remotefile.h:98
MythSocket * controlSock
Definition: remotefile.h:89
bool canresume
Definition: remotefile.h:85
MythTimer lastSizeCheck
Definition: remotefile.h:95
MythSocket * sock
Definition: remotefile.h:90
ThreadedFileWriter * fileWriter
Definition: remotefile.h:100
QString query
Definition: remotefile.h:91
QString path
Definition: remotefile.h:78
This class supports the writing of recordings to disk.
Class for communcating between myth backends and frontends.
Definition: mythsocket.h:26
QStringList GetAuxiliaryFiles(void) const
Definition: remotefile.h:64
QStringList possibleauxfiles
Definition: remotefile.h:97
int timeout_ms
Definition: remotefile.h:80
static qint64 GetFileSize(ProgramInfo *program_info)