summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfilesystemengine_unix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qfilesystemengine_unix.cpp')
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 11d421591a..feb86d2895 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -250,6 +250,26 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry,
return QFileSystemEntry(ret);
}
}
+
+# elif defined(Q_OS_ANDROID)
+ // On some Android versions, realpath() will return a path even if it does not exist
+ // To work around this, we check existence in advance.
+ if (!data.hasFlags(QFileSystemMetaData::ExistsAttribute))
+ fillMetaData(entry, data, QFileSystemMetaData::ExistsAttribute);
+
+ if (!data.exists()) {
+ ret = 0;
+ errno = ENOENT;
+ } else {
+ ret = (char*)malloc(PATH_MAX + 1);
+ if (realpath(entry.nativeFilePath().constData(), (char*)ret) == 0) {
+ const int savedErrno = errno; // errno is checked below, and free() might change it
+ free(ret);
+ errno = savedErrno;
+ ret = 0;
+ }
+ }
+
# else
# if _POSIX_VERSION >= 200801L
ret = realpath(entry.nativeFilePath().constData(), (char*)0);