| 
									
										
										
										
											2015-04-19 20:18:22 -04:00
										 |  |  | ! Copyright (C) 2015 John Benediktsson | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-05 18:36:49 -04:00
										 |  |  | USING: accessors command-line formatting io io.monitors | 
					
						
							| 
									
										
										
										
											2015-04-19 20:18:22 -04:00
										 |  |  | io.pathnames kernel namespaces sequences ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | IN: file-monitor | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : file-monitor-loop ( monitor -- )
 | 
					
						
							| 
									
										
										
										
											2015-05-05 18:36:49 -04:00
										 |  |  |     dup next-change [ changed>> ] [ path>> ] bi
 | 
					
						
							|  |  |  |     "%u %s\n" printf flush file-monitor-loop ;
 | 
					
						
							| 
									
										
										
										
											2015-04-19 20:18:22 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : file-monitor-main ( -- )
 | 
					
						
							|  |  |  |     command-line get ?first current-directory get or
 | 
					
						
							|  |  |  |     dup "Monitoring %s\n" printf flush
 | 
					
						
							| 
									
										
										
										
											2015-05-05 18:33:17 -04:00
										 |  |  |     [ t [ file-monitor-loop ] with-monitor ] with-monitors ;
 | 
					
						
							| 
									
										
										
										
											2015-04-19 20:18:22 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | MAIN: file-monitor-main |