X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/tripe-android/blobdiff_plain/9190adc66f814b8b9add2d2df2ff65b43175104b..0157de026e802e94a2d0db0421b02ffca986c616:/tar.scala diff --git a/tar.scala b/tar.scala index 30a3a4a..986eeaa 100644 --- a/tar.scala +++ b/tar.scala @@ -35,6 +35,8 @@ import java.util.Date; import sys.FileInfo; import sys.FileInfo.{Value, FIFO, CHR, DIR, BLK, REG, LNK, HDLNK, UNK}; +import Implicits.truish; + /*----- Main code ---------------------------------------------------------*/ class TarFormatError(msg: String) extends Exception(msg); @@ -98,12 +100,10 @@ trait TarEntry { /* Then the permissions bits. Ugh, the permissions bits. */ def perm(s: Int, r: Int, w: Int, x: Int, schar: Char, Schar: Char) { - sb += (if ((mode&r) != 0) 'r' else '-'); - sb += (if ((mode&w) != 0) 'w' else '-'); - sb += (if ((mode&s) != 0) - if ((mode&x) != 0) schar else Schar; - else - if ((mode&x) != 0) 'x' else '-'); + sb += (if (mode&r) 'r' else '-'); + sb += (if (mode&w) 'w' else '-'); + sb += (if (mode&s) { if (mode&x) schar else Schar; } + else { if (mode&x) 'x' else '-' }); } perm(0x800, 0x100, 0x080, 0x040, 's', 'S'); perm(0x400, 0x020, 0x010, 0x008, 's', 'S'); @@ -337,7 +337,7 @@ class TarFile(in: InputStream) val b = hdr(i); /* See if we're done now. */ - if (b == ' ' || b == 0) return n; + if (!b || b == ' ') return n; else if (b < '0' || b > '7') throw new TarFormatError(s"bad octal digit (at ${offset + off + i})"); @@ -407,7 +407,7 @@ class TarFile(in: InputStream) */ val name = { val tail = string(0, 100); - if (!posixp || hdr(345) == 0) tail + if (!posixp || !hdr(345)) tail else { val prefix = string(345, 155); prefix + '/' + tail