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 
00093     PropertyMap properties() const;
00094 
00101     void removeUnsupportedProperties(const StringList& properties);
00102 
00117     PropertyMap setProperties(const PropertyMap &properties);
00118 
00124     virtual AudioProperties *audioProperties() const = 0;
00125 
00136     virtual bool save() = 0;
00137 
00141     ByteVector readBlock(unsigned long length);
00142 
00152     void writeBlock(const ByteVector &data);
00153 
00166     long find(const ByteVector &pattern,
00167               long fromOffset = 0,
00168               const ByteVector &before = ByteVector());
00169 
00182     long rfind(const ByteVector &pattern,
00183                long fromOffset = 0,
00184                const ByteVector &before = ByteVector());
00185 
00193     void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0);
00194 
00202     void removeBlock(unsigned long start = 0, unsigned long length = 0);
00203 
00207     bool readOnly() const;
00208 
00213     bool isOpen() const;
00214 
00218     bool isValid() const;
00219 
00226     void seek(long offset, Position p = Beginning);
00227 
00231     void clear();
00232 
00236     long tell() const;
00237 
00241     long length();
00242 
00249     static bool isReadable(const char *file);
00250 
00256     static bool isWritable(const char *name);
00257 
00258   protected:
00266     File(FileName file);
00267 
00277     File(IOStream *stream);
00278 
00284     void setValid(bool valid);
00285 
00289     void truncate(long length);
00290 
00294     static unsigned int bufferSize();
00295 
00296   private:
00297     File(const File &);
00298     File &operator=(const File &);
00299 
00300     class FilePrivate;
00301     FilePrivate *d;
00302   };
00303 
00304 }
00305 
00306 #endif