summaryrefslogtreecommitdiffstats
path: root/kradio3/src/include/fileringbuffer.h
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-22 18:23:26 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-22 18:23:26 +0000
commitae364d9bed0589bf1a22cd5f530c563462379e3e (patch)
treee32727e2664e7ce68d0d30270afa040320ae35a1 /kradio3/src/include/fileringbuffer.h
downloadtderadio-ae364d9bed0589bf1a22cd5f530c563462379e3e.tar.gz
tderadio-ae364d9bed0589bf1a22cd5f530c563462379e3e.zip
Added old KDE3 version of kradio
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kradio@1094417 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kradio3/src/include/fileringbuffer.h')
-rw-r--r--kradio3/src/include/fileringbuffer.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/kradio3/src/include/fileringbuffer.h b/kradio3/src/include/fileringbuffer.h
new file mode 100644
index 0000000..3447277
--- /dev/null
+++ b/kradio3/src/include/fileringbuffer.h
@@ -0,0 +1,71 @@
+/***************************************************************************
+ ringbuffer.h - description
+ -------------------
+ begin : Sun March 21 2004
+ copyright : (C) 2004 by Martin Witte
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef _KRADIO_FILE_RING_BUFFER_H
+#define _KRADIO_FILE_RING_BUFFER_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qstring.h>
+#include <stdio.h>
+
+class FileRingBuffer
+{
+public:
+ FileRingBuffer(const QString &filename, Q_UINT64 max_size);
+ ~FileRingBuffer();
+
+ bool resize(const QString &filename, Q_UINT64 new_max_size);
+
+ size_t addData (const char *src, size_t size);
+ size_t takeData(char *dst, size_t size);
+ Q_UINT64 removeData(Q_UINT64 size);
+
+ const QString &getFileName () const { return m_FileName; }
+ Q_UINT64 getMaxSize() const { return m_MaxSize; }
+ Q_UINT64 getRealSize() const { return m_RealSize; }
+ Q_UINT64 getFillSize() const { return m_FillSize; }
+ Q_UINT64 getFreeSize() const { return (m_Start + m_FillSize > m_RealSize) ? m_RealSize - m_FillSize : m_MaxSize - m_FillSize; }
+
+ void clear();
+
+ bool error() const { return m_error; }
+ const QString &errorString() const { return m_errorString; }
+
+protected:
+ Q_UINT64 getFreeSpace(Q_UINT64 &size); // returns position in file + size
+ Q_UINT64 removeFreeSpace(Q_UINT64 size);
+
+ Q_UINT64 getData(Q_UINT64 &size); // returns position in file + size
+
+
+ int m_FileIdx;
+ QString m_BaseFileName;
+ QString m_FileName;
+ FILE *m_File;
+ Q_UINT64 m_Start;
+ Q_UINT64 m_MaxSize;
+ Q_UINT64 m_RealSize;
+ Q_UINT64 m_FillSize;
+
+ QString m_errorString;
+ bool m_error;
+};
+
+#endif