Skip to content

Commit

Permalink
Restructure skipExisting checks to reuse previous values
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Swift committed Aug 10, 2024
1 parent fbda47f commit 216ff6d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/attractmode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,17 @@ bool AttractMode::skipExisting(QList<GameEntry> &gameEntries,
gameEntries = oldEntries;

printf("Resolving missing entries...");
fflush(stdout);
int dots = 0;
for (int a = 0; a < gameEntries.length(); ++a) {
dots++;
if (dots % 100 == 0) {
printf(".");
fflush(stdout);
}
QString baseName = gameEntries.at(a).baseName;
for (int b = 0; b < queue->length(); ++b) {
if (gameEntries.at(a).baseName == queue->at(b).completeBaseName()) {
if (baseName == queue->at(b).completeBaseName()) {
queue->removeAt(b);
// We assume baseName is unique, so break after getting first
// hit
Expand Down
1 change: 1 addition & 0 deletions src/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,7 @@ void Cache::readPriorities() {
QFile prioFile(cacheDir.absolutePath() + "/priorities.xml");
printf("Looking for optional '\033[1;33mpriorities.xml\033[0m' file in "
"cache folder... ");
fflush(stdout);
if (prioFile.open(QIODevice::ReadOnly)) {
printf("\033[1;32mFound!\033[0m\n");
if (!prioDoc.setContent(prioFile.readAll())) {
Expand Down
22 changes: 14 additions & 8 deletions src/emulationstation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,32 @@ bool EmulationStation::skipExisting(QList<GameEntry> &gameEntries,
gameEntries = oldEntries;

printf("Resolving missing entries...");
fflush(stdout);
int dots = 0;
for (int a = 0; a < gameEntries.length(); ++a) {
dots++;
if (dots % 100 == 0) {
printf(".");
fflush(stdout);
}

QFileInfo current(gameEntries.at(a).path);
for (int b = 0; b < queue->length(); ++b) {
if (current.isFile()) {
if (current.fileName() == queue->at(b).fileName()) {
if (current.isFile()) {
QString fileName = current.fileName();
for (int b = 0; b < queue->length(); ++b) {
if (fileName == queue->at(b).fileName()) {
queue->removeAt(b);
// We assume filename is unique, so break after getting
// first hit
break;
}
} else if (current.isDir()) {
// Use current.canonicalFilePath here since it is already a
// path. Otherwise it will use the parent folder
if (current.canonicalFilePath() ==
queue->at(b).canonicalPath()) {
}
} else if (current.isDir()) {
// Use current.canonicalFilePath here since it is already a
// path. Otherwise it will use the parent folder
QString filePath = current.canonicalFilePath();
for (int b = 0; b < queue->length(); ++b) {
if (filePath == queue->at(b).canonicalPath()) {
queue->removeAt(b);
// We assume filename is unique, so break after getting
// first hit
Expand All @@ -88,6 +93,7 @@ bool EmulationStation::skipExisting(QList<GameEntry> &gameEntries,
}
}
}

return true;
}

Expand Down
21 changes: 14 additions & 7 deletions src/pegasus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,26 +215,32 @@ bool Pegasus::skipExisting(QList<GameEntry> &gameEntries,
gameEntries = oldEntries;

printf("Resolving missing entries...");
fflush(stdout);
int dots = 0;
for (int a = 0; a < gameEntries.length(); ++a) {
dots++;
if (dots % 100 == 0) {
printf(".");
fflush(stdout);
}

QFileInfo current(gameEntries.at(a).path);
for (int b = 0; b < queue->length(); ++b) {
if (current.isFile()) {
if (current.fileName() == queue->at(b).fileName()) {
if (current.isFile()) {
QString fileName = current.fileName();
for (int b = 0; b < queue->length(); ++b) {
if (fileName == queue->at(b).fileName()) {
queue->removeAt(b);
// We assume filename is unique, so break after getting
// first hit
break;
}
} else if (current.isDir()) {
// Use current.absoluteFilePath here since it is already a path.
// Otherwise it will use the parent folder
if (current.absoluteFilePath() == queue->at(b).absolutePath()) {
}
} else if (current.isDir()) {
// Use current.absoluteFilePath here since it is already a path.
// Otherwise it will use the parent folder
QString filePath = current.absoluteFilePath();
for (int b = 0; b < queue->length(); ++b) {
if (filePath == queue->at(b).absoluteFilePath()) {
queue->removeAt(b);
// We assume filename is unique, so break after getting
// first hit
Expand All @@ -243,6 +249,7 @@ bool Pegasus::skipExisting(QList<GameEntry> &gameEntries,
}
}
}

return true;
}

Expand Down

0 comments on commit 216ff6d

Please sign in to comment.