获取当天修改的文件 require "#{File.dirname(__FILE__)}/lib/libFile" class deal_file def get_file_info(path)
stat = File::Stat.new(path)
size = stat.size #文件大小 atime = stat.atime #最终访问时间 mtime = stat.mtime #最终更新时间 if ($date < mtime) #比较时间 return [size,atime,mtime] else return ['NODATA']
end
end
def GetDirList(path) #获取目录列表 list = Dir.entries(path)
list.delete('.')
list.delete('..') return list
end
end #获取当天时间 $date = Time.mktime(Time.now.strftime("%Y"),Time.now.strftime("%m"),Time.now.strftime("%d"))
$path ="F:\\脚本\\lib"
f = deal_file.new
dir_list = f.GetDirList($path)
dir_list.each do |file|
file_path ="#{$path}\\#{file}"
if !(File.directory?(file_path))
info = f.get_file_info(file_path ) if (info != ['NODATA'])
puts "获取#{file_path}文件信息:"
p info
puts '-------------------------'
end
file_path =''
end
end