Ruby/File Directory/atime

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

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



Get file last accessed time

File::atime( "access.rb" )