diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-02-09 10:56:24 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-02-09 10:56:24 +0000 |
commit | b814252d728cb08f159da1777feca4f8e9362327 (patch) | |
tree | de6617897dbf6bce78045e3fa2ea84ea2422f166 /sample/from.rb | |
parent | 1bbcd202e4dab0894bc5ed68ce4ea84dc916980f (diff) |
1.1b7 pre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@67 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/from.rb')
-rw-r--r-- | sample/from.rb | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/sample/from.rb b/sample/from.rb index d39bb70084..39aa4b7553 100644 --- a/sample/from.rb +++ b/sample/from.rb @@ -9,8 +9,6 @@ include Kconv class String - public :kconv - def kconv(code = Kconv::EUC) Kconv.kconv(self, code, Kconv::AUTO) end @@ -35,10 +33,11 @@ if ARGV.length == 0 user = ENV['USER'] else user = ARGV[0] + ARGV.clear end [ENV['SPOOLDIR'], '/usr/spool', '/var/spool', '/usr', '/var'].each do |m| - break if File.exist? ARGV[0] = "#{m}/mail/#{user}" + break if File.exist? file = "#{m}/mail/#{user}" end $outcount = 0; @@ -67,14 +66,19 @@ def fromout(date, from, subj) $outcount += 1 end -for file in ARGV - next if !File.exist?(file) +if File.exist?(file) + atime = File.atime(file) + mtime = File.mtime(file) f = open(file, "r") - while !f.eof? - mail = Mail.new(f) - fromout mail.header['Date'], mail.header['From'], mail.header['Subject'] + begin + until f.eof? + mail = Mail.new(f) + fromout mail.header['Date'],mail.header['From'],mail.header['Subject'] + end + ensure + f.close + File.utime(atime, mtime, file) end - f.close end if $outcount == 0 |