diff options
author | Rainer Keller <Rainer.Keller@qt.io> | 2016-10-18 10:03:04 +0200 |
---|---|---|
committer | Rainer Keller <Rainer.Keller@qt.io> | 2016-10-18 11:48:35 +0000 |
commit | 271cf667d74a91acf3c203180526ac449ba0c49a (patch) | |
tree | af19ef626dff8d29872e02e1fd64cc849d275d27 | |
parent | 1e3c96e0e4f28a072c835775f7fdc310eb3b4f28 (diff) |
Fix setting default application with invalid symlink
Change-Id: Ia99140c0a8f8cf201eeaad352c36becbb1f6636f
Reviewed-by: Karim Pinter <karim.pinter@theqtcompany.com>
Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
-rw-r--r-- | main.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -245,14 +245,32 @@ bool parseConfigFileDirectory(Config *config, const QString &dirName) static bool removeDefault() { - if (QFile::exists(B2QT_PREFIX)) { + QFileInfo fi(B2QT_PREFIX); + + if (fi.isSymLink()) { if (!QFile::remove(B2QT_PREFIX)) { fprintf(stderr, "Could not remove default application.\n"); return false; } sync(); + return true; } - return true; + + if (fi.isDir()) { + fprintf(stderr, "Could not remove default application because '" B2QT_PREFIX "' is a directory. It should be a symlink.\n"); + return false; + } + + if (fi.isFile()) { + fprintf(stderr, "Could not remove default application because '" B2QT_PREFIX "' is a file. It should be a symlink.\n"); + return false; + } + + if (!fi.exists()) { + return true; + } + + return false; } static bool makeDefault(const QString &filepath) |