@@ -114,6 +114,7 @@ open class Process: NSObject {
114
114
static var done = false
115
115
static let lock = NSLock ( )
116
116
}
117
+
117
118
Once . lock. synchronized {
118
119
if !Once. done {
119
120
let thread = Thread {
@@ -164,26 +165,52 @@ open class Process: NSObject {
164
165
165
166
}
166
167
167
- // these methods can only be set before a launch
168
+ // These methods can only be set before a launch.
169
+
168
170
open var launchPath : String ?
169
171
open var arguments : [ String ] ?
170
172
open var environment : [ String : String ] ? // if not set, use current
171
173
172
174
open var currentDirectoryPath : String = FileManager . default. currentDirectoryPath
173
175
174
- // standard I/O channels; could be either a FileHandle or a Pipe
176
+ open var executableURL : URL ? {
177
+ get {
178
+ guard let launchPath = self . launchPath else {
179
+ return nil
180
+ }
181
+
182
+ return URL ( fileURLWithPath: launchPath)
183
+ }
184
+ set {
185
+ self . launchPath = newValue? . path
186
+ }
187
+ }
188
+
189
+ open var currentDirectoryURL : URL {
190
+ get {
191
+ return URL ( fileURLWithPath: self . currentDirectoryPath)
192
+ }
193
+ set {
194
+ self . currentDirectoryPath = newValue. path
195
+ }
196
+ }
197
+
198
+ // Standard I/O channels; could be either a FileHandle or a Pipe
199
+
175
200
open var standardInput : Any ? {
176
201
willSet {
177
202
precondition ( newValue is Pipe || newValue is FileHandle ,
178
203
" standardInput must be either Pipe or FileHandle " )
179
204
}
180
205
}
206
+
181
207
open var standardOutput : Any ? {
182
208
willSet {
183
209
precondition ( newValue is Pipe || newValue is FileHandle ,
184
210
" standardOutput must be either Pipe or FileHandle " )
185
211
}
186
212
}
213
+
187
214
open var standardError : Any ? {
188
215
willSet {
189
216
precondition ( newValue is Pipe || newValue is FileHandle ,
@@ -198,7 +225,8 @@ open class Process: NSObject {
198
225
199
226
private var processLaunchedCondition = NSCondition ( )
200
227
201
- // actions
228
+ // Actions
229
+
202
230
open func launch( ) {
203
231
204
232
self . processLaunchedCondition. lock ( )
0 commit comments