File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -122,7 +122,12 @@ public final class Drawing: Reference {
122122 author: String ? = nil ,
123123 creator: String ? = nil ) -> Bool {
124124 // First check if we can write to the URL
125- guard FileManager . default. isWritableFile ( atPath: url. path) else {
125+ var dir : ObjCBool = false
126+ let parent = url. deletingLastPathComponent ( ) . path
127+ guard FileManager . default. fileExists ( atPath: parent, isDirectory: & dir) && dir. boolValue else {
128+ return false
129+ }
130+ guard FileManager . default. isWritableFile ( atPath: parent) else {
126131 return false
127132 }
128133 // Define a media box
Original file line number Diff line number Diff line change @@ -83,6 +83,15 @@ public final class DrawingDocument: Reference {
8383
8484 /// Save the collection as a PDF file to URL `url`.
8585 public func saveAsPDF( url: URL ) -> Bool {
86+ // First check if we can write to the URL
87+ var dir : ObjCBool = false
88+ let parent = url. deletingLastPathComponent ( ) . path
89+ guard FileManager . default. fileExists ( atPath: parent, isDirectory: & dir) && dir. boolValue else {
90+ return false
91+ }
92+ guard FileManager . default. isWritableFile ( atPath: parent) else {
93+ return false
94+ }
8695 // Define PDF document information
8796 var pdfInfo : NSMutableDictionary = [
8897 kCGPDFContextAllowsPrinting: ( self . allowsPrinting ? kCFBooleanTrue : kCFBooleanFalse) as Any ,
You can’t perform that action at this time.
0 commit comments