tfile.h
Go to the documentation of this file.
1/***************************************************************************
2 copyright : (C) 2002 - 2008 by Scott Wheeler
3 email : wheeler@kde.org
4 ***************************************************************************/
5
6/***************************************************************************
7 * This library is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU Lesser General Public License version *
9 * 2.1 as published by the Free Software Foundation. *
10 * *
11 * This library is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * Lesser General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with this library; if not, write to the Free Software *
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 * 02110-1301 USA *
20 * *
21 * Alternatively, this file is available under the Mozilla Public *
22 * License Version 1.1. You may obtain a copy of the License at *
23 * http://www.mozilla.org/MPL/ *
24 ***************************************************************************/
25
26#ifndef TAGLIB_FILE_H
27#define TAGLIB_FILE_H
28
29#include "taglib_export.h"
30#include "taglib.h"
31#include "tag.h"
32#include "tbytevector.h"
33#include "tiostream.h"
34
35namespace TagLib {
36
37 class String;
38 class Tag;
39 class AudioProperties;
40 class PropertyMap;
41
43
51 {
52 public:
56 enum Position {
62 End
63 };
64
68 virtual ~File();
69
73 FileName name() const;
74
79 virtual Tag *tag() const = 0;
80
94
102
118
124 virtual AudioProperties *audioProperties() const = 0;
125
136 virtual bool save() = 0;
137
141 ByteVector readBlock(unsigned long length);
142
152 void writeBlock(const ByteVector &data);
153
166 long find(const ByteVector &pattern,
167 long fromOffset = 0,
168 const ByteVector &before = ByteVector());
169
182 long rfind(const ByteVector &pattern,
183 long fromOffset = 0,
184 const ByteVector &before = ByteVector());
185
193 void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0);
194
202 void removeBlock(unsigned long start = 0, unsigned long length = 0);
203
207 bool readOnly() const;
208
213 bool isOpen() const;
214
218 bool isValid() const;
219
226 void seek(long offset, Position p = Beginning);
227
231 void clear();
232
236 long tell() const;
237
241 long length();
242
249 static bool isReadable(const char *file);
250
256 static bool isWritable(const char *name);
257
258 protected:
267
277 File(IOStream *stream);
278
284 void setValid(bool valid);
285
289 void truncate(long length);
290
294 static unsigned int bufferSize();
295
296 private:
297 File(const File &);
298 File &operator=(const File &);
299
300 class FilePrivate;
301 FilePrivate *d;
302 };
303
304}
305
306#endif
A simple, abstract interface to common audio properties.
Definition: audioproperties.h:43
A byte vector.
Definition: tbytevector.h:46
A file class with some useful methods for tag manipulation.
Definition: tfile.h:51
long tell() const
void seek(long offset, Position p=Beginning)
bool isOpen() const
void writeBlock(const ByteVector &data)
File(IOStream *stream)
File(FileName file)
static bool isWritable(const char *name)
void removeBlock(unsigned long start=0, unsigned long length=0)
virtual AudioProperties * audioProperties() const =0
bool readOnly() const
PropertyMap properties() const
Position
Definition: tfile.h:56
@ Current
Seek from the current position in the file.
Definition: tfile.h:60
@ Beginning
Seek from the beginning of the file.
Definition: tfile.h:58
long find(const ByteVector &pattern, long fromOffset=0, const ByteVector &before=ByteVector())
virtual ~File()
FileName name() const
long rfind(const ByteVector &pattern, long fromOffset=0, const ByteVector &before=ByteVector())
void removeUnsupportedProperties(const StringList &properties)
static bool isReadable(const char *file)
ByteVector readBlock(unsigned long length)
void setValid(bool valid)
bool isValid() const
virtual bool save()=0
void insert(const ByteVector &data, unsigned long start=0, unsigned long replace=0)
static unsigned int bufferSize()
void truncate(long length)
PropertyMap setProperties(const PropertyMap &properties)
virtual Tag * tag() const =0
An abstract class that provides operations on a sequence of bytes.
Definition: tiostream.h:63
A map for format-independent <key,valuelist> tag representations.
Definition: tpropertymap.h:109
A list of strings.
Definition: tstringlist.h:46
Definition: tag.h:47
A namespace for all TagLib related classes and functions.
Definition: apefile.h:41
const char * FileName
Definition: tiostream.h:57
#define TAGLIB_EXPORT
Definition: taglib_export.h:40