<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>id3lib: src/tag_file.cpp Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="id3lib.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.3 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>src/tag_file.cpp</h1><a href="tag__file_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// $Id: tag_file.cpp,v 1.43 2003/03/02 14:14:08 t1mpy Exp $</span> <a name="l00002"></a>00002 <a name="l00003"></a>00003 <span class="comment">// id3lib: a C++ library for creating and manipulating id3v1/v2 tags</span> <a name="l00004"></a>00004 <span class="comment">// Copyright 1999, 2000 Scott Thomas Haug</span> <a name="l00005"></a>00005 <span class="comment">// Copyright 2002 Thijmen Klok (thijmen@id3lib.org)</span> <a name="l00006"></a>00006 <a name="l00007"></a>00007 <span class="comment">// This library is free software; you can redistribute it and/or modify it</span> <a name="l00008"></a>00008 <span class="comment">// under the terms of the GNU Library General Public License as published by</span> <a name="l00009"></a>00009 <span class="comment">// the Free Software Foundation; either version 2 of the License, or (at your</span> <a name="l00010"></a>00010 <span class="comment">// option) any later version.</span> <a name="l00011"></a>00011 <span class="comment">//</span> <a name="l00012"></a>00012 <span class="comment">// This library is distributed in the hope that it will be useful, but WITHOUT</span> <a name="l00013"></a>00013 <span class="comment">// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or</span> <a name="l00014"></a>00014 <span class="comment">// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public</span> <a name="l00015"></a>00015 <span class="comment">// License for more details.</span> <a name="l00016"></a>00016 <span class="comment">//</span> <a name="l00017"></a>00017 <span class="comment">// You should have received a copy of the GNU Library General Public License</span> <a name="l00018"></a>00018 <span class="comment">// along with this library; if not, write to the Free Software Foundation,</span> <a name="l00019"></a>00019 <span class="comment">// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.</span> <a name="l00020"></a>00020 <a name="l00021"></a>00021 <span class="comment">// The id3lib authors encourage improvements and optimisations to be sent to</span> <a name="l00022"></a>00022 <span class="comment">// the id3lib coordinator. Please see the README file for details on where to</span> <a name="l00023"></a>00023 <span class="comment">// send such submissions. See the AUTHORS file for a list of people who have</span> <a name="l00024"></a>00024 <span class="comment">// contributed to id3lib. See the ChangeLog file for a list of changes to</span> <a name="l00025"></a>00025 <span class="comment">// id3lib. These files are distributed with id3lib at</span> <a name="l00026"></a>00026 <span class="comment">// http://download.sourceforge.net/id3lib/</span> <a name="l00027"></a>00027 <a name="l00028"></a>00028 <span class="preprocessor">#include <stdio.h></span> <span class="comment">//for BUFSIZ and functions remove & rename</span> <a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="writers_8h.html">writers.h</a>"</span> <a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="io__strings_8h.html">io_strings.h</a>"</span> <a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="tag__impl_8h.html">tag_impl.h</a>"</span> <span class="comment">//has <stdio.h> "tag.h" "header_tag.h" "frame.h" "field.h" "spec.h" "id3lib_strings.h" "utils.h"</span> <a name="l00032"></a>00032 <a name="l00033"></a>00033 <span class="keyword">using namespace </span>dami; <a name="l00034"></a>00034 <a name="l00035"></a>00035 <span class="preprocessor">#if !defined HAVE_MKSTEMP</span> <a name="l00036"></a>00036 <span class="preprocessor"></span><span class="preprocessor"># include <stdio.h></span> <a name="l00037"></a>00037 <span class="preprocessor">#endif</span> <a name="l00038"></a>00038 <span class="preprocessor"></span> <a name="l00039"></a>00039 <span class="preprocessor">#if defined HAVE_UNISTD_H</span> <a name="l00040"></a>00040 <span class="preprocessor"></span><span class="preprocessor"># include <unistd.h></span> <a name="l00041"></a>00041 <span class="preprocessor">#endif</span> <a name="l00042"></a>00042 <span class="preprocessor"></span> <a name="l00043"></a>00043 <span class="preprocessor">#if defined HAVE_SYS_STAT_H</span> <a name="l00044"></a>00044 <span class="preprocessor"></span><span class="preprocessor"># include <sys/stat.h></span> <a name="l00045"></a>00045 <span class="preprocessor">#endif</span> <a name="l00046"></a>00046 <span class="preprocessor"></span> <a name="l00047"></a>00047 <span class="preprocessor">#if defined WIN32 && (!defined(WINCE))</span> <a name="l00048"></a>00048 <span class="preprocessor"></span><span class="preprocessor"># include <windows.h></span> <a name="l00049"></a>00049 <span class="keyword">static</span> <span class="keywordtype">int</span> truncate(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <span class="keywordtype">size_t</span> length) <a name="l00050"></a>00050 { <a name="l00051"></a>00051 <span class="keywordtype">int</span> result = -1; <a name="l00052"></a>00052 HANDLE fh; <a name="l00053"></a>00053 <a name="l00054"></a>00054 fh = ::CreateFile(path, <a name="l00055"></a>00055 GENERIC_WRITE | GENERIC_READ, <a name="l00056"></a>00056 0, <a name="l00057"></a>00057 <a class="code" href="globals_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, <a name="l00058"></a>00058 OPEN_EXISTING, <a name="l00059"></a>00059 FILE_ATTRIBUTE_NORMAL, <a name="l00060"></a>00060 NULL); <a name="l00061"></a>00061 <a name="l00062"></a>00062 <span class="keywordflow">if</span>(INVALID_HANDLE_VALUE != fh) <a name="l00063"></a>00063 { <a name="l00064"></a>00064 SetFilePointer(fh, length, NULL, FILE_BEGIN); <a name="l00065"></a>00065 SetEndOfFile(fh); <a name="l00066"></a>00066 CloseHandle(fh); <a name="l00067"></a>00067 result = 0; <a name="l00068"></a>00068 } <a name="l00069"></a>00069 <a name="l00070"></a>00070 <span class="keywordflow">return</span> result; <a name="l00071"></a>00071 } <a name="l00072"></a>00072 <a name="l00073"></a>00073 <span class="comment">// prevents a weird error I was getting compiling this under windows</span> <a name="l00074"></a>00074 <span class="preprocessor"># if defined CreateFile</span> <a name="l00075"></a>00075 <span class="preprocessor"></span><span class="preprocessor"># undef CreateFile</span> <a name="l00076"></a>00076 <span class="preprocessor"></span><span class="preprocessor"># endif</span> <a name="l00077"></a>00077 <span class="preprocessor"></span> <a name="l00078"></a>00078 <span class="preprocessor">#elif defined(WINCE)</span> <a name="l00079"></a>00079 <span class="preprocessor"></span><span class="comment">// Createfile is apparently to defined to CreateFileW. (Bad Bad Bad), so we</span> <a name="l00080"></a>00080 <span class="comment">// work around it by converting path to Unicode</span> <a name="l00081"></a>00081 <span class="preprocessor"># include <windows.h></span> <a name="l00082"></a>00082 <span class="keyword">static</span> <span class="keywordtype">int</span> truncate(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <span class="keywordtype">size_t</span> length) <a name="l00083"></a>00083 { <a name="l00084"></a>00084 <span class="keywordtype">int</span> result = -1; <a name="l00085"></a>00085 <span class="keywordtype">wchar_t</span> wcTempPath[256]; <a name="l00086"></a>00086 mbstowcs(wcTempPath,path,255); <a name="l00087"></a>00087 HANDLE fh; <a name="l00088"></a>00088 fh = ::CreateFile(wcTempPath, <a name="l00089"></a>00089 GENERIC_WRITE | GENERIC_READ, <a name="l00090"></a>00090 0, <a name="l00091"></a>00091 NULL, <a name="l00092"></a>00092 OPEN_EXISTING, <a name="l00093"></a>00093 FILE_ATTRIBUTE_NORMAL, <a name="l00094"></a>00094 NULL); <a name="l00095"></a>00095 <a name="l00096"></a>00096 <span class="keywordflow">if</span> (INVALID_HANDLE_VALUE != fh) <a name="l00097"></a>00097 { <a name="l00098"></a>00098 SetFilePointer(fh, length, NULL, FILE_BEGIN); <a name="l00099"></a>00099 SetEndOfFile(fh); <a name="l00100"></a>00100 CloseHandle(fh); <a name="l00101"></a>00101 result = 0; <a name="l00102"></a>00102 } <a name="l00103"></a>00103 <a name="l00104"></a>00104 <span class="keywordflow">return</span> result; <a name="l00105"></a>00105 } <a name="l00106"></a>00106 <a name="l00107"></a>00107 <span class="preprocessor">#elif defined(macintosh)</span> <a name="l00108"></a>00108 <span class="preprocessor"></span> <a name="l00109"></a>00109 <span class="keyword">static</span> <span class="keywordtype">int</span> truncate(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <span class="keywordtype">size_t</span> length) <a name="l00110"></a>00110 { <a name="l00111"></a>00111 <span class="comment">/* not implemented on the Mac */</span> <a name="l00112"></a>00112 <span class="keywordflow">return</span> -1; <a name="l00113"></a>00113 } <a name="l00114"></a>00114 <a name="l00115"></a>00115 <span class="preprocessor">#endif</span> <a name="l00116"></a>00116 <span class="preprocessor"></span> <a name="l00117"></a><a class="code" href="class_i_d3___tag_impl.html#a046b9a4e337449fb1e9e95bb33364e7e">00117</a> <span class="keywordtype">size_t</span> <a class="code" href="class_i_d3___tag_impl.html#a9c71ba17ca8cfd45b6bb77209a20c314">ID3_TagImpl::Link</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fileInfo, <span class="keywordtype">bool</span> parseID3v1, <span class="keywordtype">bool</span> parseLyrics3) <a name="l00118"></a>00118 { <a name="l00119"></a>00119 <a class="code" href="globals_8h.html#ab20eda11df95fbb997872386ec0d6004">flags_t</a> tt = <a class="code" href="globals_8h.html#a2d783dffbb1bb13e23080984b277b348af7791f864e6b616f963b35bb27dbdf08" title="Represents an empty or non-existant tag.">ID3TT_NONE</a>; <a name="l00120"></a>00120 <span class="keywordflow">if</span> (parseID3v1) <a name="l00121"></a>00121 { <a name="l00122"></a>00122 tt |= <a class="code" href="globals_8h.html#a2d783dffbb1bb13e23080984b277b348ad874770876eb09c8d37ed7f6e60546f8" title="Represents an id3v1 or id3v1.1 tag.">ID3TT_ID3V1</a>; <a name="l00123"></a>00123 } <a name="l00124"></a>00124 <span class="keywordflow">if</span> (parseLyrics3) <a name="l00125"></a>00125 { <a name="l00126"></a>00126 tt |= <a class="code" href="globals_8h.html#a2d783dffbb1bb13e23080984b277b348ad02523404c43bb0f9f8989cc5cd20eac">ID3TT_LYRICS</a>; <a name="l00127"></a>00127 } <a name="l00128"></a>00128 <span class="keywordflow">return</span> this-><a class="code" href="class_i_d3___tag_impl.html#a9c71ba17ca8cfd45b6bb77209a20c314">Link</a>(fileInfo, tt); <a name="l00129"></a>00129 } <a name="l00130"></a>00130 <a name="l00131"></a><a class="code" href="class_i_d3___tag_impl.html#a9c71ba17ca8cfd45b6bb77209a20c314">00131</a> <span class="keywordtype">size_t</span> <a class="code" href="class_i_d3___tag_impl.html#a9c71ba17ca8cfd45b6bb77209a20c314">ID3_TagImpl::Link</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fileInfo, <a class="code" href="globals_8h.html#ab20eda11df95fbb997872386ec0d6004">flags_t</a> tag_types) <a name="l00132"></a>00132 { <a name="l00133"></a>00133 _tags_to_parse.<a class="code" href="class_i_d3___flags.html#a6aa5d0be84c92c189c777c6b77fdda06">set</a>(tag_types); <a name="l00134"></a>00134 <a name="l00135"></a>00135 <span class="keywordflow">if</span> (NULL == fileInfo) <a name="l00136"></a>00136 { <a name="l00137"></a>00137 <span class="keywordflow">return</span> 0; <a name="l00138"></a>00138 } <a name="l00139"></a>00139 <a name="l00140"></a>00140 _file_name = fileInfo; <a name="l00141"></a>00141 _changed = <span class="keyword">true</span>; <a name="l00142"></a>00142 <a name="l00143"></a>00143 this-><a class="code" href="class_i_d3___tag_impl.html#ab8053253873768d25d7188f34da9f75e">ParseFile</a>(); <a name="l00144"></a>00144 <a name="l00145"></a>00145 <span class="keywordflow">return</span> this-><a class="code" href="class_i_d3___tag_impl.html#a9b2279334b6bc5f4a2564b529fe92b03">GetPrependedBytes</a>(); <a name="l00146"></a>00146 } <a name="l00147"></a>00147 <a name="l00148"></a>00148 <span class="comment">// used for streaming:</span> <a name="l00149"></a><a class="code" href="class_i_d3___tag_impl.html#a0a045d78da827fe80923ab2538284207">00149</a> <span class="keywordtype">size_t</span> <a class="code" href="class_i_d3___tag_impl.html#a9c71ba17ca8cfd45b6bb77209a20c314">ID3_TagImpl::Link</a>(<a class="code" href="class_i_d3___reader.html">ID3_Reader</a> &reader, <a class="code" href="globals_8h.html#ab20eda11df95fbb997872386ec0d6004">flags_t</a> tag_types) <a name="l00150"></a>00150 { <a name="l00151"></a>00151 _tags_to_parse.<a class="code" href="class_i_d3___flags.html#a6aa5d0be84c92c189c777c6b77fdda06">set</a>(tag_types); <a name="l00152"></a>00152 <a name="l00153"></a>00153 _file_name = <span class="stringliteral">""</span>; <a name="l00154"></a>00154 _changed = <span class="keyword">true</span>; <a name="l00155"></a>00155 <a name="l00156"></a>00156 this-><a class="code" href="class_i_d3___tag_impl.html#a452b7f87e0a9ec5a7e61d60c6fbaf020">ParseReader</a>(reader); <a name="l00157"></a>00157 <a name="l00158"></a>00158 <span class="keywordflow">return</span> this-><a class="code" href="class_i_d3___tag_impl.html#a9b2279334b6bc5f4a2564b529fe92b03">GetPrependedBytes</a>(); <a name="l00159"></a>00159 } <a name="l00160"></a>00160 <a name="l00161"></a><a class="code" href="tag__file_8cpp.html#a254b3e67b6b7f5a17fbdeff0831fd332">00161</a> <span class="keywordtype">size_t</span> <a class="code" href="tag__file_8cpp.html#a254b3e67b6b7f5a17fbdeff0831fd332">RenderV1ToFile</a>(<a class="code" href="class_i_d3___tag_impl.html">ID3_TagImpl</a>& tag, fstream& file) <a name="l00162"></a>00162 { <a name="l00163"></a>00163 <span class="keywordflow">if</span> (!file) <a name="l00164"></a>00164 { <a name="l00165"></a>00165 <span class="keywordflow">return</span> 0; <a name="l00166"></a>00166 } <a name="l00167"></a>00167 <a name="l00168"></a>00168 <span class="comment">// Heck no, this is stupid. If we do not read in an initial V1(.1)</span> <a name="l00169"></a>00169 <span class="comment">// header then we are constantly appending new V1(.1) headers. Files</span> <a name="l00170"></a>00170 <span class="comment">// can get very big that way if we never overwrite the old ones.</span> <a name="l00171"></a>00171 <span class="comment">// if (ID3_V1_LEN > tag.GetAppendedBytes()) - Daniel Hazelbaker</span> <a name="l00172"></a>00172 <span class="keywordflow">if</span> (<a class="code" href="globals_8h.html#af5c00561c08372185f9acec6fffc0843a46a5c15ce2275169ef60c607e2d65cc7">ID3_V1_LEN</a> > tag.<a class="code" href="class_i_d3___tag_impl.html#a4c667c682aba07ab731050662b6afead">GetFileSize</a>()) <a name="l00173"></a>00173 { <a name="l00174"></a>00174 file.seekp(0, ios::end); <a name="l00175"></a>00175 } <a name="l00176"></a>00176 <span class="keywordflow">else</span> <a name="l00177"></a>00177 { <a name="l00178"></a>00178 <span class="comment">// We want to check if there is already an id3v1 tag, so we can write over</span> <a name="l00179"></a>00179 <span class="comment">// it. First, seek to the beginning of any possible id3v1 tag</span> <a name="l00180"></a>00180 file.seekg(0-<a class="code" href="globals_8h.html#af5c00561c08372185f9acec6fffc0843a46a5c15ce2275169ef60c607e2d65cc7">ID3_V1_LEN</a>, ios::end); <a name="l00181"></a>00181 <span class="keywordtype">char</span> sID[<a class="code" href="globals_8h.html#af5c00561c08372185f9acec6fffc0843a5fec9a62d9c76ada23f0c918bae02499">ID3_V1_LEN_ID</a>]; <a name="l00182"></a>00182 <a name="l00183"></a>00183 <span class="comment">// Read in the TAG characters</span> <a name="l00184"></a>00184 file.read(sID, <a class="code" href="globals_8h.html#af5c00561c08372185f9acec6fffc0843a5fec9a62d9c76ada23f0c918bae02499">ID3_V1_LEN_ID</a>); <a name="l00185"></a>00185 <a name="l00186"></a>00186 <span class="comment">// If those three characters are TAG, then there's a preexisting id3v1 tag,</span> <a name="l00187"></a>00187 <span class="comment">// so we should set the file cursor so we can overwrite it with a new tag.</span> <a name="l00188"></a>00188 <span class="keywordflow">if</span> (memcmp(sID, <span class="stringliteral">"TAG"</span>, <a class="code" href="globals_8h.html#af5c00561c08372185f9acec6fffc0843a5fec9a62d9c76ada23f0c918bae02499">ID3_V1_LEN_ID</a>) == 0) <a name="l00189"></a>00189 { <a name="l00190"></a>00190 file.seekp(0-<a class="code" href="globals_8h.html#af5c00561c08372185f9acec6fffc0843a46a5c15ce2275169ef60c607e2d65cc7">ID3_V1_LEN</a>, ios::end); <a name="l00191"></a>00191 } <a name="l00192"></a>00192 <span class="comment">// Otherwise, set the cursor to the end of the file so we can append on</span> <a name="l00193"></a>00193 <span class="comment">// the new tag.</span> <a name="l00194"></a>00194 <span class="keywordflow">else</span> <a name="l00195"></a>00195 { <a name="l00196"></a>00196 file.seekp(0, ios::end); <a name="l00197"></a>00197 } <a name="l00198"></a>00198 } <a name="l00199"></a>00199 <a name="l00200"></a>00200 <a class="code" href="class_i_d3___i_o_stream_writer.html">ID3_IOStreamWriter</a> out(file); <a name="l00201"></a>00201 <a name="l00202"></a>00202 <a class="code" href="namespacedami_1_1id3_1_1v1.html#aeb5143c535f4bc42e6e13b429e4197e5">id3::v1::render</a>(out, tag); <a name="l00203"></a>00203 <a name="l00204"></a>00204 <span class="keywordflow">return</span> <a class="code" href="globals_8h.html#af5c00561c08372185f9acec6fffc0843a46a5c15ce2275169ef60c607e2d65cc7">ID3_V1_LEN</a>; <a name="l00205"></a>00205 } <a name="l00206"></a>00206 <a name="l00207"></a><a class="code" href="tag__file_8cpp.html#ad0146df50d1705e60230240ebcebbdd4">00207</a> <span class="keywordtype">size_t</span> <a class="code" href="tag__file_8cpp.html#ad0146df50d1705e60230240ebcebbdd4">RenderV2ToFile</a>(<span class="keyword">const</span> <a class="code" href="class_i_d3___tag_impl.html">ID3_TagImpl</a>& tag, fstream& file) <a name="l00208"></a>00208 { <a name="l00209"></a>00209 ID3D_NOTICE( <span class="stringliteral">"RenderV2ToFile: starting"</span> ); <a name="l00210"></a>00210 <span class="keywordflow">if</span> (!file) <a name="l00211"></a>00211 { <a name="l00212"></a>00212 ID3D_WARNING( <span class="stringliteral">"RenderV2ToFile: error in file"</span> ); <a name="l00213"></a>00213 <span class="keywordflow">return</span> 0; <a name="l00214"></a>00214 } <a name="l00215"></a>00215 <a name="l00216"></a>00216 String tagString; <a name="l00217"></a>00217 <a class="code" href="classdami_1_1io_1_1_string_writer.html">io::StringWriter</a> writer(tagString); <a name="l00218"></a>00218 <a class="code" href="namespacedami_1_1id3_1_1v1.html#aeb5143c535f4bc42e6e13b429e4197e5">id3::v2::render</a>(writer, tag); <a name="l00219"></a>00219 ID3D_NOTICE( <span class="stringliteral">"RenderV2ToFile: rendered v2"</span> ); <a name="l00220"></a>00220 <a name="l00221"></a>00221 <span class="keyword">const</span> <span class="keywordtype">char</span>* tagData = tagString.data(); <a name="l00222"></a>00222 <span class="keywordtype">size_t</span> tagSize = tagString.size(); <a name="l00223"></a>00223 <span class="comment">// if the new tag fits perfectly within the old and the old one</span> <a name="l00224"></a>00224 <span class="comment">// actually existed (ie this isn't the first tag this file has had)</span> <a name="l00225"></a>00225 <span class="keywordflow">if</span> ((!tag.<a class="code" href="class_i_d3___tag_impl.html#a9b2279334b6bc5f4a2564b529fe92b03">GetPrependedBytes</a>() && !<a class="code" href="tag__impl_8cpp.html#af1f761cbfe07a83bb9450ab5661bbbae">ID3_GetDataSize</a>(tag)) || <a name="l00226"></a>00226 (tagSize == tag.<a class="code" href="class_i_d3___tag_impl.html#a9b2279334b6bc5f4a2564b529fe92b03">GetPrependedBytes</a>())) <a name="l00227"></a>00227 { <a name="l00228"></a>00228 file.seekp(0, ios::beg); <a name="l00229"></a>00229 file.write(tagData, tagSize); <a name="l00230"></a>00230 } <a name="l00231"></a>00231 <span class="keywordflow">else</span> <a name="l00232"></a>00232 { <a name="l00233"></a>00233 String filename = tag.<a class="code" href="class_i_d3___tag_impl.html#a66ff56b585189b1e393b9a33c81bd6f2">GetFileName</a>(); <a name="l00234"></a>00234 String sTmpSuffix = <span class="stringliteral">".XXXXXX"</span>; <a name="l00235"></a>00235 <span class="keywordflow">if</span> (filename.size() + sTmpSuffix.size() > ID3_PATH_LENGTH) <a name="l00236"></a>00236 { <a name="l00237"></a>00237 <span class="comment">// log this</span> <a name="l00238"></a>00238 <span class="keywordflow">return</span> 0; <a name="l00239"></a>00239 <span class="comment">//ID3_THROW_DESC(ID3E_NoFile, "filename too long");</span> <a name="l00240"></a>00240 } <a name="l00241"></a>00241 <span class="keywordtype">char</span> sTempFile[ID3_PATH_LENGTH]; <a name="l00242"></a>00242 strcpy(sTempFile, filename.c_str()); <a name="l00243"></a>00243 strcat(sTempFile, sTmpSuffix.c_str()); <a name="l00244"></a>00244 <a name="l00245"></a>00245 <span class="preprocessor">#if !defined(HAVE_MKSTEMP)</span> <a name="l00246"></a>00246 <span class="preprocessor"></span> <span class="comment">// This section is for Windows folk</span> <a name="l00247"></a>00247 fstream tmpOut; <a name="l00248"></a>00248 createFile(sTempFile, tmpOut); <a name="l00249"></a>00249 <a name="l00250"></a>00250 tmpOut.write(tagData, tagSize); <a name="l00251"></a>00251 file.seekg(tag.<a class="code" href="class_i_d3___tag_impl.html#a9b2279334b6bc5f4a2564b529fe92b03">GetPrependedBytes</a>(), ios::beg); <a name="l00252"></a>00252 <span class="keywordtype">char</span> *tmpBuffer[BUFSIZ]; <a name="l00253"></a>00253 <span class="keywordflow">while</span> (!file.eof()) <a name="l00254"></a>00254 { <a name="l00255"></a>00255 file.read((<span class="keywordtype">char</span> *)tmpBuffer, BUFSIZ); <a name="l00256"></a>00256 <span class="keywordtype">size_t</span> nBytes = file.gcount(); <a name="l00257"></a>00257 tmpOut.write((<span class="keywordtype">char</span> *)tmpBuffer, nBytes); <a name="l00258"></a>00258 } <a name="l00259"></a>00259 <a name="l00260"></a>00260 <span class="preprocessor">#else //!defined(HAVE_MKSTEMP)</span> <a name="l00261"></a>00261 <span class="preprocessor"></span> <a name="l00262"></a>00262 <span class="comment">// else we gotta make a temp file, copy the tag into it, copy the</span> <a name="l00263"></a>00263 <span class="comment">// rest of the old file after the tag, delete the old file, rename</span> <a name="l00264"></a>00264 <span class="comment">// this new file to the old file's name and update the handle</span> <a name="l00265"></a>00265 <a name="l00266"></a>00266 <span class="keywordtype">int</span> fd = mkstemp(sTempFile); <a name="l00267"></a>00267 <span class="keywordflow">if</span> (fd < 0) <a name="l00268"></a>00268 { <a name="l00269"></a>00269 <span class="keyword">remove</span>(sTempFile); <a name="l00270"></a>00270 <span class="comment">//ID3_THROW_DESC(ID3E_NoFile, "couldn't open temp file");</span> <a name="l00271"></a>00271 } <a name="l00272"></a>00272 <a name="l00273"></a>00273 ofstream tmpOut(sTempFile); <a name="l00274"></a>00274 <span class="keywordflow">if</span> (!tmpOut) <a name="l00275"></a>00275 { <a name="l00276"></a>00276 tmpOut.close(); <a name="l00277"></a>00277 <span class="keyword">remove</span>(sTempFile); <a name="l00278"></a>00278 <span class="keywordflow">return</span> 0; <a name="l00279"></a>00279 <span class="comment">// log this</span> <a name="l00280"></a>00280 <span class="comment">//ID3_THROW(ID3E_ReadOnly);</span> <a name="l00281"></a>00281 } <a name="l00282"></a>00282 <a name="l00283"></a>00283 tmpOut.write(tagData, tagSize); <a name="l00284"></a>00284 file.seekg(tag.<a class="code" href="class_i_d3___tag_impl.html#a9b2279334b6bc5f4a2564b529fe92b03">GetPrependedBytes</a>(), ios::beg); <a name="l00285"></a>00285 <a class="code" href="globals_8h.html#a65f85814a8290f9797005d3b28e7e5fc">uchar</a> tmpBuffer[BUFSIZ]; <a name="l00286"></a>00286 <span class="keywordflow">while</span> (file) <a name="l00287"></a>00287 { <a name="l00288"></a>00288 file.read((<span class="keywordtype">char</span> *)tmpBuffer, BUFSIZ); <a name="l00289"></a>00289 <span class="keywordtype">size_t</span> nBytes = file.gcount(); <a name="l00290"></a>00290 tmpOut.write((<span class="keywordtype">char</span> *)tmpBuffer, nBytes); <a name="l00291"></a>00291 } <a name="l00292"></a>00292 <a name="l00293"></a>00293 close(fd); <span class="comment">//closes the file</span> <a name="l00294"></a>00294 <a name="l00295"></a>00295 <span class="preprocessor">#endif ////!defined(HAVE_MKSTEMP)</span> <a name="l00296"></a>00296 <span class="preprocessor"></span> <a name="l00297"></a>00297 tmpOut.close(); <a name="l00298"></a>00298 file.close(); <a name="l00299"></a>00299 <a name="l00300"></a>00300 <span class="comment">// the following sets the permissions of the new file</span> <a name="l00301"></a>00301 <span class="comment">// to be the same as the original</span> <a name="l00302"></a>00302 <span class="preprocessor">#if defined(HAVE_SYS_STAT_H)</span> <a name="l00303"></a>00303 <span class="preprocessor"></span> <span class="keyword">struct </span>stat fileStat; <a name="l00304"></a>00304 <span class="keywordflow">if</span>(stat(filename.c_str(), &fileStat) == 0) <a name="l00305"></a>00305 { <a name="l00306"></a>00306 <span class="preprocessor">#endif //defined(HAVE_SYS_STAT_H)</span> <a name="l00307"></a>00307 <span class="preprocessor"></span> <span class="keyword">remove</span>(filename.c_str()); <a name="l00308"></a>00308 rename(sTempFile, filename.c_str()); <a name="l00309"></a>00309 <span class="preprocessor">#if defined(HAVE_SYS_STAT_H)</span> <a name="l00310"></a>00310 <span class="preprocessor"></span> chmod(filename.c_str(), fileStat.st_mode); <a name="l00311"></a>00311 } <a name="l00312"></a>00312 <span class="preprocessor">#endif //defined(HAVE_SYS_STAT_H)</span> <a name="l00313"></a>00313 <span class="preprocessor"></span> <a name="l00314"></a>00314 <span class="comment">// file = tmpOut;</span> <a name="l00315"></a>00315 file.clear();<span class="comment">//to clear the eof mark</span> <a name="l00316"></a>00316 openWritableFile(filename, file); <a name="l00317"></a>00317 } <a name="l00318"></a>00318 <a name="l00319"></a>00319 <span class="keywordflow">return</span> tagSize; <a name="l00320"></a>00320 } <a name="l00321"></a>00321 <a name="l00322"></a>00322 <a name="l00323"></a><a class="code" href="class_i_d3___tag_impl.html#a8ccdc3a4ddc9541c95026d4299e17603">00323</a> <a class="code" href="globals_8h.html#ab20eda11df95fbb997872386ec0d6004">flags_t</a> <a class="code" href="class_i_d3___tag_impl.html#a8ccdc3a4ddc9541c95026d4299e17603">ID3_TagImpl::Update</a>(<a class="code" href="globals_8h.html#ab20eda11df95fbb997872386ec0d6004">flags_t</a> ulTagFlag) <a name="l00324"></a>00324 { <a name="l00325"></a>00325 <a class="code" href="globals_8h.html#ab20eda11df95fbb997872386ec0d6004">flags_t</a> tags = <a class="code" href="globals_8h.html#a2d783dffbb1bb13e23080984b277b348af7791f864e6b616f963b35bb27dbdf08" title="Represents an empty or non-existant tag.">ID3TT_NONE</a>; <a name="l00326"></a>00326 <a name="l00327"></a>00327 fstream file; <a name="l00328"></a>00328 String filename = this-><a class="code" href="class_i_d3___tag_impl.html#a66ff56b585189b1e393b9a33c81bd6f2">GetFileName</a>(); <a name="l00329"></a>00329 <a class="code" href="globals_8h.html#a0b8e76d7ef771f36346f7e4e5ce3fa84" title="Predefined id3lib error types.">ID3_Err</a> err = openWritableFile(filename, file); <a name="l00330"></a>00330 _file_size = getFileSize(file); <a name="l00331"></a>00331 <a name="l00332"></a>00332 <span class="keywordflow">if</span> (err == <a class="code" href="globals_8h.html#a0b8e76d7ef771f36346f7e4e5ce3fa84affc3d5d6e2c9dcc6358ac0429795368f" title="No file to parse.">ID3E_NoFile</a>) <a name="l00333"></a>00333 { <a name="l00334"></a>00334 err = createFile(filename, file); <a name="l00335"></a>00335 } <a name="l00336"></a>00336 <span class="keywordflow">if</span> (err == <a class="code" href="globals_8h.html#a0b8e76d7ef771f36346f7e4e5ce3fa84a7e6f8e7c70f044bfbceca9b48ccc57d2" title="Attempting to write to a read-only file.">ID3E_ReadOnly</a>) <a name="l00337"></a>00337 { <a name="l00338"></a>00338 <span class="keywordflow">return</span> tags; <a name="l00339"></a>00339 } <a name="l00340"></a>00340 <a name="l00341"></a>00341 <span class="keywordflow">if</span> ((ulTagFlag & <a class="code" href="globals_8h.html#a2d783dffbb1bb13e23080984b277b348a4ff91179fcf70ae9d26c87d7a34bd42a" title="Represents an id3v2 tag.">ID3TT_ID3V2</a>) && this-><a class="code" href="class_i_d3___tag_impl.html#a40d14bc7566d3f2fb7ae640510a97cb0">HasChanged</a>()) <a name="l00342"></a>00342 { <a name="l00343"></a>00343 _prepended_bytes = <a class="code" href="tag__file_8cpp.html#ad0146df50d1705e60230240ebcebbdd4">RenderV2ToFile</a>(*<span class="keyword">this</span>, file); <a name="l00344"></a>00344 <span class="keywordflow">if</span> (_prepended_bytes) <a name="l00345"></a>00345 { <a name="l00346"></a>00346 tags |= ID3TT_ID3V2; <a name="l00347"></a>00347 } <a name="l00348"></a>00348 } <a name="l00349"></a>00349 <a name="l00350"></a>00350 <span class="keywordflow">if</span> ((ulTagFlag & <a class="code" href="globals_8h.html#a2d783dffbb1bb13e23080984b277b348ad874770876eb09c8d37ed7f6e60546f8" title="Represents an id3v1 or id3v1.1 tag.">ID3TT_ID3V1</a>) && <a name="l00351"></a>00351 (!this-><a class="code" href="class_i_d3___tag_impl.html#a519cca5467a7369bb366575e7bc6ce06">HasTagType</a>(ID3TT_ID3V1) || this-><a class="code" href="class_i_d3___tag_impl.html#a40d14bc7566d3f2fb7ae640510a97cb0">HasChanged</a>())) <a name="l00352"></a>00352 { <a name="l00353"></a>00353 <span class="keywordtype">size_t</span> tag_bytes = <a class="code" href="tag__file_8cpp.html#a254b3e67b6b7f5a17fbdeff0831fd332">RenderV1ToFile</a>(*<span class="keyword">this</span>, file); <a name="l00354"></a>00354 <span class="keywordflow">if</span> (tag_bytes) <a name="l00355"></a>00355 { <a name="l00356"></a>00356 <span class="comment">// only add the tag_bytes if there wasn't an id3v1 tag before</span> <a name="l00357"></a>00357 <span class="keywordflow">if</span> (! _file_tags.<a class="code" href="class_i_d3___flags.html#a8619935f1b6dc6bbb9806be12fc3eac5">test</a>(ID3TT_ID3V1)) <a name="l00358"></a>00358 { <a name="l00359"></a>00359 _appended_bytes += tag_bytes; <a name="l00360"></a>00360 } <a name="l00361"></a>00361 tags |= ID3TT_ID3V1; <a name="l00362"></a>00362 } <a name="l00363"></a>00363 } <a name="l00364"></a>00364 _changed = <span class="keyword">false</span>; <a name="l00365"></a>00365 _file_tags.<a class="code" href="class_i_d3___flags.html#ae49b445ec2c343d8c387445bbefa384b">add</a>(tags); <a name="l00366"></a>00366 _file_size = getFileSize(file); <a name="l00367"></a>00367 file.close(); <a name="l00368"></a>00368 <span class="keywordflow">return</span> tags; <a name="l00369"></a>00369 } <a name="l00370"></a>00370 <a name="l00371"></a><a class="code" href="class_i_d3___tag_impl.html#a0126d01a8f40ac61a94e2805a8adef16">00371</a> <a class="code" href="globals_8h.html#ab20eda11df95fbb997872386ec0d6004">flags_t</a> <a class="code" href="class_i_d3___tag_impl.html#a0126d01a8f40ac61a94e2805a8adef16">ID3_TagImpl::Strip</a>(<a class="code" href="globals_8h.html#ab20eda11df95fbb997872386ec0d6004">flags_t</a> ulTagFlag) <a name="l00372"></a>00372 { <a name="l00373"></a>00373 <a class="code" href="globals_8h.html#ab20eda11df95fbb997872386ec0d6004">flags_t</a> ulTags = <a class="code" href="globals_8h.html#a2d783dffbb1bb13e23080984b277b348af7791f864e6b616f963b35bb27dbdf08" title="Represents an empty or non-existant tag.">ID3TT_NONE</a>; <a name="l00374"></a>00374 <span class="keyword">const</span> <span class="keywordtype">size_t</span> data_size = <a class="code" href="tag__impl_8cpp.html#af1f761cbfe07a83bb9450ab5661bbbae">ID3_GetDataSize</a>(*<span class="keyword">this</span>); <a name="l00375"></a>00375 <a name="l00376"></a>00376 <span class="comment">// First remove the v2 tag, if requested</span> <a name="l00377"></a>00377 <span class="keywordflow">if</span> (ulTagFlag & <a class="code" href="globals_8h.html#a2d783dffbb1bb13e23080984b277b348ad172ee549a7b4db95ce822a462667144" title="Represents all tag types that can be prepended to a file.">ID3TT_PREPENDED</a> & _file_tags.<a class="code" href="class_i_d3___flags.html#a1033f1c70975d4730c1682b46ca1ea94">get</a>()) <a name="l00378"></a>00378 { <a name="l00379"></a>00379 fstream file; <a name="l00380"></a>00380 <span class="keywordflow">if</span> (<a class="code" href="globals_8h.html#a0b8e76d7ef771f36346f7e4e5ce3fa84a92defcd73a15459b4e788cfef7b3f3eb" title="No error reported.">ID3E_NoError</a> != openWritableFile(this-><a class="code" href="class_i_d3___tag_impl.html#a66ff56b585189b1e393b9a33c81bd6f2">GetFileName</a>(), file)) <a name="l00381"></a>00381 { <a name="l00382"></a>00382 <span class="keywordflow">return</span> ulTags; <a name="l00383"></a>00383 } <a name="l00384"></a>00384 _file_size = getFileSize(file); <a name="l00385"></a>00385 <a name="l00386"></a>00386 <span class="comment">// We will remove the id3v2 tag in place: since it comes at the beginning</span> <a name="l00387"></a>00387 <span class="comment">// of the file, we'll effectively move all the data that comes after the</span> <a name="l00388"></a>00388 <span class="comment">// tag back n bytes, where n is the size of the id3v2 tag. Once we've</span> <a name="l00389"></a>00389 <span class="comment">// copied the data, we'll truncate the file.</span> <a name="l00390"></a>00390 file.seekg(this-><a class="code" href="class_i_d3___tag_impl.html#a9b2279334b6bc5f4a2564b529fe92b03">GetPrependedBytes</a>(), ios::beg); <a name="l00391"></a>00391 <a name="l00392"></a>00392 <a class="code" href="globals_8h.html#a65f85814a8290f9797005d3b28e7e5fc">uchar</a> aucBuffer[BUFSIZ]; <a name="l00393"></a>00393 <a name="l00394"></a>00394 <span class="comment">// The nBytesRemaining variable indicates how many bytes are to be copied</span> <a name="l00395"></a>00395 <span class="keywordtype">size_t</span> nBytesToCopy = data_size; <a name="l00396"></a>00396 <a name="l00397"></a>00397 <span class="comment">// Here we increase the nBytesToCopy by the size of any tags that appear</span> <a name="l00398"></a>00398 <span class="comment">// at the end of the file if we don't want to strip them</span> <a name="l00399"></a>00399 <span class="keywordflow">if</span> (!(ulTagFlag & <a class="code" href="globals_8h.html#a2d783dffbb1bb13e23080984b277b348a41ee45c38c2c3a51e09d27a30e7f2950" title="Represents all tag types that can be appended to a file.">ID3TT_APPENDED</a>)) <a name="l00400"></a>00400 { <a name="l00401"></a>00401 nBytesToCopy += this-><a class="code" href="class_i_d3___tag_impl.html#a5bc6c9c5cd3eb1d1b23a7cd46ed0730d">GetAppendedBytes</a>(); <a name="l00402"></a>00402 } <a name="l00403"></a>00403 <a name="l00404"></a>00404 <span class="comment">// The nBytesRemaining variable indicates how many bytes are left to be</span> <a name="l00405"></a>00405 <span class="comment">// moved in the actual file.</span> <a name="l00406"></a>00406 <span class="comment">// The nBytesCopied variable keeps track of how many actual bytes were</span> <a name="l00407"></a>00407 <span class="comment">// copied (or moved) so far.</span> <a name="l00408"></a>00408 <span class="keywordtype">size_t</span> nBytesRemaining = nBytesToCopy, <a name="l00409"></a>00409 nBytesCopied = 0; <a name="l00410"></a>00410 <span class="keywordflow">while</span> (!file.eof()) <a name="l00411"></a>00411 { <a name="l00412"></a>00412 <span class="preprocessor">#if (defined(__GNUC__) && __GNUC__ == 2)</span> <a name="l00413"></a>00413 <span class="preprocessor"></span> <span class="keywordtype">size_t</span> nBytesToRead = (size_t)<a class="code" href="io__strings_8h.html#ac6afabdc09a49a433ee19d8a9486056d">dami::min</a>((<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)(nBytesRemaining - nBytesCopied), (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)BUFSIZ); <a name="l00414"></a>00414 <span class="preprocessor">#else</span> <a name="l00415"></a>00415 <span class="preprocessor"></span> <span class="keywordtype">size_t</span> nBytesToRead = <a class="code" href="io__strings_8h.html#ac6afabdc09a49a433ee19d8a9486056d">min</a>((<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)(nBytesRemaining - nBytesCopied), (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)BUFSIZ); <a name="l00416"></a>00416 <span class="preprocessor">#endif</span> <a name="l00417"></a>00417 <span class="preprocessor"></span> file.read((<span class="keywordtype">char</span> *)aucBuffer, nBytesToRead); <a name="l00418"></a>00418 <span class="keywordtype">size_t</span> nBytesRead = file.gcount(); <a name="l00419"></a>00419 <a name="l00420"></a>00420 <span class="keywordflow">if</span> (nBytesRead != nBytesToRead) <a name="l00421"></a>00421 { <a name="l00422"></a>00422 <span class="comment">// TODO: log this</span> <a name="l00423"></a>00423 <span class="comment">//cerr << "--- attempted to write " << nBytesRead << " bytes, "</span> <a name="l00424"></a>00424 <span class="comment">// << "only wrote " << nBytesWritten << endl;</span> <a name="l00425"></a>00425 } <a name="l00426"></a>00426 <span class="keywordflow">if</span> (nBytesRead > 0) <a name="l00427"></a>00427 { <a name="l00428"></a>00428 <span class="keywordtype">long</span> offset = nBytesRead + this-><a class="code" href="class_i_d3___tag_impl.html#a9b2279334b6bc5f4a2564b529fe92b03">GetPrependedBytes</a>(); <a name="l00429"></a>00429 file.seekp(-offset, ios::cur); <a name="l00430"></a>00430 file.write((<span class="keywordtype">char</span> *)aucBuffer, nBytesRead); <a name="l00431"></a>00431 file.seekg(this-><a class="code" href="class_i_d3___tag_impl.html#a9b2279334b6bc5f4a2564b529fe92b03">GetPrependedBytes</a>(), ios::cur); <a name="l00432"></a>00432 nBytesCopied += nBytesRead; <a name="l00433"></a>00433 } <a name="l00434"></a>00434 <a name="l00435"></a>00435 <span class="keywordflow">if</span> (nBytesCopied == nBytesToCopy || nBytesToRead < BUFSIZ) <a name="l00436"></a>00436 { <a name="l00437"></a>00437 <span class="keywordflow">break</span>; <a name="l00438"></a>00438 } <a name="l00439"></a>00439 } <a name="l00440"></a>00440 file.close(); <a name="l00441"></a>00441 } <a name="l00442"></a>00442 <a name="l00443"></a>00443 <span class="keywordtype">size_t</span> nNewFileSize = data_size; <a name="l00444"></a>00444 <a name="l00445"></a>00445 <span class="keywordflow">if</span> ((_file_tags.<a class="code" href="class_i_d3___flags.html#a1033f1c70975d4730c1682b46ca1ea94">get</a>() & <a class="code" href="globals_8h.html#a2d783dffbb1bb13e23080984b277b348a41ee45c38c2c3a51e09d27a30e7f2950" title="Represents all tag types that can be appended to a file.">ID3TT_APPENDED</a>) && (ulTagFlag & <a class="code" href="globals_8h.html#a2d783dffbb1bb13e23080984b277b348a41ee45c38c2c3a51e09d27a30e7f2950" title="Represents all tag types that can be appended to a file.">ID3TT_APPENDED</a>)) <a name="l00446"></a>00446 { <a name="l00447"></a>00447 ulTags |= _file_tags.<a class="code" href="class_i_d3___flags.html#a1033f1c70975d4730c1682b46ca1ea94">get</a>() & ID3TT_APPENDED; <a name="l00448"></a>00448 } <a name="l00449"></a>00449 <span class="keywordflow">else</span> <a name="l00450"></a>00450 { <a name="l00451"></a>00451 <span class="comment">// if we're not stripping the appended tags, be sure to increase the file</span> <a name="l00452"></a>00452 <span class="comment">// size by those bytes</span> <a name="l00453"></a>00453 nNewFileSize += this-><a class="code" href="class_i_d3___tag_impl.html#a5bc6c9c5cd3eb1d1b23a7cd46ed0730d">GetAppendedBytes</a>(); <a name="l00454"></a>00454 } <a name="l00455"></a>00455 <a name="l00456"></a>00456 <span class="keywordflow">if</span> ((ulTagFlag & <a class="code" href="globals_8h.html#a2d783dffbb1bb13e23080984b277b348ad172ee549a7b4db95ce822a462667144" title="Represents all tag types that can be prepended to a file.">ID3TT_PREPENDED</a>) && (_file_tags.<a class="code" href="class_i_d3___flags.html#a1033f1c70975d4730c1682b46ca1ea94">get</a>() & ID3TT_PREPENDED)) <a name="l00457"></a>00457 { <a name="l00458"></a>00458 <span class="comment">// If we're stripping the ID3v2 tag, there's no need to adjust the new</span> <a name="l00459"></a>00459 <span class="comment">// file size, since it doesn't account for the ID3v2 tag size</span> <a name="l00460"></a>00460 ulTags |= _file_tags.<a class="code" href="class_i_d3___flags.html#a1033f1c70975d4730c1682b46ca1ea94">get</a>() & ID3TT_PREPENDED; <a name="l00461"></a>00461 } <a name="l00462"></a>00462 <span class="keywordflow">else</span> <a name="l00463"></a>00463 { <a name="l00464"></a>00464 <span class="comment">// add the original prepended tag size since we don't want to delete it,</span> <a name="l00465"></a>00465 <span class="comment">// and the new file size represents the file size _not_ counting the ID3v2</span> <a name="l00466"></a>00466 <span class="comment">// tag</span> <a name="l00467"></a>00467 nNewFileSize += this-><a class="code" href="class_i_d3___tag_impl.html#a9b2279334b6bc5f4a2564b529fe92b03">GetPrependedBytes</a>(); <a name="l00468"></a>00468 } <a name="l00469"></a>00469 <a name="l00470"></a>00470 <span class="keywordflow">if</span> (ulTags && (truncate(_file_name.c_str(), nNewFileSize) == -1)) <a name="l00471"></a>00471 { <a name="l00472"></a>00472 <span class="comment">// log this</span> <a name="l00473"></a>00473 <span class="keywordflow">return</span> 0; <a name="l00474"></a>00474 <span class="comment">//ID3_THROW(ID3E_NoFile);</span> <a name="l00475"></a>00475 } <a name="l00476"></a>00476 <a name="l00477"></a>00477 _prepended_bytes = (ulTags & ID3TT_PREPENDED) ? 0 : _prepended_bytes; <a name="l00478"></a>00478 _appended_bytes = (ulTags & ID3TT_APPENDED) ? 0 : _appended_bytes; <a name="l00479"></a>00479 _file_size = data_size + _prepended_bytes + _appended_bytes; <a name="l00480"></a>00480 <a name="l00481"></a>00481 _changed = _file_tags.<a class="code" href="class_i_d3___flags.html#a87a21d584631412a80084d1391531e61">remove</a>(ulTags) || _changed; <a name="l00482"></a>00482 <a name="l00483"></a>00483 <span class="keywordflow">return</span> ulTags; <a name="l00484"></a>00484 } <a name="l00485"></a>00485 </pre></div></div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Wed Jan 12 23:46:35 2011 for id3lib by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> </body> </html>