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 
91  PropertyMap properties() const;
92 
99  void removeUnsupportedProperties(const StringList& properties);
100 
110  PropertyMap setProperties(const PropertyMap &properties);
116  virtual AudioProperties *audioProperties() const = 0;
117 
128  virtual bool save() = 0;
129 
133  ByteVector readBlock(ulong length);
134 
144  void writeBlock(const ByteVector &data);
145 
158  long find(const ByteVector &pattern,
159  long fromOffset = 0,
160  const ByteVector &before = ByteVector::null);
161 
174  long rfind(const ByteVector &pattern,
175  long fromOffset = 0,
176  const ByteVector &before = ByteVector::null);
177 
185  void insert(const ByteVector &data, ulong start = 0, ulong replace = 0);
186 
194  void removeBlock(ulong start = 0, ulong length = 0);
195 
199  bool readOnly() const;
200 
205  bool isOpen() const;
206 
210  bool isValid() const;
211 
218  void seek(long offset, Position p = Beginning);
219 
223  void clear();
224 
228  long tell() const;
229 
233  long length();
234 
241  static bool isReadable(const char *file);
242 
248  static bool isWritable(const char *name);
249 
250  protected:
258  File(FileName file);
259 
269  File(IOStream *stream);
270 
276  void setValid(bool valid);
277 
281  void truncate(long length);
282 
286  static uint bufferSize();
287 
288  private:
289  File(const File &);
290  File &operator=(const File &);
291 
292  class FilePrivate;
293  FilePrivate *d;
294  };
295 
296 }
297 
298 #endif