Created
December 20, 2010 15:16
-
-
Save thinkerbot/748489 to your computer and use it in GitHub Desktop.
Illustrate mtime behavior
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'fileutils' | |
| dir = File.expand_path('../mtime', __FILE__) | |
| file = "#{dir}/file.txt" | |
| format = "%5s:%-20s %s" | |
| FileUtils.rm_rf(dir) | |
| FileUtils.mkdir_p(dir) | |
| puts format % [:dir, "mkdir", File.mtime(dir)] | |
| sleep(1) | |
| FileUtils.touch(file) | |
| puts format % [:dir, "touch file", File.mtime(dir)] | |
| sleep(1) | |
| File.open(file, 'w') {|io| io << 'content' } | |
| puts format % [:dir, "mod file", File.mtime(dir)] | |
| sleep(1) | |
| FileUtils.rm(file) | |
| puts format % [:dir, "rm file", File.mtime(dir)] | |
| sleep(1) | |
| FileUtils.touch(file) | |
| puts format % [:file, "touch", File.mtime(file)] | |
| sleep(1) | |
| File.open(file, 'w') {|io| io << 'content' } | |
| puts format % [:file, "mod", File.mtime(file)] | |
| sleep(1) | |
| FileUtils.touch(file) | |
| puts format % [:file, "touch", File.mtime(file)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment