| 401 | } |
| 402 | |
| 403 | void test_hard_link() |
| 404 | { |
| 405 | QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); |
| 406 | auto f = [&folder]() { |
| 407 | // use working dir to prevent makeing a hard link to a tmpfs or across devices |
| 408 | QTemporaryDir tempDir("./tmp"); |
| 409 | tempDir.setAutoRemove(true); |
| 410 | qDebug() << "From:" << folder << "To:" << tempDir.path(); |
| 411 | |
| 412 | QDir target_dir(FS::PathCombine(tempDir.path(), "test_folder")); |
| 413 | qDebug() << tempDir.path(); |
| 414 | qDebug() << target_dir.path(); |
| 415 | FS::create_link lnk(folder, target_dir.path()); |
| 416 | lnk.useHardLinks(true); |
| 417 | lnk.debug(true); |
| 418 | if (!lnk()) { |
| 419 | qDebug() << "Link Failed!" << lnk.getOSError().value() << lnk.getOSError().message().c_str(); |
| 420 | } |
| 421 | |
| 422 | for (auto entry : target_dir.entryList()) { |
| 423 | qDebug() << entry; |
| 424 | QFileInfo entry_lnk_info(target_dir.filePath(entry)); |
| 425 | QVERIFY(!entry_lnk_info.isSymLink()); |
| 426 | QFileInfo entry_orig_info(QDir(folder).filePath(entry)); |
| 427 | if (!entry_lnk_info.isDir()) { |
| 428 | qDebug() << "hard link equivalency?" << entry_lnk_info.absoluteFilePath() << "vs" << entry_orig_info.absoluteFilePath(); |
| 429 | QVERIFY(fs::equivalent(fs::path(StringUtils::toStdString(entry_lnk_info.absoluteFilePath())), |
| 430 | fs::path(StringUtils::toStdString(entry_orig_info.absoluteFilePath())))); |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | QFileInfo lnk_info(target_dir.path()); |
| 435 | QVERIFY(lnk_info.exists()); |
| 436 | QVERIFY(!lnk_info.isSymLink()); |
| 437 | |
| 438 | QVERIFY(target_dir.entryList().contains("pack.mcmeta")); |
| 439 | QVERIFY(target_dir.entryList().contains("assets")); |
| 440 | }; |
| 441 | |
| 442 | // first try variant without trailing / |
| 443 | QVERIFY(!folder.endsWith('/')); |
| 444 | f(); |
| 445 | |
| 446 | // then variant with trailing / |
| 447 | folder.append('/'); |
| 448 | QVERIFY(folder.endsWith('/')); |
| 449 | f(); |
| 450 | } |
| 451 | |
| 452 | void test_link_with_blacklist() |
| 453 | { |
nothing calls this directly
no test coverage detected