| 320 | } |
| 321 | |
| 322 | void LibraryCreator::create(QDir dir) |
| 323 | { |
| 324 | dir.setNameFilters(_nameFilter); |
| 325 | dir.setFilter(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); |
| 326 | QFileInfoList list = dir.entryInfoList(); |
| 327 | for (int i = 0; i < list.size(); ++i) { |
| 328 | if (stopRunning) |
| 329 | return; |
| 330 | QFileInfo fileInfo = list.at(i); |
| 331 | QString fileName = fileInfo.fileName(); |
| 332 | #ifdef Q_OS_MACOS |
| 333 | QStringList src = _source.split("/"); |
| 334 | QString filePath = fileInfo.absoluteFilePath(); |
| 335 | QStringList fp = filePath.split("/"); |
| 336 | for (int i = 0; i < src.count(); i++) { |
| 337 | fp.removeFirst(); |
| 338 | } |
| 339 | QString relativePath = "/" + fp.join("/"); |
| 340 | #else |
| 341 | QString relativePath = QDir::cleanPath(fileInfo.absoluteFilePath()).remove(_source); |
| 342 | #endif |
| 343 | if (fileInfo.isDir()) { |
| 344 | QLOG_TRACE() << "Parsing folder" << fileInfo.canonicalPath(); |
| 345 | // se añade al path actual el folder, aún no se sabe si habrá que añadirlo a la base de datos |
| 346 | _currentPathFolders.append(Folder(fileInfo.fileName(), relativePath)); |
| 347 | create(QDir(fileInfo.absoluteFilePath())); |
| 348 | // una vez importada la información del folder, se retira del path actual ya que no volverá a ser visitado |
| 349 | _currentPathFolders.pop_back(); |
| 350 | } else { |
| 351 | QLOG_TRACE() << "Parsing file" << fileInfo.filePath(); |
| 352 | insertComic(relativePath, fileInfo); |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | bool LibraryCreator::checkCover(const QString &hash) |
| 358 | { |