1.1 --- a/src/scripts/fswatch Tue Jan 01 21:33:48 2008 -0600
1.2 +++ b/src/scripts/fswatch Fri Jan 04 15:37:44 2008 -0600
1.3 @@ -11,6 +11,10 @@
1.4
1.5 $COMMAND = File.basename($0)
1.6 $USAGE = "Usage: #{$COMMAND} [OPTIONS] <command> [<args> ...]"
1.7 +def die(s)
1.8 + $stderr.puts s
1.9 + exit 1
1.10 +end
1.11
1.12 options = OpenStruct.new
1.13 options.directoriesOnly = false
1.14 @@ -36,10 +40,7 @@
1.15 end
1.16 opts.parse!(ARGV)
1.17
1.18 -if (ARGV.size < 1)
1.19 - $stderr.puts $USAGE
1.20 - exit 1
1.21 -end
1.22 +die $USAGE unless ARGV.size >= 1
1.23
1.24 if options.outputFile == "-"
1.25 outputHandle = $stdout.clone
1.26 @@ -94,30 +95,29 @@
1.27 ok = FSEventStreamStart(stream)
1.28 die "Failed to start the FSEventStream" unless ok
1.29
1.30 -begin
1.31 - FSEventStreamFlushSync(stream)
1.32 - allPaths.sort.each do |path|
1.33 - if File.exists?(path)
1.34 - outputHandle.puts path
1.35 - if (!options.directoriesOnly)
1.36 - Dir.foreach(path) do |file|
1.37 - fullPath = File.join(path, file)
1.38 - stat = File.stat(fullPath)
1.39 - if (stat.mtime.to_i >= startTime)
1.40 - outputHandle.puts " #{file}"
1.41 - end
1.42 +FSEventStreamFlushSync(stream)
1.43 +allPaths.sort.each do |path|
1.44 + if File.exists?(path)
1.45 + outputHandle.puts path
1.46 + if (!options.directoriesOnly)
1.47 + Dir.foreach(path) do |file|
1.48 + fullPath = File.join(path, file)
1.49 + stat = File.stat(fullPath)
1.50 + if (stat.mtime.to_i >= startTime)
1.51 + outputHandle.puts " #{file}"
1.52 end
1.53 end
1.54 - else
1.55 - outputHandle.puts "#{path} !"
1.56 end
1.57 + else
1.58 + outputHandle.puts "#{path} !"
1.59 end
1.60 -rescue Interrupt
1.61 - FSEventStreamStop(stream)
1.62 - FSEventStreamInvalidate(stream)
1.63 - FSEventStreamRelease(stream)
1.64 end
1.65
1.66 +FSEventStreamStop(stream)
1.67 +FSEventStreamInvalidate(stream)
1.68 +FSEventStreamRelease(stream)
1.69 +
1.70 +
1.71 outputHandle.flush
1.72
1.73 exit(returnCode)