Changeset View
Changeset View
Standalone View
Standalone View
kerfuffle/cliproperties.cpp
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
42 | 42 | | |||
43 | QStringList CliProperties::addArgs(const QString &archive, const QStringList &files, const QString &password, bool headerEncryption, int compressionLevel, const QString &compressionMethod, const QString &encryptionMethod, ulong volumeSize) | 43 | QStringList CliProperties::addArgs(const QString &archive, const QStringList &files, const QString &password, bool headerEncryption, int compressionLevel, const QString &compressionMethod, const QString &encryptionMethod, ulong volumeSize) | ||
44 | { | 44 | { | ||
45 | if (!encryptionMethod.isEmpty()) { | 45 | if (!encryptionMethod.isEmpty()) { | ||
46 | Q_ASSERT(!password.isEmpty()); | 46 | Q_ASSERT(!password.isEmpty()); | ||
47 | } | 47 | } | ||
48 | 48 | | |||
49 | QStringList args; | 49 | QStringList args; | ||
50 | foreach (const QString &s, m_addSwitch) { | 50 | for (const QString &s : qAsConst(m_addSwitch)) { | ||
51 | args << s; | 51 | args << s; | ||
52 | } | 52 | } | ||
53 | if (!password.isEmpty()) { | 53 | if (!password.isEmpty()) { | ||
54 | args << substitutePasswordSwitch(password, headerEncryption); | 54 | args << substitutePasswordSwitch(password, headerEncryption); | ||
55 | } | 55 | } | ||
56 | if (compressionLevel > -1) { | 56 | if (compressionLevel > -1) { | ||
57 | args << substituteCompressionLevelSwitch(compressionLevel); | 57 | args << substituteCompressionLevelSwitch(compressionLevel); | ||
58 | } | 58 | } | ||
Show All 11 Lines | |||||
70 | 70 | | |||
71 | args.removeAll(QString()); | 71 | args.removeAll(QString()); | ||
72 | return args; | 72 | return args; | ||
73 | } | 73 | } | ||
74 | 74 | | |||
75 | QStringList CliProperties::commentArgs(const QString &archive, const QString &commentfile) | 75 | QStringList CliProperties::commentArgs(const QString &archive, const QString &commentfile) | ||
76 | { | 76 | { | ||
77 | QStringList args; | 77 | QStringList args; | ||
78 | foreach (const QString &s, substituteCommentSwitch(commentfile)) { | 78 | const QStringList commentSwitches = substituteCommentSwitch(commentfile); | ||
79 | for (const QString &s : commentSwitches) { | ||||
elvisangelaccio: Please call this variable `commentSwitches` | |||||
79 | args << s; | 80 | args << s; | ||
80 | } | 81 | } | ||
81 | args << archive; | 82 | args << archive; | ||
82 | 83 | | |||
83 | args.removeAll(QString()); | 84 | args.removeAll(QString()); | ||
84 | return args; | 85 | return args; | ||
85 | } | 86 | } | ||
86 | 87 | | |||
87 | QStringList CliProperties::deleteArgs(const QString &archive, const QVector<Archive::Entry*> &files, const QString &password) | 88 | QStringList CliProperties::deleteArgs(const QString &archive, const QVector<Archive::Entry*> &files, const QString &password) | ||
88 | { | 89 | { | ||
89 | QStringList args; | 90 | QStringList args; | ||
90 | args << m_deleteSwitch; | 91 | args << m_deleteSwitch; | ||
91 | if (!password.isEmpty()) { | 92 | if (!password.isEmpty()) { | ||
92 | args << substitutePasswordSwitch(password); | 93 | args << substitutePasswordSwitch(password); | ||
93 | } | 94 | } | ||
94 | args << archive; | 95 | args << archive; | ||
95 | foreach (const Archive::Entry *e, files) { | 96 | for (const Archive::Entry *e : files) { | ||
96 | args << e->fullPath(NoTrailingSlash); | 97 | args << e->fullPath(NoTrailingSlash); | ||
97 | } | 98 | } | ||
98 | 99 | | |||
99 | args.removeAll(QString()); | 100 | args.removeAll(QString()); | ||
100 | return args; | 101 | return args; | ||
101 | } | 102 | } | ||
102 | 103 | | |||
103 | QStringList CliProperties::extractArgs(const QString &archive, const QStringList &files, bool preservePaths, const QString &password) | 104 | QStringList CliProperties::extractArgs(const QString &archive, const QStringList &files, bool preservePaths, const QString &password) | ||
Show All 14 Lines | 105 | { | |||
118 | 119 | | |||
119 | args.removeAll(QString()); | 120 | args.removeAll(QString()); | ||
120 | return args; | 121 | return args; | ||
121 | } | 122 | } | ||
122 | 123 | | |||
123 | QStringList CliProperties::listArgs(const QString &archive, const QString &password) | 124 | QStringList CliProperties::listArgs(const QString &archive, const QString &password) | ||
124 | { | 125 | { | ||
125 | QStringList args; | 126 | QStringList args; | ||
126 | foreach (const QString &s, m_listSwitch) { | 127 | for (const QString &s : qAsConst(m_listSwitch)) { | ||
127 | args << s; | 128 | args << s; | ||
128 | } | 129 | } | ||
129 | 130 | | |||
130 | const auto encryptionType = ArchiveFormat::fromMetadata(m_mimeType, m_metaData).encryptionType(); | 131 | const auto encryptionType = ArchiveFormat::fromMetadata(m_mimeType, m_metaData).encryptionType(); | ||
131 | if (!password.isEmpty() && encryptionType == Archive::EncryptionType::HeaderEncrypted) { | 132 | if (!password.isEmpty() && encryptionType == Archive::EncryptionType::HeaderEncrypted) { | ||
132 | args << substitutePasswordSwitch(password); | 133 | args << substitutePasswordSwitch(password); | ||
133 | } | 134 | } | ||
134 | args << archive; | 135 | args << archive; | ||
135 | 136 | | |||
136 | args.removeAll(QString()); | 137 | args.removeAll(QString()); | ||
137 | return args; | 138 | return args; | ||
138 | } | 139 | } | ||
139 | 140 | | |||
140 | QStringList CliProperties::moveArgs(const QString &archive, const QVector<Archive::Entry*> &entries, Archive::Entry *destination, const QString &password) | 141 | QStringList CliProperties::moveArgs(const QString &archive, const QVector<Archive::Entry*> &entries, Archive::Entry *destination, const QString &password) | ||
141 | { | 142 | { | ||
142 | QStringList args; | 143 | QStringList args; | ||
143 | args << m_moveSwitch; | 144 | args << m_moveSwitch; | ||
144 | if (!password.isEmpty()) { | 145 | if (!password.isEmpty()) { | ||
145 | args << substitutePasswordSwitch(password); | 146 | args << substitutePasswordSwitch(password); | ||
146 | } | 147 | } | ||
147 | args << archive; | 148 | args << archive; | ||
148 | if (entries.count() > 1) { | 149 | if (entries.count() > 1) { | ||
149 | foreach (const Archive::Entry *file, entries) { | 150 | for (const Archive::Entry *file : entries) { | ||
150 | args << file->fullPath(NoTrailingSlash) << destination->fullPath() + file->name(); | 151 | args << file->fullPath(NoTrailingSlash) << destination->fullPath() + file->name(); | ||
151 | } | 152 | } | ||
152 | } else { | 153 | } else { | ||
153 | args << entries.at(0)->fullPath(NoTrailingSlash) << destination->fullPath(NoTrailingSlash); | 154 | args << entries.at(0)->fullPath(NoTrailingSlash) << destination->fullPath(NoTrailingSlash); | ||
154 | } | 155 | } | ||
155 | 156 | | |||
156 | args.removeAll(QString()); | 157 | args.removeAll(QString()); | ||
157 | return args; | 158 | return args; | ||
158 | } | 159 | } | ||
159 | 160 | | |||
160 | QStringList CliProperties::testArgs(const QString &archive, const QString &password) | 161 | QStringList CliProperties::testArgs(const QString &archive, const QString &password) | ||
161 | { | 162 | { | ||
162 | QStringList args; | 163 | QStringList args; | ||
163 | foreach (const QString &s, m_testSwitch) { | 164 | for (const QString &s : qAsConst(m_testSwitch)) { | ||
164 | args << s; | 165 | args << s; | ||
165 | } | 166 | } | ||
166 | if (!password.isEmpty()) { | 167 | if (!password.isEmpty()) { | ||
167 | args << substitutePasswordSwitch(password); | 168 | args << substitutePasswordSwitch(password); | ||
168 | } | 169 | } | ||
169 | args << archive; | 170 | args << archive; | ||
170 | 171 | | |||
171 | args.removeAll(QString()); | 172 | args.removeAll(QString()); | ||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | 277 | { | |||
287 | 288 | | |||
288 | multiVolumeSwitch.replace(QLatin1String("$VolumeSize"), QString::number(volumeSize)); | 289 | multiVolumeSwitch.replace(QLatin1String("$VolumeSize"), QString::number(volumeSize)); | ||
289 | 290 | | |||
290 | return multiVolumeSwitch; | 291 | return multiVolumeSwitch; | ||
291 | } | 292 | } | ||
292 | 293 | | |||
293 | bool CliProperties::isTestPassedMsg(const QString &line) | 294 | bool CliProperties::isTestPassedMsg(const QString &line) | ||
294 | { | 295 | { | ||
295 | foreach(const QString &rx, m_testPassedPatterns) { | 296 | for (const QString &rx : qAsConst(m_testPassedPatterns)) { | ||
296 | if (QRegularExpression(rx).match(line).hasMatch()) { | 297 | if (QRegularExpression(rx).match(line).hasMatch()) { | ||
297 | return true; | 298 | return true; | ||
298 | } | 299 | } | ||
299 | } | 300 | } | ||
300 | return false; | 301 | return false; | ||
301 | } | 302 | } | ||
302 | 303 | | |||
303 | } | 304 | } |
Please call this variable commentSwitches