tfile.h
Go to the documentation of this file.
00001 /***************************************************************************
00002     copyright            : (C) 2002 - 2008 by Scott Wheeler
00003     email                : wheeler@kde.org
00004  ***************************************************************************/
00005 
00006 /***************************************************************************
00007  *   This library is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU Lesser General Public License version   *
00009  *   2.1 as published by the Free Software Foundation.                     *
00010  *                                                                         *
00011  *   This library is distributed in the hope that it will be useful, but   *
00012  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00014  *   Lesser General Public License for more details.                       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with this library; if not, write to the Free Software   *
00018  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA         *
00019  *   02110-1301  USA                                                       *
00020  *                                                                         *
00021  *   Alternatively, this file is available under the Mozilla Public        *
00022  *   License Version 1.1.  You may obtain a copy of the License at         *
00023  *   http://www.mozilla.org/MPL/                                           *
00024  ***************************************************************************/
00025 
00026 #ifndef TAGLIB_FILE_H
00027 #define TAGLIB_FILE_H
00028 
00029 #include "taglib_export.h"
00030 #include "taglib.h"
00031 #include "tag.h"
00032 #include "tbytevector.h"
00033 #include "tiostream.h"
00034 
00035 namespace TagLib {
00036 
00037   class String;
00038   class Tag;
00039   class AudioProperties;
00040   class PropertyMap;
00041 
00043 
00050   class TAGLIB_EXPORT File
00051   {
00052   public:
00056     enum Position {
00058       Beginning,
00060       Current,
00062       End
00063     };
00064 
00068     virtual ~File();
00069 
00073     FileName name() const;
00074 
00079     virtual Tag *tag() const = 0;
00080 
00091     PropertyMap properties() const;
00092 
00099     void removeUnsupportedProperties(const StringList& properties);
00100 
00110     PropertyMap setProperties(const PropertyMap &properties);
00116     virtual AudioProperties *audioProperties() const = 0;
00117 
00128     virtual bool save() = 0;
00129 
00133     ByteVector readBlock(ulong length);
00134 
00144     void writeBlock(const ByteVector &data);
00145 
00158     long find(const ByteVector &pattern,
00159               long fromOffset = 0,
00160               const ByteVector &before = ByteVector::null);
00161 
00174     long rfind(const ByteVector &pattern,
00175                long fromOffset = 0,
00176                const ByteVector &before = ByteVector::null);
00177 
00185     void insert(const ByteVector &data, ulong start = 0, ulong replace = 0);
00186 
00194     void removeBlock(ulong start = 0, ulong length = 0);
00195 
00199     bool readOnly() const;
00200 
00205     bool isOpen() const;
00206 
00210     bool isValid() const;
00211 
00218     void seek(long offset, Position p = Beginning);
00219 
00223     void clear();
00224 
00228     long tell() const;
00229 
00233     long length();
00234 
00241     static bool isReadable(const char *file);
00242 
00248     static bool isWritable(const char *name);
00249 
00250   protected:
00258     File(FileName file);
00259 
00269     File(IOStream *stream);
00270 
00276     void setValid(bool valid);
00277 
00281     void truncate(long length);
00282 
00286     static uint bufferSize();
00287 
00288   private:
00289     File(const File &);
00290     File &operator=(const File &);
00291 
00292     class FilePrivate;
00293     FilePrivate *d;
00294   };
00295 
00296 }
00297 
00298 #endif