MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / foreach

Function foreach

lib/QuaZip/qztest/qztest.cpp:52–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50{
51 QDir curDir;
52 foreach (QString fileName, fileNames) {
53 QString filePath = QDir(dir).filePath(fileName);
54 QDir testDir = QFileInfo(filePath).dir();
55 if (!testDir.exists()) {
56 if (!curDir.mkpath(testDir.path())) {
57 qWarning("Couldn't mkpath %s",
58 testDir.path().toUtf8().constData());
59 return false;
60 }
61 //qDebug() << "Created path " << testDir.path();
62 QFile dirFile(testDir.path());
63 if (!dirFile.setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner | QFileDevice::ExeOwner |
64 QFileDevice::ReadGroup | QFileDevice::ExeGroup |
65 QFileDevice::ReadOther | QFileDevice::ExeOther)) {
66 qWarning("Couldn't set permissions for %s",
67 testDir.path().toUtf8().constData());
68 return false;
69 }
70 }
71 if (fileName.endsWith('/')) {
72 if (!curDir.mkpath(filePath)) {
73 qWarning("Couldn't mkpath %s",
74 fileName.toUtf8().constData());
75 return false;
76 }
77 //qDebug() << "Created path " << filePath;
78 QFile dirFile(filePath);
79 if (!dirFile.setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner | QFileDevice::ExeOwner |
80 QFileDevice::ReadGroup | QFileDevice::ExeGroup |
81 QFileDevice::ReadOther | QFileDevice::ExeOther)) {
82 qWarning("Couldn't set permissions for %s",
83 filePath.toUtf8().constData());
84 return false;
85 }
86 } else {
87 QFile testFile(filePath);
88 if (!testFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
89 qWarning("Couldn't create %s",
90 fileName.toUtf8().constData());
91 return false;
92 }
93 testFile.setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner |
94 QFileDevice::ReadGroup | QFileDevice::ReadOther);
95 if (size == -1) {
96 QTextStream testStream(&testFile);
97 testStream << "This is a test file named " << fileName << quazip_endl;
98 } else {
99 for (int i = 0; i < size; ++i) {
100 testFile.putChar(static_cast<char>('0' + i % 10));
101 }
102 }
103 }
104 }
105 return true;
106}
107

Callers

nothing calls this directly

Calls 10

existsMethod · 0.80
setPermissionsMethod · 0.80
filePathMethod · 0.45
pathMethod · 0.45
openMethod · 0.45
atEndMethod · 0.45
readMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected