Is it possible to change contents of symlink using Qt
?
Static QFile::link
and non-static one both return false
if linkname filepath is already exist.
I just want to retarget symlink. An analogue of ln -sf
, but crossplatform.
Is it possible to change contents of symlink using Qt
?
Static QFile::link
and non-static one both return false
if linkname filepath is already exist.
I just want to retarget symlink. An analogue of ln -sf
, but crossplatform.
Short answer: No.
To quote the docs:
The solution is rather straightforward: First remove the link explicitely, e. g. using
QFile::remove()
on the link, then useQFile::link()
for the targeted file (as you already did).BTW,
ln -f
with or without-s
is doing nothing else than callingunlink()
. This can be seen conveniently in the BusyBox sources (line 128), while in the GNU coreutils it's a bit more obfuscated.