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 
35 namespace TagLib {
36 
37  class String;
38  class Tag;
39  class AudioProperties;
40  class PropertyMap;
41 
43 
50  class TAGLIB_EXPORT File
51  {
52  public:
56  enum Position {
58  Beginning,
60  Current,
62  End
63  };
64 
68  enum StripTags {
69  StripNone, //<! Don't strip any tags
70  StripAll, //<! Strip all tags
71  StripOthers //<! Strip all tags not explicitly referenced in method call
72  };
73 
78  enum DuplicateTags {
79  Duplicate, //<! Syncronize values between different tag types
80  DoNotDuplicate //<! Do not syncronize values between different tag types
81  };
82 
86  virtual ~File();
87 
91  FileName name() const;
92 
97  virtual Tag *tag() const = 0;
98 
111  PropertyMap properties() const;
112 
119  void removeUnsupportedProperties(const StringList& properties);
120 
135  PropertyMap setProperties(const PropertyMap &properties);
136 
142  virtual AudioProperties *audioProperties() const = 0;
143 
154  virtual bool save() = 0;
155 
159  ByteVector readBlock(unsigned long length);
160 
170  void writeBlock(const ByteVector &data);
171 
184  long find(const ByteVector &pattern,
185  long fromOffset = 0,
186  const ByteVector &before = ByteVector());
187 
200  long rfind(const ByteVector &pattern,
201  long fromOffset = 0,
202  const ByteVector &before = ByteVector());
203 
211  void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0);
212 
220  void removeBlock(unsigned long start = 0, unsigned long length = 0);
221 
225  bool readOnly() const;
226 
231  bool isOpen() const;
232 
236  bool isValid() const;
237 
244  void seek(long offset, Position p = Beginning);
245 
249  void clear();
250 
254  long tell() const;
255 
259  long length();
260 
267  TAGLIB_DEPRECATED static bool isReadable(const char *file);
268 
274  TAGLIB_DEPRECATED static bool isWritable(const char *name);
275 
276  protected:
284  File(FileName file);
285 
295  File(IOStream *stream);
296 
302  void setValid(bool valid);
303 
307  void truncate(long length);
308 
312  static unsigned int bufferSize();
313 
314  private:
315  File(const File &);
316  File &operator=(const File &);
317 
318  class FilePrivate;
319  FilePrivate *d;
320  };
321 
322 }
323 
324 #endif
A list of strings.
Definition: tstringlist.h:66
A namespace for all TagLib related classes and functions.
Definition: apefile.h:41
Definition: tag.h:67
#define TAGLIB_DEPRECATED
Definition: taglib.h:54
A map for format-independent <key,valuelist> tag representations.
Definition: tpropertymap.h:129
Position
Definition: tfile.h:77
const typedef char * FileName
Definition: tiostream.h:78
A byte vector.
Definition: tbytevector.h:66
#define TAGLIB_EXPORT
Definition: taglib_export.h:40
A file class with some useful methods for tag manipulation.
Definition: tfile.h:71
A simple, abstract interface to common audio properties.
Definition: audioproperties.h:63
An abstract class that provides operations on a sequence of bytes.
Definition: tiostream.h:83