src/Pure/Thy/sessions.scala
changeset 75709 a068fb7346ef
parent 75680 605f4b6b5785
child 75732 14598eca6c20
equal deleted inserted replaced
75708:0caf8528b07b 75709:a068fb7346ef
  1134           file.position(len - n)
  1134           file.position(len - n)
  1135 
  1135 
  1136           val buf = ByteBuffer.allocate(n)
  1136           val buf = ByteBuffer.allocate(n)
  1137           var i = 0
  1137           var i = 0
  1138           var m = 0
  1138           var m = 0
  1139           var cont = true
  1139           while ({
  1140           while (cont) {
       
  1141             m = file.read(buf)
  1140             m = file.read(buf)
  1142             if (m != -1) i += m
  1141             if (m != -1) i += m
  1143             cont = (m != -1 && n > i)
  1142             m != -1 && n > i
  1144           }
  1143           }) ()
  1145 
  1144 
  1146           if (i == n) {
  1145           if (i == n) {
  1147             val prefix = new String(buf.array(), 0, sha1_prefix.length, UTF8.charset)
  1146             val prefix = new String(buf.array(), 0, sha1_prefix.length, UTF8.charset)
  1148             val s = new String(buf.array(), sha1_prefix.length, SHA1.digest_length, UTF8.charset)
  1147             val s = new String(buf.array(), sha1_prefix.length, SHA1.digest_length, UTF8.charset)
  1149             if (prefix == sha1_prefix) Some(s) else None
  1148             if (prefix == sha1_prefix) Some(s) else None