From a06fd8abc54c436d942430ebaeb7ea3922f5394c Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Tue, 29 Jul 2008 18:13:52 +0000 Subject: [PATCH] Support symlinks, also on Windows! git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25988 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/support/FileName.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp index 0a62dd3eb5..e0a6271c23 100644 --- a/src/support/FileName.cpp +++ b/src/support/FileName.cpp @@ -811,12 +811,19 @@ docstring const FileName::relPath(string const & path) const bool operator==(FileName const & lhs, FileName const & rhs) { - // FIXME: We need to solve these warnings from documentations: - // * This will not compare two different symbolic links pointing to the same - // file. + // FIXME: We need to solve this warning from Qt documentation: // * Long and short file names that refer to the same file on Windows are // treated as if they referred to different files. - return lhs.d->fi == rhs.d->fi; + if (!lhs.d->fi.isSymLink() && !rhs.d->fi.isSymLink()) + return lhs.d->fi == rhs.d->fi; + + QFileInfo fi1(lhs.d->fi); + if (fi1.isSymLink()) + fi1 = QFileInfo(fi1.symLinkTarget()); + QFileInfo fi2(rhs.d->fi); + if (fi2.isSymLink()) + fi2 = QFileInfo(fi2.symLinkTarget()); + return fi1 == fi2; }