Class: TMail::MaildirLoader

### Home Classes Methods

### In Files

- lib/tmail/mailbox.rb

### Parent

Object

### Methods

- ::new
- ::unique_number
- #check_tmp
- #close
- #directory
- #each
- #each_new_port
- #each_port
- #inspect
- #new_port
- #reverse_each
- #reverse_each_port

### Files

- CHANGES
- LICENSE
- NOTES
- README
- Rakefile
- MANIFEST
- Makefile
- depend
- Makefile
- COPYING
- README

### Class/Module Index

Quicksearch

- TMail
- TMail::Address
- TMail::AddressGroup
- TMail::AddressHeader
- TMail::Attachment
- TMail::ContentDispositionHeader
- TMail::ContentTransferEncodingHeader
- TMail::ContentTypeHeader
- TMail::DateTimeHeader
- TMail::EncryptedHeader
- TMail::FilePort
- TMail::HeaderField
- TMail::KeywordsHeader
- TMail::Mail
- TMail::MailFlags
- TMail::Maildir
- TMail::MaildirLoader
- TMail::MaildirPort
- TMail::MboxLoader
- TMail::MessageIdHeader
- TMail::MhLoader
- TMail::MhMailbox
- TMail::MhPort
- TMail::MimeVersionHeader
- TMail::Parser
- TMail::Port
- TMail::ReceivedHeader
- TMail::ReferencesHeader
- TMail::ReturnPathHeader
- TMail::SingleAddressHeader
- TMail::StringPort
- TMail::StructuredHeader
- TMail::SyntaxError
- TMail::TMailScanner
- TMail::TextUtils
- TMail::UNIXMbox
- TMail::UnstructuredHeader
- CharDet
- CharDet::Big5DistributionAnalysis
- CharDet::Big5Prober
- CharDet::CharDistributionAnalysis
- CharDet::CharSetGroupProber
- CharDet::CharSetProber
- CharDet::CodingStateMachine
- CharDet::EUCJPContextAnalysis
- CharDet::EUCJPDistributionAnalysis
- CharDet::EUCJPProber
- CharDet::EUCKRDistributionAnalysis
- CharDet::EUCKRProber
- CharDet::EUCTWDistributionAnalysis
- CharDet::EUCTWProber
- CharDet::EscCharSetProber
- CharDet::GB2312DistributionAnalysis
- CharDet::GB2312Prober
- CharDet::HebrewProber
- CharDet::JapaneseContextAnalysis
- CharDet::Latin1Prober
- CharDet::MBCSGroupProber
- CharDet::MultiByteCharSetProber
- CharDet::SBCSGroupProber
- CharDet::SJISContextAnalysis
- CharDet::SJISDistributionAnalysis
- CharDet::SJISProber
- CharDet::SingleByteCharSetProber
- CharDet::UTF8Prober
- CharDet::UniversalDetector

No matching classes.

# TMail::MaildirLoader

### Constants

PORT_CLASS
TOO_OLD

### Public Class Methods

new( dir = nil ) click to toggle source

    # File lib/tmail/mailbox.rb, line 392
    def initialize( dir = nil )
      @dirname = dir || ENV['MAILDIR']
      raise ArgumentError, "not directory: #{@dirname}"                               unless FileTest.directory? @dirname
      @new = "#{@dirname}/new"
      @tmp = "#{@dirname}/tmp"
      @cur = "#{@dirname}/cur"
    end

unique_number() click to toggle source

    # File lib/tmail/mailbox.rb, line 385
    def Maildir.unique_number
      synchronize {
          @seq += 1
          return @seq
      }
    end

### Public Instance Methods

check_tmp() click to toggle source

    # File lib/tmail/mailbox.rb, line 462
    def check_tmp
      old = Time.now.to_i - TOO_OLD

      each_filename(@tmp) do |full, fname|
        if FileTest.file? full and
           File.stat(full).mtime.to_i < old
          File.unlink full
        end
      end
    end

close() click to toggle source

    # File lib/tmail/mailbox.rb, line 409
    def close
    end

directory() click to toggle source

    # File lib/tmail/mailbox.rb, line 401
    def directory
      @dirname
    end

each() click to toggle source
Alias for: each_port
each_new_port() click to toggle source

    # File lib/tmail/mailbox.rb, line 450
    def each_new_port
      mail_files(@new).each do |path|
        dest = @cur + '/' + File.basename(path)
        File.rename path, dest
        yield PORT_CLASS.new(dest)
      end

      check_tmp
    end

each_port() click to toggle source

    # File lib/tmail/mailbox.rb, line 412
    def each_port
      mail_files(@cur).each do |path|
        yield PORT_CLASS.new(path)
      end
    end

Also aliased as: each
inspect() click to toggle source

    # File lib/tmail/mailbox.rb, line 405
    def inspect
      "#<#{self.class} #{@dirname}>"
    end

new_port() click to toggle source

    # File lib/tmail/mailbox.rb, line 428
    def new_port
      fname = nil
      tmpfname = nil
      newfname = nil

      begin
        fname = "#{Time.now.to_i}.#{$$}_#{Maildir.unique_number}.#{Socket.gethostname}"

        tmpfname = "#{@tmp}/#{fname}"
        newfname = "#{@new}/#{fname}"
      end while FileTest.exist? tmpfname

      if block_given?
        File.open(tmpfname, 'w') {|f| yield f }
        File.rename tmpfname, newfname
        PORT_CLASS.new(newfname)
      else
        File.open(tmpfname, 'w') {|f| f.write "\n\n" }
        PORT_CLASS.new(tmpfname)
      end
    end

reverse_each() click to toggle source
Alias for: reverse_each_port
reverse_each_port() click to toggle source

    # File lib/tmail/mailbox.rb, line 420
    def reverse_each_port
      mail_files(@cur).reverse_each do |path|
        yield PORT_CLASS.new(path)
      end
    end

Also aliased as: reverse_each

[Validate]

Generated with the Darkfish Rdoc Generator 2.