UTMProcess.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // Copyright © 2019 osy. All rights reserved.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. #import <Foundation/Foundation.h>
  17. @class UTMProcess;
  18. NS_ASSUME_NONNULL_BEGIN
  19. typedef int (*UTMProcessThreadEntry)(UTMProcess *self, int argc, const char * _Nonnull argv[_Nonnull], const char * _Nonnull envp[_Nonnull]);
  20. @interface UTMProcess : NSObject
  21. @property (nonatomic, readonly) BOOL hasRemoteProcess;
  22. @property (nonatomic, readonly) NSURL *libraryURL;
  23. @property (nonatomic) NSArray<NSString *> *argv;
  24. @property (nonatomic, readonly) NSString *arguments;
  25. @property (nonatomic, nullable) NSDictionary<NSString *, NSString *> *environment;
  26. @property (nonatomic) NSInteger status;
  27. @property (nonatomic) NSInteger fatal;
  28. @property (nonatomic) UTMProcessThreadEntry entry;
  29. @property (nonatomic, nullable) NSPipe *standardOutput;
  30. @property (nonatomic, nullable) NSPipe *standardError;
  31. @property (nonatomic, nullable) NSURL *currentDirectoryUrl;
  32. - (instancetype)init;
  33. - (instancetype)initWithArguments:(NSArray<NSString *> *)arguments NS_DESIGNATED_INITIALIZER;
  34. - (void)pushArgv:(nullable NSString *)arg;
  35. - (void)clearArgv;
  36. - (void)startProcess:(nonnull NSString *)name completion:(nonnull void (^)(NSError * _Nullable))completion;
  37. - (void)stopProcess;
  38. - (void)accessDataWithBookmark:(NSData *)bookmark;
  39. - (void)accessDataWithBookmark:(NSData *)bookmark securityScoped:(BOOL)securityScoped completion:(void(^)(BOOL, NSData * _Nullable, NSString * _Nullable))completion;
  40. - (void)stopAccessingPath:(nullable NSString *)path;
  41. - (void)processHasExited:(NSInteger)exitCode message:(nullable NSString *)message;
  42. - (BOOL)didLoadDylib:(void *)handle;
  43. @end
  44. NS_ASSUME_NONNULL_END