You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -138,23 +138,80 @@ open class FileManager : NSObject {
138
138
139
139
You may pass only one of the values from the NSSearchPathDomainMask enumeration, and you may not pass NSAllDomainsMask.
140
140
*/
141
-
openfunc url(for directory:SearchPathDirectory, in domain:SearchPathDomainMask, appropriateFor url:URL?, create shouldCreate:Bool)throws->URL{
142
-
leturls=self.urls(for: directory, in: domain)
143
-
guardlet url = urls.first else{
144
-
// On Apple OSes, this case returns nil without filling in the error parameter; Swift then synthesizes an error rather than trap.
145
-
// We simulate that behavior by throwing a private error.
146
-
throwURLForDirectoryError.directoryUnknown
141
+
openfunc url(for directory:SearchPathDirectory, in domain:SearchPathDomainMask, appropriateFor reference:URL?, create
142
+
shouldCreate:Bool)throws->URL{
143
+
varurl:URL
144
+
145
+
if directory ==.itemReplacementDirectory {
146
+
// We mimic Darwin here — .itemReplacementDirectory has a number of requirements for use and not meeting them is a programmer error and should panic out.
147
+
precondition(domain ==.userDomainMask)
148
+
letreferenceURL= reference!
149
+
150
+
// If the temporary directory and the reference URL are on the same device, use a subdirectory in the temporary directory. Otherwise, use a temporary directory at the same path as the filesystem that contains this file if it's writable. Fall back to the temporary directory if the latter doesn't work.
@available(*, unavailable, message:"Returning an object through an autoreleased pointer is not supported in swift-corelibs-foundation. Use replaceItem(at:withItemAt:backupItemName:options:) instead.", renamed:"replaceItem(at:withItemAt:backupItemName:options:)")
0 commit comments