annotate data/fileio/CachedFile.h @ 1310:aa1b1fc2d018 mp3-gapless

Stop reporting sync errors only when we really are at eof, i.e. after the input callback has been called again (previously we just tested whether we'd buffered up all the input, which of course we do in one go at the start)
author Chris Cannam
date Tue, 29 Nov 2016 16:45:29 +0000
parents b99dc5465b80
children ad5f892c0c4d
rev   line source
Chris@465 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@465 2
Chris@465 3 /*
Chris@465 4 Sonic Visualiser
Chris@465 5 An audio file viewer and annotation editor.
Chris@465 6 Centre for Digital Music, Queen Mary, University of London.
Chris@465 7 This file copyright 2008 QMUL.
Chris@465 8
Chris@465 9 This program is free software; you can redistribute it and/or
Chris@465 10 modify it under the terms of the GNU General Public License as
Chris@465 11 published by the Free Software Foundation; either version 2 of the
Chris@465 12 License, or (at your option) any later version. See the file
Chris@465 13 COPYING included with this distribution for more information.
Chris@465 14 */
Chris@465 15
Chris@465 16 #ifndef _CACHED_FILE_H_
Chris@465 17 #define _CACHED_FILE_H_
Chris@465 18
Chris@465 19 #include <QString>
Chris@465 20 #include <QUrl>
Chris@465 21 #include <QDateTime>
Chris@481 22 #include <map>
Chris@465 23
Chris@465 24 class ProgressReporter;
Chris@465 25
Chris@465 26 class CachedFile
Chris@465 27 {
Chris@465 28 public:
Chris@520 29 CachedFile(QString fileOrUrl,
Chris@520 30 ProgressReporter *reporter = 0,
Chris@520 31 QString preferredContentType = "");
Chris@520 32 CachedFile(QUrl url,
Chris@520 33 ProgressReporter *reporter = 0,
Chris@520 34 QString preferredContentType = "");
Chris@465 35
Chris@465 36 virtual ~CachedFile();
Chris@465 37
Chris@465 38 bool isOK() const;
Chris@465 39
Chris@465 40 QString getLocalFilename() const;
Chris@465 41
Chris@465 42 protected:
Chris@468 43 QString m_origin;
Chris@465 44 QString m_localFilename;
Chris@520 45 QString m_preferredContentType;
Chris@466 46 ProgressReporter *m_reporter;
Chris@465 47 bool m_ok;
Chris@465 48
Chris@691 49 void checkFile();
Chris@465 50 bool retrieve();
Chris@465 51
Chris@465 52 QDateTime getLastRetrieval();
Chris@465 53 void updateLastRetrieval(bool successful);
Chris@465 54
Chris@465 55 static QString getCacheDirectory();
Chris@465 56 static QString getLocalFilenameFor(QUrl url);
Chris@481 57
Chris@481 58 typedef std::map<QString, QString> OriginLocalFilenameMap;
Chris@481 59 static OriginLocalFilenameMap m_knownGoodCaches;
Chris@465 60 };
Chris@465 61
Chris@465 62 #endif