tfile.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef TAGLIB_FILE_H
00027 #define TAGLIB_FILE_H
00028
00029 #include "taglib_export.h"
00030 #include "taglib.h"
00031 #include "tbytevector.h"
00032
00033 namespace TagLib {
00034
00035 class String;
00036 class Tag;
00037 class AudioProperties;
00038
00039 #ifdef _WIN32
00040 class TAGLIB_EXPORT FileName
00041 {
00042 public:
00043 FileName(const wchar_t *name) : m_wname(name) {}
00044 FileName(const char *name) : m_name(name) {}
00045 operator const wchar_t *() const { return m_wname.c_str(); }
00046 operator const char *() const { return m_name.c_str(); }
00047 private:
00048 std::string m_name;
00049 std::wstring m_wname;
00050 };
00051 #else
00052 typedef const char *FileName;
00053 #endif
00054
00056
00063 class TAGLIB_EXPORT File
00064 {
00065 public:
00069 enum Position {
00071 Beginning,
00073 Current,
00075 End
00076 };
00077
00081 virtual ~File();
00082
00086 FileName name() const;
00087
00092 virtual Tag *tag() const = 0;
00093
00099 virtual AudioProperties *audioProperties() const = 0;
00100
00111 virtual bool save() = 0;
00112
00116 ByteVector readBlock(ulong length);
00117
00127 void writeBlock(const ByteVector &data);
00128
00141 long find(const ByteVector &pattern,
00142 long fromOffset = 0,
00143 const ByteVector &before = ByteVector::null);
00144
00157 long rfind(const ByteVector &pattern,
00158 long fromOffset = 0,
00159 const ByteVector &before = ByteVector::null);
00160
00168 void insert(const ByteVector &data, ulong start = 0, ulong replace = 0);
00169
00177 void removeBlock(ulong start = 0, ulong length = 0);
00178
00182 bool readOnly() const;
00183
00188 bool isOpen() const;
00189
00194 bool isValid() const;
00195
00202 void seek(long offset, Position p = Beginning);
00203
00207 void clear();
00208
00212 long tell() const;
00213
00217 long length();
00218
00225 static bool isReadable(const char *file);
00226
00232 static bool isWritable(const char *name);
00233
00234 protected:
00242 File(FileName file);
00243
00249 void setValid(bool valid);
00250
00254 void truncate(long length);
00255
00259 static uint bufferSize();
00260
00261 private:
00262 File(const File &);
00263 File &operator=(const File &);
00264
00265 class FilePrivate;
00266 FilePrivate *d;
00267 };
00268
00269 }
00270
00271 #endif