Mega Code Archive

 
Categories / Ruby / File Directory
 

Checking When a File was Last Used

open("output", "w") { |f| f << "Here's some output.\n" } stat = File.stat("output") stat.mtime             stat.atime             sleep(2) open("output", "a") { |f| f << "Here's some more output.\n" } stat = File.stat("output") stat.mtime             stat.atime             sleep(2) open("output") { |f| contents = f.read } stat = File.stat("output") stat.mtime             stat.atime