~ubuntu-branches/ubuntu/utopic/psi/utopic

« back to all changes in this revision

Viewing changes to src/tools/atomicxmlfile/atomicxmlfile.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2009-09-25 17:49:51 UTC
  • mfrom: (6.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090925174951-lvm7kdap82o8xhn3
Tags: 0.13-1
* Updated to upstream version 0.13
* Set Standards-Version to 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
        return true;
68
68
}
69
69
 
70
 
/**
71
 
 * Tries to load \a doc from config file, or if that fails, from a back up.
72
 
 */
73
 
bool AtomicXmlFile::loadDocument(QDomDocument* doc) const
74
 
{
75
 
        Q_ASSERT(doc);
76
70
 
 
71
QStringList AtomicXmlFile::loadCandidateList() const {
77
72
        QStringList fileNames;
78
73
        fileNames << fileName_
79
74
                  << tempFileName()
80
75
                  << backupFileName();
81
 
 
82
 
        foreach(QString fileName, fileNames)
83
 
                if (loadDocument(doc, fileName))
 
76
        return fileNames;
 
77
}
 
78
 
 
79
/**
 
80
 * Tries to load \a doc from config file, or if that fails, from a back up.
 
81
 */
 
82
bool AtomicXmlFile::loadDocument(QDomDocument* doc) const
 
83
{
 
84
        Q_ASSERT(doc);
 
85
 
 
86
 
 
87
        foreach(QString fileName, loadCandidateList()) {
 
88
                if (loadDocument(doc, fileName)) {
84
89
                        return true;
 
90
                }
 
91
        }
85
92
 
86
93
        return false;
87
94
}
143
150
        file.close();
144
151
        return true;
145
152
}
 
153
 
 
154
/**
 
155
 * Check if an AtomicXmlFile exists.
 
156
 * returns true if any of the files loadDocument tries to read exists,
 
157
 * it *doesn't* check that there is at least one uncorupted file.
 
158
 */
 
159
bool AtomicXmlFile::exists(QString fileName) {
 
160
        AtomicXmlFile tmp(fileName);
 
161
 
 
162
        foreach(QString fileName, tmp.loadCandidateList()) {
 
163
                if (QFile::exists(fileName)) {
 
164
                        return true;
 
165
                }
 
166
        }
 
167
        return false;
 
168
}
 
169
 
 
170