[英]Qt5, symbolic link to a folder
A dupe-ish question of this question , which (possibly) has got an outdated answer, as I can't get it to work in Qt5. 这个问题的重复问题 ,(可能)答案已经过时,因为我无法在Qt5中使用它。
I wish to create a symbolic link to a folder for a result similar to QFile::link()
. 我希望创建指向文件夹的符号链接,以获得类似于
QFile::link()
。 Given that QDir
doesn't have an equivalent function, QProcess
(or an external library) seems like the way out if I'm up to snuff. 鉴于
QDir
没有等效功能,如果我不敢尝试, QProcess
(或外部库)似乎是出路。 How would this be managed in Qt5? 如何在Qt5中进行管理?
Big thanks in advance. 预先非常感谢。
There are shortcuts and hardlinks on Windows. Windows上有快捷方式和硬链接。 I think
mklink
refers to hardlinks. 我认为
mklink
指的是硬链接。
It works for shortcuts: 它适用于快捷方式:
#include <QCoreApplication>
#include <QFile>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QFile dir("D:\\source-dir");
bool ok = dir.link("D:\\target-dir.lnk");
if (ok)
{
qDebug() << "yeah!";
return 0;
}
else {
qDebug() << "Did not work :(";
return 1;
}
}
In this case you will find a shortcut in the Explorer but you cannot access the file D:\\source-dir\\Bitmap.bmp
by typing D:\\target-dir\\Bitmap.bmp
在这种情况下,您将在资源管理器中找到一个快捷方式,但无法通过键入
D:\\target-dir\\Bitmap.bmp
来访问文件D:\\source-dir\\Bitmap.bmp
D:\\target-dir\\Bitmap.bmp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.