From 827232a74d0910252df1ea226d4db54c3a029568 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 10 Apr 2015 10:58:54 +0200 Subject: [PATCH] qstandardpaths_ios: return writable locations for Fonts, Music, Movies, Pictures and Download MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QStandardPaths::writableLocation() for FontsLocation, MusicLocation, MoviesLocation, PicturesLocation and DownloadLocation all return directories that point inside the sandbox, but don't exist and cannot be created. In other words, they are not usable for writing or anything else. According to iOS File System Programming Guide (*), such files should instead be located inside Documents, or sub-directories within. (*) https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW4 Task-number: QTBUG-42804 Change-Id: I54145af8058d68e0346d29de5a2bec18dafc21e7 Reviewed-by: Tor Arne Vestbø --- src/corelib/io/qstandardpaths_ios.mm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/corelib/io/qstandardpaths_ios.mm b/src/corelib/io/qstandardpaths_ios.mm index 27d28526c2..4af1d93589 100644 --- a/src/corelib/io/qstandardpaths_ios.mm +++ b/src/corelib/io/qstandardpaths_ios.mm @@ -62,19 +62,22 @@ QString QStandardPaths::writableLocation(StandardLocation type) location = pathForDirectory(NSDocumentDirectory); break; case FontsLocation: - location = bundlePath() + QLatin1String("/.fonts"); + location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/.fonts"); break; case ApplicationsLocation: location = pathForDirectory(NSApplicationDirectory); break; case MusicLocation: - location = pathForDirectory(NSMusicDirectory); + // NSMusicDirectory points to a non-existing write-protected path. Use sensible fallback. + location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/Music"); break; case MoviesLocation: - location = pathForDirectory(NSMoviesDirectory); + // NSMoviesDirectory points to a non-existing write-protected path. Use sensible fallback. + location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/Movies"); break; case PicturesLocation: - location = pathForDirectory(NSPicturesDirectory); + // NSPicturesDirectory points to a non-existing write-protected path. Use sensible fallback. + location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/Pictures"); break; case TempLocation: location = QString::fromNSString(NSTemporaryDirectory()); @@ -99,7 +102,8 @@ QString QStandardPaths::writableLocation(StandardLocation type) location = pathForDirectory(NSDocumentDirectory); break; case DownloadLocation: - location = pathForDirectory(NSDownloadsDirectory); + // NSDownloadsDirectory points to a non-existing write-protected path. + location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/Download"); break; default: break;