rtaglib 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/History.txt +4 -0
  2. data/Manifest.txt +84 -9
  3. data/README.txt +0 -0
  4. data/Rakefile +30 -27
  5. data/{test/data → data}/440Hz-5sec.flac +0 -0
  6. data/{test/data → data}/440Hz-5sec.mp3 +0 -0
  7. data/{test/data → data}/440Hz-5sec.mpc +0 -0
  8. data/{test/data → data}/440Hz-5sec.ogg +0 -0
  9. data/{test/data → data}/440Hz-5sec.wv +0 -0
  10. data/data/test_jason.mp3 +0 -0
  11. data/data/test_jason.ogg +0 -0
  12. data/ext/Rakefile +10 -0
  13. data/ext/tagfile/Rakefile.rb +42 -0
  14. data/ext/tagfile/rake_ext_conf.rb +29 -0
  15. data/ext/tagfile/tagfile.c +11 -7
  16. data/ext/taglib/Rakefile.rb +48 -0
  17. data/ext/taglib/rake_ext_conf.rb +33 -0
  18. data/ext/taglib/taglib-mswin32/bin/tag.dll +0 -0
  19. data/ext/taglib/taglib-mswin32/bin/tag_c.dll +0 -0
  20. data/ext/taglib/taglib-mswin32/bin/tag_cd.dll +0 -0
  21. data/ext/taglib/taglib-mswin32/bin/tagd.dll +0 -0
  22. data/ext/taglib/taglib-mswin32/bin/taglib-config +55 -0
  23. data/ext/taglib/taglib-mswin32/include/taglib/apefooter.h +173 -0
  24. data/ext/taglib/taglib-mswin32/include/taglib/apeitem.h +204 -0
  25. data/ext/taglib/taglib-mswin32/include/taglib/apetag.h +162 -0
  26. data/ext/taglib/taglib-mswin32/include/taglib/attachedpictureframe.h +220 -0
  27. data/ext/taglib/taglib-mswin32/include/taglib/audioproperties.h +110 -0
  28. data/ext/taglib/taglib-mswin32/include/taglib/commentsframe.h +168 -0
  29. data/ext/taglib/taglib-mswin32/include/taglib/fileref.h +262 -0
  30. data/ext/taglib/taglib-mswin32/include/taglib/flacfile.h +201 -0
  31. data/ext/taglib/taglib-mswin32/include/taglib/flacproperties.h +92 -0
  32. data/ext/taglib/taglib-mswin32/include/taglib/generalencapsulatedobjectframe.h +174 -0
  33. data/ext/taglib/taglib-mswin32/include/taglib/id3v1genres.h +66 -0
  34. data/ext/taglib/taglib-mswin32/include/taglib/id3v1tag.h +180 -0
  35. data/ext/taglib/taglib-mswin32/include/taglib/id3v2extendedheader.h +93 -0
  36. data/ext/taglib/taglib-mswin32/include/taglib/id3v2footer.h +82 -0
  37. data/ext/taglib/taglib-mswin32/include/taglib/id3v2frame.h +414 -0
  38. data/ext/taglib/taglib-mswin32/include/taglib/id3v2framefactory.h +167 -0
  39. data/ext/taglib/taglib-mswin32/include/taglib/id3v2header.h +175 -0
  40. data/ext/taglib/taglib-mswin32/include/taglib/id3v2synchdata.h +70 -0
  41. data/ext/taglib/taglib-mswin32/include/taglib/id3v2tag.h +300 -0
  42. data/ext/taglib/taglib-mswin32/include/taglib/mpcfile.h +175 -0
  43. data/ext/taglib/taglib-mswin32/include/taglib/mpcproperties.h +85 -0
  44. data/ext/taglib/taglib-mswin32/include/taglib/mpegfile.h +277 -0
  45. data/ext/taglib/taglib-mswin32/include/taglib/mpegheader.h +166 -0
  46. data/ext/taglib/taglib-mswin32/include/taglib/mpegproperties.h +118 -0
  47. data/ext/taglib/taglib-mswin32/include/taglib/oggfile.h +112 -0
  48. data/ext/taglib/taglib-mswin32/include/taglib/oggflacfile.h +118 -0
  49. data/ext/taglib/taglib-mswin32/include/taglib/oggpage.h +203 -0
  50. data/ext/taglib/taglib-mswin32/include/taglib/oggpageheader.h +232 -0
  51. data/ext/taglib/taglib-mswin32/include/taglib/relativevolumeframe.h +274 -0
  52. data/ext/taglib/taglib-mswin32/include/taglib/speexfile.h +99 -0
  53. data/ext/taglib/taglib-mswin32/include/taglib/speexproperties.h +89 -0
  54. data/ext/taglib/taglib-mswin32/include/taglib/tag.h +173 -0
  55. data/ext/taglib/taglib-mswin32/include/taglib/tag_c.h +288 -0
  56. data/ext/taglib/taglib-mswin32/include/taglib/taglib.h +177 -0
  57. data/ext/taglib/taglib-mswin32/include/taglib/taglib_export.h +39 -0
  58. data/ext/taglib/taglib-mswin32/include/taglib/tbytevector.h +409 -0
  59. data/ext/taglib/taglib-mswin32/include/taglib/tbytevectorlist.h +91 -0
  60. data/ext/taglib/taglib-mswin32/include/taglib/textidentificationframe.h +258 -0
  61. data/ext/taglib/taglib-mswin32/include/taglib/tfile.h +271 -0
  62. data/ext/taglib/taglib-mswin32/include/taglib/tlist.h +252 -0
  63. data/ext/taglib/taglib-mswin32/include/taglib/tlist.tcc +316 -0
  64. data/ext/taglib/taglib-mswin32/include/taglib/tmap.h +200 -0
  65. data/ext/taglib/taglib-mswin32/include/taglib/tmap.tcc +196 -0
  66. data/ext/taglib/taglib-mswin32/include/taglib/trueaudiofile.h +180 -0
  67. data/ext/taglib/taglib-mswin32/include/taglib/trueaudioproperties.h +93 -0
  68. data/ext/taglib/taglib-mswin32/include/taglib/tstring.h +456 -0
  69. data/ext/taglib/taglib-mswin32/include/taglib/tstringlist.h +115 -0
  70. data/ext/taglib/taglib-mswin32/include/taglib/uniquefileidentifierframe.h +113 -0
  71. data/ext/taglib/taglib-mswin32/include/taglib/unknownframe.h +79 -0
  72. data/ext/taglib/taglib-mswin32/include/taglib/unsynchronizedlyricsframe.h +157 -0
  73. data/ext/taglib/taglib-mswin32/include/taglib/urllinkframe.h +172 -0
  74. data/ext/taglib/taglib-mswin32/include/taglib/vorbisfile.h +118 -0
  75. data/ext/taglib/taglib-mswin32/include/taglib/vorbisproperties.h +125 -0
  76. data/ext/taglib/taglib-mswin32/include/taglib/wavpackfile.h +164 -0
  77. data/ext/taglib/taglib-mswin32/include/taglib/wavpackproperties.h +94 -0
  78. data/ext/taglib/taglib-mswin32/include/taglib/xingheader.h +100 -0
  79. data/ext/taglib/taglib-mswin32/include/taglib/xiphcomment.h +202 -0
  80. data/ext/taglib/taglib-mswin32/lib/pkgconfig/taglib_c.pc +12 -0
  81. data/ext/taglib/taglib-mswin32/lib/tag.lib +0 -0
  82. data/ext/taglib/taglib-mswin32/lib/tag_c.lib +0 -0
  83. data/ext/taglib/taglib_i386-mingw32.source +22645 -0
  84. data/ext/taglib/taglib_i386-mswin32.source +22645 -0
  85. data/ext/taglib/{taglib.cxx → taglib_x86_64-linux.source} +508 -75
  86. data/lib/TagLib.rb +3 -2
  87. data/lib/TagLib_doc.rb +1532 -1526
  88. data/lib/rtaglib_mswin32.rb +4 -0
  89. data/lib/tagfile.rb +6 -0
  90. data/swig/Doxyfile +0 -0
  91. data/swig/Rakefile +44 -19
  92. data/swig/TagLib_doc.rb +2755 -0
  93. data/swig/make_doc.rb +5 -4
  94. data/swig/process_cxx.rb +2 -2
  95. data/swig/rake_ext_conf.rb +33 -0
  96. data/swig/taglib.i +8 -5
  97. data/swig/test.rb +47 -39
  98. data/test/test_read.rb +4 -3
  99. data/test/test_taglib.rb +47 -39
  100. data/test/test_write.rb +4 -3
  101. metadata +96 -20
  102. data/ext/tagfile/extconf.rb +0 -14
  103. data/ext/taglib/extconf.rb +0 -22
  104. data/swig/extconf.rb +0 -22
@@ -0,0 +1,91 @@
1
+ /***************************************************************************
2
+ copyright : (C) 2002 - 2008 by Scott Wheeler
3
+ email : wheeler@kde.org
4
+ ***************************************************************************/
5
+
6
+ /***************************************************************************
7
+ * This library is free software; you can redistribute it and/or modify *
8
+ * it under the terms of the GNU Lesser General Public License version *
9
+ * 2.1 as published by the Free Software Foundation. *
10
+ * *
11
+ * This library is distributed in the hope that it will be useful, but *
12
+ * WITHOUT ANY WARRANTY; without even the implied warranty of *
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14
+ * Lesser General Public License for more details. *
15
+ * *
16
+ * You should have received a copy of the GNU Lesser General Public *
17
+ * License along with this library; if not, write to the Free Software *
18
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
19
+ * USA *
20
+ * *
21
+ * Alternatively, this file is available under the Mozilla Public *
22
+ * License Version 1.1. You may obtain a copy of the License at *
23
+ * http://www.mozilla.org/MPL/ *
24
+ ***************************************************************************/
25
+
26
+ #ifndef TAGLIB_BYTEVECTORLIST_H
27
+ #define TAGLIB_BYTEVECTORLIST_H
28
+
29
+ #include "taglib_export.h"
30
+ #include "tbytevector.h"
31
+ #include "tlist.h"
32
+
33
+ namespace TagLib {
34
+
35
+ //! A list of ByteVectors
36
+
37
+ /*!
38
+ * A List specialization with some handy features useful for ByteVectors.
39
+ */
40
+
41
+ class TAGLIB_EXPORT ByteVectorList : public List<ByteVector>
42
+ {
43
+ public:
44
+
45
+ /*!
46
+ * Construct an empty ByteVectorList.
47
+ */
48
+ ByteVectorList();
49
+
50
+ /*!
51
+ * Destroys this ByteVectorList instance.
52
+ */
53
+ virtual ~ByteVectorList();
54
+
55
+ /*!
56
+ * Make a shallow, implicitly shared, copy of \a l. Because this is
57
+ * implicitly shared, this method is lightweight and suitable for
58
+ * pass-by-value usage.
59
+ */
60
+ ByteVectorList(const ByteVectorList &l);
61
+
62
+ /*!
63
+ * Convert the ByteVectorList to a ByteVector separated by \a separator. By
64
+ * default a space is used.
65
+ */
66
+ ByteVector toByteVector(const ByteVector &separator = " ") const;
67
+
68
+ /*!
69
+ * Splits the ByteVector \a v into several strings at \a pattern. This will
70
+ * not include the pattern in the returned ByteVectors.
71
+ */
72
+ static ByteVectorList split(const ByteVector &v, const ByteVector &pattern,
73
+ int byteAlign = 1);
74
+ /*!
75
+ * Splits the ByteVector \a v into several strings at \a pattern. This will
76
+ * not include the pattern in the returned ByteVectors. \a max is the
77
+ * maximum number of entries that will be separated. If \a max for instance
78
+ * is 2 then a maximum of 1 match will be found and the vector will be split
79
+ * on that match.
80
+ */
81
+ // BIC: merge with the function above
82
+ static ByteVectorList split(const ByteVector &v, const ByteVector &pattern,
83
+ int byteAlign, int max);
84
+ private:
85
+ class ByteVectorListPrivate;
86
+ ByteVectorListPrivate *d;
87
+ };
88
+
89
+ }
90
+
91
+ #endif
@@ -0,0 +1,258 @@
1
+ /***************************************************************************
2
+ copyright : (C) 2002 - 2008 by Scott Wheeler
3
+ email : wheeler@kde.org
4
+ ***************************************************************************/
5
+
6
+ /***************************************************************************
7
+ * This library is free software; you can redistribute it and/or modify *
8
+ * it under the terms of the GNU Lesser General Public License version *
9
+ * 2.1 as published by the Free Software Foundation. *
10
+ * *
11
+ * This library is distributed in the hope that it will be useful, but *
12
+ * WITHOUT ANY WARRANTY; without even the implied warranty of *
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14
+ * Lesser General Public License for more details. *
15
+ * *
16
+ * You should have received a copy of the GNU Lesser General Public *
17
+ * License along with this library; if not, write to the Free Software *
18
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
19
+ * USA *
20
+ * *
21
+ * Alternatively, this file is available under the Mozilla Public *
22
+ * License Version 1.1. You may obtain a copy of the License at *
23
+ * http://www.mozilla.org/MPL/ *
24
+ ***************************************************************************/
25
+
26
+ #ifndef TAGLIB_TEXTIDENTIFICATIONFRAME_H
27
+ #define TAGLIB_TEXTIDENTIFICATIONFRAME_H
28
+
29
+ #include <tstringlist.h>
30
+ #include "taglib_export.h"
31
+
32
+ #include <id3v2frame.h>
33
+
34
+ namespace TagLib {
35
+
36
+ namespace ID3v2 {
37
+
38
+ class Tag;
39
+
40
+ //! An ID3v2 text identification frame implementation
41
+
42
+ /*!
43
+ * This is an implementation of the most common type of ID3v2 frame -- text
44
+ * identification frames. There are a number of variations on this. Those
45
+ * enumerated in the ID3v2.4 standard are:
46
+ *
47
+ * <ul>
48
+ * <li><b>TALB</b> Album/Movie/Show title</li>
49
+ * <li><b>TBPM</b> BPM (beats per minute)</li>
50
+ * <li><b>TCOM</b> Composer</li>
51
+ * <li><b>TCON</b> Content type</li>
52
+ * <li><b>TCOP</b> Copyright message</li>
53
+ * <li><b>TDEN</b> Encoding time</li>
54
+ * <li><b>TDLY</b> Playlist delay</li>
55
+ * <li><b>TDOR</b> Original release time</li>
56
+ * <li><b>TDRC</b> Recording time</li>
57
+ * <li><b>TDRL</b> Release time</li>
58
+ * <li><b>TDTG</b> Tagging time</li>
59
+ * <li><b>TENC</b> Encoded by</li>
60
+ * <li><b>TEXT</b> Lyricist/Text writer</li>
61
+ * <li><b>TFLT</b> File type</li>
62
+ * <li><b>TIPL</b> Involved people list</li>
63
+ * <li><b>TIT1</b> Content group description</li>
64
+ * <li><b>TIT2</b> Title/songname/content description</li>
65
+ * <li><b>TIT3</b> Subtitle/Description refinement</li>
66
+ * <li><b>TKEY</b> Initial key</li>
67
+ * <li><b>TLAN</b> Language(s)</li>
68
+ * <li><b>TLEN</b> Length</li>
69
+ * <li><b>TMCL</b> Musician credits list</li>
70
+ * <li><b>TMED</b> Media type</li>
71
+ * <li><b>TMOO</b> Mood</li>
72
+ * <li><b>TOAL</b> Original album/movie/show title</li>
73
+ * <li><b>TOFN</b> Original filename</li>
74
+ * <li><b>TOLY</b> Original lyricist(s)/text writer(s)</li>
75
+ * <li><b>TOPE</b> Original artist(s)/performer(s)</li>
76
+ * <li><b>TOWN</b> File owner/licensee</li>
77
+ * <li><b>TPE1</b> Lead performer(s)/Soloist(s)</li>
78
+ * <li><b>TPE2</b> Band/orchestra/accompaniment</li>
79
+ * <li><b>TPE3</b> Conductor/performer refinement</li>
80
+ * <li><b>TPE4</b> Interpreted, remixed, or otherwise modified by</li>
81
+ * <li><b>TPOS</b> Part of a set</li>
82
+ * <li><b>TPRO</b> Produced notice</li>
83
+ * <li><b>TPUB</b> Publisher</li>
84
+ * <li><b>TRCK</b> Track number/Position in set</li>
85
+ * <li><b>TRSN</b> Internet radio station name</li>
86
+ * <li><b>TRSO</b> Internet radio station owner</li>
87
+ * <li><b>TSOA</b> Album sort order</li>
88
+ * <li><b>TSOP</b> Performer sort order</li>
89
+ * <li><b>TSOT</b> Title sort order</li>
90
+ * <li><b>TSRC</b> ISRC (international standard recording code)</li>
91
+ * <li><b>TSSE</b> Software/Hardware and settings used for encoding</li>
92
+ * <li><b>TSST</b> Set subtitle</li>
93
+ * </ul>
94
+ *
95
+ * The ID3v2 Frames document gives a description of each of these formats
96
+ * and the expected order of strings in each. ID3v2::Header::frameID() can
97
+ * be used to determine the frame type.
98
+ *
99
+ * \note If non-Latin1 compatible strings are used with this class, even if
100
+ * the text encoding is set to Latin1, the frame will be written using UTF8
101
+ * (with the encoding flag appropriately set in the output).
102
+ */
103
+
104
+ class TAGLIB_EXPORT TextIdentificationFrame : public Frame
105
+ {
106
+ friend class FrameFactory;
107
+
108
+ public:
109
+ /*!
110
+ * Construct an empty frame of type \a type. Uses \a encoding as the
111
+ * default text encoding.
112
+ *
113
+ * \note In this case you must specify the text encoding as it
114
+ * resolves the ambiguity between constructors.
115
+ *
116
+ * \note Please see the note in the class description regarding Latin1.
117
+ */
118
+ TextIdentificationFrame(const ByteVector &type, String::Type encoding);
119
+
120
+ /*!
121
+ * This is a dual purpose constructor. \a data can either be binary data
122
+ * that should be parsed or (at a minimum) the frame ID.
123
+ */
124
+ explicit TextIdentificationFrame(const ByteVector &data);
125
+
126
+ /*!
127
+ * Destroys this TextIdentificationFrame instance.
128
+ */
129
+ virtual ~TextIdentificationFrame();
130
+
131
+ /*!
132
+ * Text identification frames are a list of string fields.
133
+ *
134
+ * This function will accept either a StringList or a String (using the
135
+ * StringList constructor that accepts a single String).
136
+ *
137
+ * \note This will not change the text encoding of the frame even if the
138
+ * strings passed in are not of the same encoding. Please use
139
+ * setEncoding(s.type()) if you wish to change the encoding of the frame.
140
+ */
141
+ void setText(const StringList &l);
142
+
143
+ // Reimplementations.
144
+
145
+ virtual void setText(const String &s);
146
+ virtual String toString() const;
147
+
148
+ /*!
149
+ * Returns the text encoding that will be used in rendering this frame.
150
+ * This defaults to the type that was either specified in the constructor
151
+ * or read from the frame when parsed.
152
+ *
153
+ * \note Please see the note in the class description regarding Latin1.
154
+ *
155
+ * \see setTextEncoding()
156
+ * \see render()
157
+ */
158
+ String::Type textEncoding() const;
159
+
160
+ /*!
161
+ * Sets the text encoding to be used when rendering this frame to
162
+ * \a encoding.
163
+ *
164
+ * \note Please see the note in the class description regarding Latin1.
165
+ *
166
+ * \see textEncoding()
167
+ * \see render()
168
+ */
169
+ void setTextEncoding(String::Type encoding);
170
+
171
+ /*!
172
+ * Returns a list of the strings in this frame.
173
+ */
174
+ StringList fieldList() const;
175
+
176
+ protected:
177
+ // Reimplementations.
178
+
179
+ virtual void parseFields(const ByteVector &data);
180
+ virtual ByteVector renderFields() const;
181
+
182
+ /*!
183
+ * The constructor used by the FrameFactory.
184
+ */
185
+ TextIdentificationFrame(const ByteVector &data, Header *h);
186
+
187
+ private:
188
+ TextIdentificationFrame(const TextIdentificationFrame &);
189
+ TextIdentificationFrame &operator=(const TextIdentificationFrame &);
190
+
191
+ class TextIdentificationFramePrivate;
192
+ TextIdentificationFramePrivate *d;
193
+ };
194
+
195
+ /*!
196
+ * This is a specialization of text identification frames that allows for
197
+ * user defined entries. Each entry has a description in addition to the
198
+ * normal list of fields that a text identification frame has.
199
+ *
200
+ * This description identifies the frame and must be unique.
201
+ */
202
+
203
+ //! An ID3v2 custom text identification frame implementationx
204
+
205
+ class TAGLIB_EXPORT UserTextIdentificationFrame : public TextIdentificationFrame
206
+ {
207
+ friend class FrameFactory;
208
+
209
+ public:
210
+ /*!
211
+ * Constructs an empty user defined text identification frame. For this to be
212
+ * a useful frame both a description and text must be set.
213
+ */
214
+ explicit UserTextIdentificationFrame(String::Type encoding = String::Latin1);
215
+
216
+ /*!
217
+ * Creates a frame based on \a data.
218
+ */
219
+ explicit UserTextIdentificationFrame(const ByteVector &data);
220
+
221
+ virtual String toString() const;
222
+
223
+ /*!
224
+ * Returns the description for this frame.
225
+ */
226
+ String description() const;
227
+
228
+ /*!
229
+ * Sets the description of the frame to \a s. \a s must be unique. You can
230
+ * check for the presence of another user defined text frame of the same type
231
+ * using find() and testing for null.
232
+ */
233
+ void setDescription(const String &s);
234
+
235
+ StringList fieldList() const;
236
+ void setText(const String &text);
237
+ void setText(const StringList &fields);
238
+
239
+ /*!
240
+ * Searches for the user defined text frame with the description \a description
241
+ * in \a tag. This returns null if no matching frames were found.
242
+ */
243
+ static UserTextIdentificationFrame *find(Tag *tag, const String &description);
244
+
245
+ private:
246
+ UserTextIdentificationFrame(const ByteVector &data, Header *h);
247
+ UserTextIdentificationFrame(const TextIdentificationFrame &);
248
+ UserTextIdentificationFrame &operator=(const UserTextIdentificationFrame &);
249
+
250
+ void checkFields();
251
+
252
+ class UserTextIdentificationFramePrivate;
253
+ UserTextIdentificationFramePrivate *d;
254
+ };
255
+
256
+ }
257
+ }
258
+ #endif
@@ -0,0 +1,271 @@
1
+ /***************************************************************************
2
+ copyright : (C) 2002 - 2008 by Scott Wheeler
3
+ email : wheeler@kde.org
4
+ ***************************************************************************/
5
+
6
+ /***************************************************************************
7
+ * This library is free software; you can redistribute it and/or modify *
8
+ * it under the terms of the GNU Lesser General Public License version *
9
+ * 2.1 as published by the Free Software Foundation. *
10
+ * *
11
+ * This library is distributed in the hope that it will be useful, but *
12
+ * WITHOUT ANY WARRANTY; without even the implied warranty of *
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14
+ * Lesser General Public License for more details. *
15
+ * *
16
+ * You should have received a copy of the GNU Lesser General Public *
17
+ * License along with this library; if not, write to the Free Software *
18
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
19
+ * USA *
20
+ * *
21
+ * Alternatively, this file is available under the Mozilla Public *
22
+ * License Version 1.1. You may obtain a copy of the License at *
23
+ * http://www.mozilla.org/MPL/ *
24
+ ***************************************************************************/
25
+
26
+ #ifndef TAGLIB_FILE_H
27
+ #define TAGLIB_FILE_H
28
+
29
+ #include "taglib_export.h"
30
+ #include "taglib.h"
31
+ #include "tbytevector.h"
32
+
33
+ namespace TagLib {
34
+
35
+ class String;
36
+ class Tag;
37
+ class AudioProperties;
38
+
39
+ #ifdef _WIN32
40
+ class TAGLIB_EXPORT FileName
41
+ {
42
+ public:
43
+ FileName(const wchar_t *name) : m_wname(name) {}
44
+ FileName(const char *name) : m_name(name) {}
45
+ operator const wchar_t *() const { return m_wname.c_str(); }
46
+ operator const char *() const { return m_name.c_str(); }
47
+ private:
48
+ std::string m_name;
49
+ std::wstring m_wname;
50
+ };
51
+ #else
52
+ typedef const char *FileName;
53
+ #endif
54
+
55
+ //! A file class with some useful methods for tag manipulation
56
+
57
+ /*!
58
+ * This class is a basic file class with some methods that are particularly
59
+ * useful for tag editors. It has methods to take advantage of
60
+ * ByteVector and a binary search method for finding patterns in a file.
61
+ */
62
+
63
+ class TAGLIB_EXPORT File
64
+ {
65
+ public:
66
+ /*!
67
+ * Position in the file used for seeking.
68
+ */
69
+ enum Position {
70
+ //! Seek from the beginning of the file.
71
+ Beginning,
72
+ //! Seek from the current position in the file.
73
+ Current,
74
+ //! Seek from the end of the file.
75
+ End
76
+ };
77
+
78
+ /*!
79
+ * Destroys this File instance.
80
+ */
81
+ virtual ~File();
82
+
83
+ /*!
84
+ * Returns the file name in the local file system encoding.
85
+ */
86
+ FileName name() const;
87
+
88
+ /*!
89
+ * Returns a pointer to this file's tag. This should be reimplemented in
90
+ * the concrete subclasses.
91
+ */
92
+ virtual Tag *tag() const = 0;
93
+
94
+ /*!
95
+ * Returns a pointer to this file's audio properties. This should be
96
+ * reimplemented in the concrete subclasses. If no audio properties were
97
+ * read then this will return a null pointer.
98
+ */
99
+ virtual AudioProperties *audioProperties() const = 0;
100
+
101
+ /*!
102
+ * Save the file and its associated tags. This should be reimplemented in
103
+ * the concrete subclasses. Returns true if the save succeeds.
104
+ *
105
+ * \warning On UNIX multiple processes are able to write to the same file at
106
+ * the same time. This can result in serious file corruption. If you are
107
+ * developing a program that makes use of TagLib from multiple processes you
108
+ * must insure that you are only doing writes to a particular file from one
109
+ * of them.
110
+ */
111
+ virtual bool save() = 0;
112
+
113
+ /*!
114
+ * Reads a block of size \a length at the current get pointer.
115
+ */
116
+ ByteVector readBlock(ulong length);
117
+
118
+ /*!
119
+ * Attempts to write the block \a data at the current get pointer. If the
120
+ * file is currently only opened read only -- i.e. readOnly() returns true --
121
+ * this attempts to reopen the file in read/write mode.
122
+ *
123
+ * \note This should be used instead of using the streaming output operator
124
+ * for a ByteVector. And even this function is significantly slower than
125
+ * doing output with a char[].
126
+ */
127
+ void writeBlock(const ByteVector &data);
128
+
129
+ /*!
130
+ * Returns the offset in the file that \a pattern occurs at or -1 if it can
131
+ * not be found. If \a before is set, the search will only continue until the
132
+ * pattern \a before is found. This is useful for tagging purposes to search
133
+ * for a tag before the synch frame.
134
+ *
135
+ * Searching starts at \a fromOffset, which defaults to the beginning of the
136
+ * file.
137
+ *
138
+ * \note This has the practial limitation that \a pattern can not be longer
139
+ * than the buffer size used by readBlock(). Currently this is 1024 bytes.
140
+ */
141
+ long find(const ByteVector &pattern,
142
+ long fromOffset = 0,
143
+ const ByteVector &before = ByteVector::null);
144
+
145
+ /*!
146
+ * Returns the offset in the file that \a pattern occurs at or -1 if it can
147
+ * not be found. If \a before is set, the search will only continue until the
148
+ * pattern \a before is found. This is useful for tagging purposes to search
149
+ * for a tag before the synch frame.
150
+ *
151
+ * Searching starts at \a fromOffset and proceeds from the that point to the
152
+ * beginning of the file and defaults to the end of the file.
153
+ *
154
+ * \note This has the practial limitation that \a pattern can not be longer
155
+ * than the buffer size used by readBlock(). Currently this is 1024 bytes.
156
+ */
157
+ long rfind(const ByteVector &pattern,
158
+ long fromOffset = 0,
159
+ const ByteVector &before = ByteVector::null);
160
+
161
+ /*!
162
+ * Insert \a data at position \a start in the file overwriting \a replace
163
+ * bytes of the original content.
164
+ *
165
+ * \note This method is slow since it requires rewriting all of the file
166
+ * after the insertion point.
167
+ */
168
+ void insert(const ByteVector &data, ulong start = 0, ulong replace = 0);
169
+
170
+ /*!
171
+ * Removes a block of the file starting a \a start and continuing for
172
+ * \a length bytes.
173
+ *
174
+ * \note This method is slow since it involves rewriting all of the file
175
+ * after the removed portion.
176
+ */
177
+ void removeBlock(ulong start = 0, ulong length = 0);
178
+
179
+ /*!
180
+ * Returns true if the file is read only (or if the file can not be opened).
181
+ */
182
+ bool readOnly() const;
183
+
184
+ /*!
185
+ * Since the file can currently only be opened as an argument to the
186
+ * constructor (sort-of by design), this returns if that open succeeded.
187
+ */
188
+ bool isOpen() const;
189
+
190
+ /*!
191
+ * Returns true if the file is open and readble and valid information for
192
+ * the Tag and / or AudioProperties was found.
193
+ */
194
+ bool isValid() const;
195
+
196
+ /*!
197
+ * Move the I/O pointer to \a offset in the file from position \a p. This
198
+ * defaults to seeking from the beginning of the file.
199
+ *
200
+ * \see Position
201
+ */
202
+ void seek(long offset, Position p = Beginning);
203
+
204
+ /*!
205
+ * Reset the end-of-file and error flags on the file.
206
+ */
207
+ void clear();
208
+
209
+ /*!
210
+ * Returns the current offset withing the file.
211
+ */
212
+ long tell() const;
213
+
214
+ /*!
215
+ * Returns the length of the file.
216
+ */
217
+ long length();
218
+
219
+ /*!
220
+ * Returns true if \a file can be opened for reading. If the file does not
221
+ * exist, this will return false.
222
+ *
223
+ * \deprecated
224
+ */
225
+ static bool isReadable(const char *file);
226
+
227
+ /*!
228
+ * Returns true if \a file can be opened for writing.
229
+ *
230
+ * \deprecated
231
+ */
232
+ static bool isWritable(const char *name);
233
+
234
+ protected:
235
+ /*!
236
+ * Construct a File object and opens the \a file. \a file should be a
237
+ * be a C-string in the local file system encoding.
238
+ *
239
+ * \note Constructor is protected since this class should only be
240
+ * instantiated through subclasses.
241
+ */
242
+ File(FileName file);
243
+
244
+ /*!
245
+ * Marks the file as valid or invalid.
246
+ *
247
+ * \see isValid()
248
+ */
249
+ void setValid(bool valid);
250
+
251
+ /*!
252
+ * Truncates the file to a \a length.
253
+ */
254
+ void truncate(long length);
255
+
256
+ /*!
257
+ * Returns the buffer size that is used for internal buffering.
258
+ */
259
+ static uint bufferSize();
260
+
261
+ private:
262
+ File(const File &);
263
+ File &operator=(const File &);
264
+
265
+ class FilePrivate;
266
+ FilePrivate *d;
267
+ };
268
+
269
+ }
270
+
271
+ #endif