MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / findBackups

Function findBackups

Engine/Project.cpp:499–528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

497}
498
499static QStringList
500findBackups(const QString & filePath)
501{
502 QStringList ret;
503 if ( QFile::exists(filePath) ) {
504 ret.append(filePath);
505 }
506 // find files matching filePath.~[0-9]+~
507 QRegExp rx(QString::fromUtf8("\\.~(\\d+)~$"));
508 QFileInfo fileInfo(filePath);
509 QString fileName = fileInfo.fileName();
510 QDirIterator it(fileInfo.dir());
511 while (it.hasNext()) {
512 QString filename = it.next();
513 QFileInfo file(filename);
514
515 if (file.isDir()) { // Check if it's a dir
516 continue;
517 }
518
519 // If the filename contains target string - put it in the hitlist
520 QString fn = file.fileName();
521 if (fn.startsWith(fileName) && rx.lastIndexIn(fn) == fileName.size()) {
522 ret.append(file.filePath());
523 }
524 }
525 ret.sort();
526
527 return ret;
528}
529
530// if filePath matches .*\.~[0-9]+~, increment the backup number
531// else append .~1~

Callers 1

saveProjectInternalMethod · 0.85

Calls 4

appendMethod · 0.80
isDirMethod · 0.80
sizeMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected