summaryrefslogtreecommitdiffstats
path: root/lib/git/raw/internal/mmap.rb
diff options
context:
space:
mode:
authorScott Chacon <schacon@gmail.com>2008-03-08 18:14:15 -0800
committerScott Chacon <schacon@gmail.com>2008-03-08 18:14:15 -0800
commit1d845799ebc05bee9e3a68b7ad9dd5015277ca41 (patch)
treee84397c1359cc51189760477a4475e4279cfa01f /lib/git/raw/internal/mmap.rb
parent2d749e3aa69d7bfedf814f59618f964fdbc300d5 (diff)
downloadthird_party-ruby-git-1d845799ebc05bee9e3a68b7ad9dd5015277ca41.tar.gz
third_party-ruby-git-1d845799ebc05bee9e3a68b7ad9dd5015277ca41.tar.xz
third_party-ruby-git-1d845799ebc05bee9e3a68b7ad9dd5015277ca41.zip
reverted the pure ruby code to system calls and split the pure ruby to a new library
Diffstat (limited to 'lib/git/raw/internal/mmap.rb')
-rw-r--r--lib/git/raw/internal/mmap.rb58
1 files changed, 0 insertions, 58 deletions
diff --git a/lib/git/raw/internal/mmap.rb b/lib/git/raw/internal/mmap.rb
deleted file mode 100644
index 78de164..0000000
--- a/lib/git/raw/internal/mmap.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# converted from the gitrb project
-#
-# authors:
-# Matthias Lederhofer <matled@gmx.net>
-# Simon 'corecode' Schubert <corecode@fs.ei.tum.de>
-#
-# provides native ruby access to git objects and pack files
-#
-
-begin
- require 'mmap'
-rescue LoadError
-
-module Git
- module Raw
- 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
-