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 
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 
93  PropertyMap properties() const;
94 
101  void removeUnsupportedProperties(const StringList& properties);
102 
117  PropertyMap setProperties(const PropertyMap &properties);
118 
124  virtual AudioProperties *audioProperties() const = 0;
125 
136  virtual bool save() = 0;
137 
141  ByteVector readBlock(ulong length);
142 
152  void writeBlock(const ByteVector &data);
153 
166  long find(const ByteVector &pattern,
167  long fromOffset = 0,
168  const ByteVector &before = ByteVector::null);
169 
182  long rfind(const ByteVector &pattern,
183  long fromOffset = 0,
184  const ByteVector &before = ByteVector::null);
185 
193  void insert(const ByteVector &data, ulong start = 0, ulong replace = 0);
194 
202  void removeBlock(ulong start = 0, ulong 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:
266  File(FileName file);
267 
277  File(IOStream *stream);
278 
284  void setValid(bool valid);
285 
289  void truncate(long length);
290 
294  static uint 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
static ByteVector null
Definition: tbytevector.h:397
unsigned int uint
Definition: taglib.h:83
A map for format-independent <key,valuelist> tag representations.
Definition: tpropertymap.h:104
An abstract class that provides operations on a sequence of bytes.
Definition: tiostream.h:53
Definition: tag.h:46
A file class with some useful methods for tag manipulation.
Definition: tfile.h:50
Position
Definition: tfile.h:56
Seek from the beginning of the file.
Definition: tfile.h:58
A byte vector.
Definition: tbytevector.h:45
unsigned long ulong
Definition: taglib.h:84
A list of strings.
Definition: tstringlist.h:45
#define TAGLIB_EXPORT
Definition: taglib_export.h:40
Seek from the current position in the file.
Definition: tfile.h:60
A simple, abstract interface to common audio properties.
Definition: audioproperties.h:42
const char * FileName
Definition: tiostream.h:48