Sha256: 24f30251e0f24b031ff59be6df6a4449ffc5b9abc9f2aa329cf1962e534398a1
Contents?: true
Size: 1.09 KB
Versions: 13
Compression:
Stored size: 1.09 KB
Contents
module Imap::Backup class Serializer::Mbox attr_reader :folder_path def initialize(folder_path) @folder_path = folder_path end def valid? exist? end def append(message) File.open(pathname, "ab") do |file| file.write message end end def read(offset, length) File.open(pathname, "rb") do |f| f.seek offset f.read length end end def delete return if !exist? File.unlink(pathname) end def length return nil if !exist? File.stat(pathname).size end def pathname "#{folder_path}.mbox" end def rename(new_path) if exist? old_pathname = pathname @folder_path = new_path File.rename(old_pathname, pathname) else @folder_path = new_path end end def rewind(length) File.open(pathname, File::RDWR | File::CREAT, 0o644) do |f| f.truncate(length) end end def touch File.open(pathname, "a") {} end private def exist? File.exist?(pathname) end end end
Version data entries
13 entries across 13 versions & 1 rubygems