MCPcopy Create free account
hub / github.com/KDE/krusader / createFileItem

Method createFileItem

app/FileSystem/virtualfilesystem.cpp:295–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293}
294
295FileItem *VirtualFileSystem::createFileItem(const QUrl &url)
296{
297 if (url.scheme() == "virt") { // return a virtual directory in root
298 QString path = url.path().mid(1);
299 if (path.isEmpty())
300 path = '/';
301 return FileItem::createVirtualDir(path, url);
302 }
303
304 const QUrl directory = url.adjusted(QUrl::RemoveFilename);
305
306 if (url.isLocalFile()) {
307 QFileInfo file(url.path());
308 return file.exists() ? FileSystem::createLocalFileItem(url.fileName(), directory.path(), true) : nullptr;
309 }
310
311 KIO::StatJob *statJob = KIO::stat(url, KIO::HideProgressInfo);
312 connect(statJob, &KIO::Job::result, this, &VirtualFileSystem::slotStatResult);
313
314 // ugly: we have to wait here until the stat job is finished
315 QEventLoop eventLoop;
316 connect(statJob, &KJob::finished, &eventLoop, &QEventLoop::quit);
317 eventLoop.exec(); // blocking until quit()
318
319 if (_fileEntry.count() == 0) {
320 return nullptr; // stat job failed
321 }
322
323 if (!_fileEntry.contains(KIO::UDSEntry::UDS_MODIFICATION_TIME)) {
324 // TODO this also happens for FTP directories
325 return nullptr; // file not found
326 }
327
328 return FileSystem::createFileItemFromKIO(_fileEntry, directory, true);
329}
330
331KConfig &VirtualFileSystem::getVirtDB()
332{

Callers

nothing calls this directly

Calls 8

statClass · 0.85
midMethod · 0.80
isEmptyMethod · 0.80
existsMethod · 0.80
fileNameMethod · 0.80
pathMethod · 0.45
execMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected