~ubuntu-branches/ubuntu/gutsy/kid3/gutsy

« back to all changes in this revision

Viewing changes to kid3/flacfile.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2007-07-01 00:31:03 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070701003103-2qownnv49a7jdqm3
Tags: 0.9-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#include "standardtags.h"
14
14
#include "genres.h"
15
15
#include "flacframelist.h"
 
16
#include "dirinfo.h"
16
17
#include <FLAC++/metadata.h>
17
18
#include <qfile.h>
18
19
#include <qdir.h>
32
33
/**
33
34
 * Constructor.
34
35
 *
35
 
 * @param dn directory name
 
36
 * @param di directory information
36
37
 * @param fn filename
37
38
 */
38
 
FlacFile::FlacFile(const QString& dn, const QString& fn) :
39
 
        OggFile(dn, fn), m_chain(0)
 
39
FlacFile::FlacFile(const DirInfo* di, const QString& fn) :
 
40
        OggFile(di, fn), m_chain(0)
40
41
{
41
42
}
42
43
 
59
60
{
60
61
        if (force || !m_fileRead) {
61
62
                m_comments.clear();
62
 
                changedV2 = false;
 
63
                markTag2Changed(false);
63
64
                m_fileRead = true;
64
 
                Q3CString fnIn = QFile::encodeName(dirname + QDir::separator() + filename);
 
65
                Q3CString fnIn = QFile::encodeName(getDirInfo()->getDirname() + QDir::separator() + currentFilename());
65
66
                m_fileInfo.read(0); // just to start invalid
66
67
                if (!m_chain) {
67
68
                        m_chain = new FLAC::Metadata::Chain;
121
122
        }
122
123
 
123
124
        if (force) {
124
 
                new_filename = filename;
 
125
                setFilename(currentFilename());
125
126
        }
126
127
}
127
128
 
139
140
bool FlacFile::writeTags(bool force, bool* renamed, bool preserve)
140
141
{
141
142
        if (isChanged() &&
142
 
                !QFileInfo(dirname + QDir::separator() + filename).isWritable()) {
 
143
                !QFileInfo(getDirInfo()->getDirname() + QDir::separator() + currentFilename()).isWritable()) {
143
144
                return false;
144
145
        }
145
146
 
146
 
        if (m_fileRead && (force || changedV2) && m_chain && m_chain->is_valid()) {
 
147
        if (m_fileRead && (force || isTag2Changed()) && m_chain && m_chain->is_valid()) {
147
148
                bool commentsSet = false;
148
149
                m_chain->sort_padding();
149
150
                FLAC::Metadata::Iterator* mdit = new FLAC::Metadata::Iterator;
190
191
                }
191
192
                if (commentsSet &&
192
193
                                m_chain->write(true, preserve)) {
193
 
                        changedV2 = false;
 
194
                        markTag2Changed(false);
194
195
                } else {
195
196
                        return false;
196
197
                }
197
198
        }
198
 
        if (new_filename != filename) {
199
 
                if (!renameFile(filename, new_filename)) {
 
199
        if (getFilename() != currentFilename()) {
 
200
                if (!renameFile(currentFilename(), getFilename())) {
200
201
                        return false;
201
202
                }
 
203
                updateCurrentFilename();
 
204
                // link tags to new file name
 
205
                readTags(true);
202
206
                *renamed = true;
203
207
        }
204
208
        return true;