forked from alvincrisuy/clashX
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16167b1
commit 3cb5d25
Showing
7 changed files
with
86 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// CommonUtils.h | ||
// ClashX | ||
// | ||
// Created by yicheng on 2020/4/2. | ||
// Copyright © 2020 west2online. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface CommonUtils : NSObject | ||
+ (NSString *)runCommand:(NSString *)path args:(nullable NSArray *)args; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// CommonUtils.m | ||
// ClashX | ||
// | ||
// Created by yicheng on 2020/4/2. | ||
// Copyright © 2020 west2online. All rights reserved. | ||
// | ||
|
||
#import "CommonUtils.h" | ||
|
||
@implementation CommonUtils | ||
+ (NSString *)runCommand:(NSString *)path args:(nullable NSArray *)args { | ||
NSTask *task = [[NSTask alloc] init]; | ||
[task setLaunchPath:path]; | ||
[task setArguments:args]; | ||
|
||
NSPipe *pipe = [NSPipe pipe]; | ||
[task setStandardOutput: pipe]; | ||
|
||
NSFileHandle *file = [pipe fileHandleForReading]; | ||
|
||
[task launch]; | ||
|
||
NSData *data = [file readDataToEndOfFile]; | ||
NSString *output = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding]; | ||
#if DEBUG | ||
NSLog(@"%@",output); | ||
#endif | ||
return output; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters