[Qt-interest] Symbolic link real value?

Lukas Lipavsky llipavsky at suse.cz
Tue Jul 28 14:02:36 CEST 2009


On 28.07. 13:57, Pau Garcia i Quiles wrote:
> On Tue, Jul 28, 2009 at 1:52 PM, Lukas Lipavsky<llipavsky at suse.cz> wrote:
> > On 28.07. 13:47, Pau Garcia i Quiles wrote:
> >> On Tue, Jul 28, 2009 at 1:40 PM, Lukas Lipavsky<llipavsky at suse.cz> wrote:
> >> > Hi,
> >> >
> >> > is there any way to get the path symlink (in linux) is pointing to? But
> >> > I need the real value - e.g. '../../dir/file'
> >> >
> >> > All I found so far was QFileInfo::symLinkTarget() but it returns
> >> > *absolute* path, which is useless for me.
> >> >
> >> > Is there any way to get this information from the Qt library (better
> >> > than calling ls)?
> >>
> >> Use QDir::relativeFilePath with the current directory (QDir::current() )
> >>
> >> http://doc.trolltech.com/4.5/qdir.html#relativeFilePath
> >> http://doc.trolltech.com/4.5/qdir.html#current
> >
> > thanks,
> >
> > but unfortunatelly, this won't help me either. To make it more clean, I
> > am writing a synchronization app that would synchronize the content of
> > two directories (on different hosts). For this I need to be able to
> > synchronize the symbolic link to the same state as it is, so if it's
> > absolute, keep it absolute, if it's relative, keep it relative...
> >
> > Is there any way to do this?
> 
> Match the result of QFile::symLinkTarget() against "..":
> - It it contains "..", it's a relative symlink and you should then use
> QDir::relativeFilePath() and Qdir::current() to get in the destination
> machine the same path as in the origin machine.
> - It it does not contain "..", it's an absolute symlink and the output
> of QFile::symLinkTarget() is what you want.

No, it does not:
1. relative path does not need to contain '..'
2. even if it worked, symLinkTarget() never returns path with '..',
because it always return absolute path. If it would return relative
path, that would be exactly what I need.


Best regards,
-- 
Lukas Lipavsky, QA Developer

GPG Key ID: FF55774A
Key fingerprint = 5BEB 6AF2 9653 638E EC0E  7E73 9A11 2BC5 FF55 774A
---------------------------------------------------
SUSE LINUX, s.r.o.        e-mail: llipavsky at suse.cz
Lihovarska 1060/12        tel: +420 284 028 969
190 00 Prague 9           
Czech Republic            
---------------------------------------------------




More information about the Qt-interest-old mailing list