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
00193 bool isValid() const;
00194
00201 void seek(long offset, Position p = Beginning);
00202
00206 void clear();
00207
00211 long tell() const;
00212
00216 long length();
00217
00224 static bool isReadable(const char *file);
00225
00231 static bool isWritable(const char *name);
00232
00233 protected:
00241 File(FileName file);
00242
00248 void setValid(bool valid);
00249
00253 void truncate(long length);
00254
00258 static uint bufferSize();
00259
00260 private:
00261 File(const File &);
00262 File &operator=(const File &);
00263
00264 class FilePrivate;
00265 FilePrivate *d;
00266 };
00267
00268 }
00269
00270 #endif