tfilestream.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_FILESTREAM_H
00027 #define TAGLIB_FILESTREAM_H
00028 
00029 #include "taglib_export.h"
00030 #include "taglib.h"
00031 #include "tbytevector.h"
00032 #include "tiostream.h"
00033 
00034 namespace TagLib {
00035 
00036   class String;
00037   class Tag;
00038   class AudioProperties;
00039 
00041 
00048   class TAGLIB_EXPORT FileStream : public IOStream
00049   {
00050   public:
00055     FileStream(FileName file, bool openReadOnly = false);
00056 
00060     virtual ~FileStream();
00061 
00065     FileName name() const;
00066 
00070     ByteVector readBlock(unsigned long length);
00071 
00081     void writeBlock(const ByteVector &data);
00082 
00090     void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0);
00091 
00099     void removeBlock(unsigned long start = 0, unsigned long length = 0);
00100 
00104     bool readOnly() const;
00105 
00110     bool isOpen() const;
00111 
00118     void seek(long offset, Position p = Beginning);
00119 
00123     void clear();
00124 
00128     long tell() const;
00129 
00133     long length();
00134 
00138     void truncate(long length);
00139 
00140   protected:
00141 
00145     static unsigned int bufferSize();
00146 
00147   private:
00148     class FileStreamPrivate;
00149     FileStreamPrivate *d;
00150   };
00151 
00152 }
00153 
00154 #endif