| 
									
										
										
										
											2019-05-09 18:39:21 +00:00
										 |  |  | #!/usr/bin/swift | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import Foundation | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-31 14:07:42 +03:00
										 |  |  | let manager = FileManager.default | 
					
						
							| 
									
										
										
										
											2019-05-09 18:39:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-23 05:21:21 +02:00
										 |  |  | var success = true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-31 14:07:42 +03:00
										 |  |  | // The command line arguments given but without the script's name | 
					
						
							|  |  |  | let CMDLineArgs = Array(CommandLine.arguments.dropFirst()) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-15 02:51:38 +01:00
										 |  |  | var trashed: [String] = [] | 
					
						
							|  |  |  | var untrashable: [String] = [] | 
					
						
							| 
									
										
										
										
											2021-12-31 14:07:42 +03:00
										 |  |  | for item in CMDLineArgs { | 
					
						
							|  |  |  |     do { | 
					
						
							|  |  |  |         let url = URL(fileURLWithPath: item) | 
					
						
							|  |  |  |         var trashedPath: NSURL! | 
					
						
							|  |  |  |         try manager.trashItem(at: url, resultingItemURL: &trashedPath) | 
					
						
							| 
									
										
										
										
											2024-06-15 02:51:38 +01:00
										 |  |  |         trashed.append((trashedPath as URL).path) | 
					
						
							| 
									
										
										
										
											2021-12-31 14:07:42 +03:00
										 |  |  |         success = true | 
					
						
							|  |  |  |     } catch { | 
					
						
							| 
									
										
										
										
											2024-06-15 02:51:38 +01:00
										 |  |  |         untrashable.append(item) | 
					
						
							| 
									
										
										
										
											2021-12-31 14:07:42 +03:00
										 |  |  |         success = false | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-05-09 18:39:21 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-15 02:51:38 +01:00
										 |  |  | print(trashed.joined(separator: ":")) | 
					
						
							|  |  |  | print(untrashable.joined(separator: ":"), terminator: "") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-23 05:21:21 +02:00
										 |  |  | guard success else { | 
					
						
							| 
									
										
										
										
											2021-12-31 14:07:42 +03:00
										 |  |  |     exit(1) | 
					
						
							| 
									
										
										
										
											2019-10-23 05:21:21 +02:00
										 |  |  | } |