Skip to content

Commit

Permalink
Add support for mounting folders from iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahPeeters authored and tbodt committed Apr 12, 2020
1 parent c1ab200 commit 68340ac
Show file tree
Hide file tree
Showing 9 changed files with 548 additions and 20 deletions.
9 changes: 7 additions & 2 deletions app/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
#include <netdb.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import "AppDelegate.h"
#import "AppGroup.h"
#import "iOSFS.h"
#import "SceneDelegate.h"
#import "PasteboardDevice.h"
#import "LocationDevice.h"
#import "TerminalViewController.h"
#import "UserPreferences.h"
#import "AppGroup.h"
#include "kernel/init.h"
#include "kernel/calls.h"
#include "fs/dyndev.h"
Expand Down Expand Up @@ -137,7 +139,9 @@ - (int)boot {
die_handler = ios_handle_die;
NSString *sockTmp = [NSTemporaryDirectory() stringByAppendingString:@"ishsock"];
sock_tmp_prefix = strdup(sockTmp.UTF8String);


filesystems[IOS_FILESYSTEM_ID] = &iosfs;
filesystems[IOS_UNSAFE_FILESYSTEM_ID] = &iosfs_unsafe;
tty_drivers[TTY_CONSOLE_MAJOR] = &ios_console_driver;
set_console_device(TTY_CONSOLE_MAJOR, 1);
err = create_stdio("/dev/console", TTY_CONSOLE_MAJOR, 1);
Expand Down Expand Up @@ -237,6 +241,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
if (self.window != nil) {
// For iOS <13, where the app delegate owns the window instead of the scene
TerminalViewController *vc = (TerminalViewController *) self.window.rootViewController;
currentTerminalViewController = vc;
[vc startNewSession];
}
return YES;
Expand Down
3 changes: 3 additions & 0 deletions app/SceneDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
//

#import <UIKit/UIKit.h>
#import "TerminalViewController.h"

NS_ASSUME_NONNULL_BEGIN

extern TerminalViewController *currentTerminalViewController;

API_AVAILABLE(ios(13))
@interface SceneDelegate : UIResponder <UIWindowSceneDelegate>

Expand Down
16 changes: 15 additions & 1 deletion app/SceneDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
//

#import "SceneDelegate.h"
#import "TerminalViewController.h"

TerminalViewController *currentTerminalViewController = NULL;

@interface SceneDelegate ()

Expand Down Expand Up @@ -40,4 +41,17 @@ - (NSUserActivity *)stateRestorationActivityForScene:(UIScene *)scene {
return activity;
}

- (void)sceneDidBecomeActive:(UIScene *)scene {
TerminalViewController *terminalViewController = (TerminalViewController *) self.window.rootViewController;;
currentTerminalViewController = terminalViewController;
}

- (void)sceneWillResignActive:(UIScene *)scene {
TerminalViewController *terminalViewController = (TerminalViewController *) self.window.rootViewController;

if (currentTerminalViewController == terminalViewController) {
currentTerminalViewController = NULL;
}
}

@end
9 changes: 9 additions & 0 deletions app/iOSFS.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// iOSFS.h
// iSH
//
// Created by Noah Peeters on 26.10.19.
//

extern const struct fs_ops iosfs;
extern const struct fs_ops iosfs_unsafe;
Loading

0 comments on commit 68340ac

Please sign in to comment.