| 
									
										
										
										
											2019-05-09 18:39:21 +00:00
										 |  |  | #!/usr/bin/swift | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import Foundation | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-23 05:21:21 +02:00
										 |  |  | extension FileHandle : TextOutputStream { | 
					
						
							|  |  |  |   public func write(_ string: String) { | 
					
						
							|  |  |  |     self.write(string.data(using: .utf8)!) | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-10-01 11:12:23 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-23 05:21:21 +02:00
										 |  |  | var stderr = FileHandle.standardError | 
					
						
							| 
									
										
										
										
											2019-05-09 18:39:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | let manager: FileManager = FileManager() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-23 05:21:21 +02:00
										 |  |  | var success = true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-09 18:39:21 +00:00
										 |  |  | for item in CommandLine.arguments[1...] { | 
					
						
							|  |  |  |   do { | 
					
						
							|  |  |  |     let path: URL = URL(fileURLWithPath: item) | 
					
						
							| 
									
										
										
										
											2019-10-23 05:21:21 +02:00
										 |  |  |     var trashedPath: NSURL! | 
					
						
							|  |  |  |     try manager.trashItem(at: path, resultingItemURL: &trashedPath) | 
					
						
							|  |  |  |     print((trashedPath as URL).path, terminator: ":") | 
					
						
							|  |  |  |   } catch { | 
					
						
							|  |  |  |     print(item, terminator: ":", to: &stderr) | 
					
						
							|  |  |  |     success = false | 
					
						
							| 
									
										
										
										
											2019-05-09 18:39:21 +00:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-23 05:21:21 +02:00
										 |  |  | guard success else { | 
					
						
							|  |  |  |   exit(1) | 
					
						
							|  |  |  | } |