From 603b63964079c0bd9ff813fa5f3c6d036cce2766 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Mon, 3 Jun 2019 10:14:04 +0200 Subject: [PATCH] ios: setSshKeys: Create the directory --- ios/Runner/AppDelegate.m | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ios/Runner/AppDelegate.m b/ios/Runner/AppDelegate.m index e83d636a..1675c50b 100644 --- a/ios/Runner/AppDelegate.m +++ b/ios/Runner/AppDelegate.m @@ -329,7 +329,22 @@ NSString* GetDirectoryOfType(NSSearchPathDirectory dir) { return; } + NSArray *sshComponents = [NSArray arrayWithObjects:filesDir, @"ssh", nil]; + NSString* sshDirPath = [NSString pathWithComponents:sshComponents]; + NSError *error = nil; + [[NSFileManager defaultManager] createDirectoryAtPath:sshDirPath + withIntermediateDirectories:NO + attributes:nil + error:&error]; + + if (error != nil) { + NSLog(@"Create directory error: %@", error); + result([FlutterError errorWithCode:@"FAILED" + message:[error localizedDescription] details:nil]); + return; + } + [publicKey writeToFile:sshPublicKeyString atomically:YES encoding:NSUTF8StringEncoding error:&error]; if (error != nil) {