| 316 | } |
| 317 | |
| 318 | void FileAccess::loadData() |
| 319 | { |
| 320 | m_fileInfo.setCaching(true); |
| 321 | |
| 322 | if(parent() == nullptr) |
| 323 | m_baseDir.setPath(m_fileInfo.absoluteFilePath()); |
| 324 | else |
| 325 | m_baseDir = m_pParent->m_baseDir; |
| 326 | |
| 327 | //convert to absolute path that doesn't depend on the current directory. |
| 328 | m_fileInfo.makeAbsolute(); |
| 329 | m_bSymLink = m_fileInfo.isSymLink(); |
| 330 | |
| 331 | m_bFile = m_fileInfo.isFile(); |
| 332 | m_bDir = m_fileInfo.isDir(); |
| 333 | m_bExists = m_fileInfo.exists(); |
| 334 | m_size = m_fileInfo.size(); |
| 335 | m_modificationTime = m_fileInfo.lastModified(); |
| 336 | m_bHidden = m_fileInfo.isHidden(); |
| 337 | |
| 338 | m_bWritable = m_fileInfo.isWritable(); |
| 339 | m_bReadable = m_fileInfo.isReadable(); |
| 340 | m_bExecutable = m_fileInfo.isExecutable(); |
| 341 | |
| 342 | m_name = m_fileInfo.fileName(); |
| 343 | if(isLocal() && m_name.isEmpty()) |
| 344 | { |
| 345 | m_name = m_fileInfo.absoluteDir().dirName(); |
| 346 | } |
| 347 | |
| 348 | if(isLocal() && m_bSymLink) |
| 349 | { |
| 350 | m_linkTarget = m_fileInfo.symLinkTarget(); |
| 351 | |
| 352 | #ifndef Q_OS_WIN |
| 353 | // Unfortunately Qt5 symLinkTarget/readLink always return an absolute path, even if the link is relative |
| 354 | std::unique_ptr<char[]> s = std::make_unique<char[]>(PATH_MAX + 1); |
| 355 | ssize_t len = readlink(QFile::encodeName(absoluteFilePath()).constData(), s.get(), PATH_MAX); |
| 356 | if(len > 0) |
| 357 | { |
| 358 | s[len] = '\0'; |
| 359 | m_linkTarget = QFile::decodeName(s.get()); |
| 360 | } |
| 361 | #endif |
| 362 | |
| 363 | m_bBrokenLink = !QFileInfo::exists(m_linkTarget); |
| 364 | //We want to know if the link itself exists |
| 365 | if(m_bBrokenLink) |
| 366 | m_bExists = true; |
| 367 | |
| 368 | if(!m_modificationTime.isValid()) |
| 369 | m_modificationTime = QDateTime::fromMSecsSinceEpoch(0); |
| 370 | } |
| 371 | |
| 372 | realFile = QSharedPointer<QFile>::create(absoluteFilePath()); |
| 373 | m_bValidData = true; |
| 374 | } |
| 375 |
nothing calls this directly
no test coverage detected