[QuickLook] Create temporary files with NSFileProtectionCompleteUnlessOpen
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jan 2017 23:50:28 +0000 (23:50 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jan 2017 23:50:28 +0000 (23:50 +0000)
commit7532ca67eb9d6ba5a1988d7970769a061ba3b3ff
treee9fe91c0da611322c4fc3dbf0d9af089278774b4
parentbde3edc2dbc16a55bc0544cc4ab535275b16663d
[QuickLook] Create temporary files with NSFileProtectionCompleteUnlessOpen
https://bugs.webkit.org/show_bug.cgi?id=167455
<rdar://problem/12499118>

Reviewed by David Kilzer.

Add the NSFileProtectionKey attribute with value NSFileProtectionCompleteUnlessOpen to
temporary directories created for QuickLook files. Also:

1. Stop calling -[NSFileManager _web_pathWithUniqueFilenameForPath:], since the temporary
directory is already unique and only one file will be placed inside it.
2. Create the temporary file with -[NSFileManager _web_createFileAtPath:contents:attributes:]
instead of with -[NSFileManager _web_createFileAtPathWithIntermediateDirectories:contents:attributes:directoryAttributes:],
since the intermediate directories were already created by createTemporaryDirectory().
3. Explicitly set the temporary directory's attributes with
-[NSFileManager setAttributes:ofItemAtPath:error:].
4. Append the lastPathComponent of fileName to downloadDirectory to ensure fileName isn't
really a relative path.

* loader/ios/QuickLook.h: Stopped declaring QLFileAttributes() and QLDirectoryAttributes().
* loader/ios/QuickLook.mm:
(WebCore::temporaryFileAttributes): Renamed from QLFileAttributes().
(WebCore::temporaryDirectoryAttributes): Renamed from QLDirectoryAttributes().
(WebCore::createTemporaryFileForQuickLook):
(WebCore::QLFileAttributes): Deleted.
(WebCore::QLDirectoryAttributes): Deleted.
* platform/spi/cocoa/NSFileManagerSPI.h: Declared -_web_createFileAtPath:contents:attributes:
and removed declarations for -_web_createFileAtPathWithIntermediateDirectories:contents:attributes:directoryAttributes:
and -_web_pathWithUniqueFilenameForPath:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@211236 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/loader/ios/QuickLook.h
Source/WebCore/loader/ios/QuickLook.mm
Source/WebCore/platform/spi/cocoa/NSFileManagerSPI.h