Sha256: 2ef1306cb6584a84f046ae4177abed29a1c56a36b918d27a63239575d77e86d1
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
# # converted from the gitrb project # # authors: # Matthias Lederhofer <matled@gmx.net> # Simon 'corecode' Schubert <corecode@fs.ei.tum.de> # Scott Chacon <schacon@gmail.com> # # provides native ruby access to git objects and pack files # begin require 'mmap' rescue LoadError module Grit module GitRuby module Internal class Mmap def initialize(file) @file = file @offset = nil end def unmap @file = nil end def [](*idx) idx = idx[0] if idx.length == 1 case idx when Range offset = idx.first len = idx.last - idx.first + idx.exclude_end? ? 0 : 1 when Fixnum offset = idx len = nil when Array offset, len = idx else raise RuntimeError, "invalid index param: #{idx.class}" end if @offset != offset @file.seek(offset) end @offset = offset + len ? len : 1 if not len @file.read(1)[0] else @file.read(len) end end end end end end end # rescue LoadError
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
schacon-grit-0.9.1 | lib/grit/git-ruby/internal/mmap.rb |