The work! The progress!
[tripe-android] / sock.scala
diff --git a/sock.scala b/sock.scala
deleted file mode 100644 (file)
index 1b52bf1..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-package uk.org.distorted.tripe;
-
-import java.io.{Closeable, File, InputStream, OutputStream};
-import jni.Constants._;
-
-class Connection(path: File) extends Closeable {
-  def this(path: String) { this(new File(path)); }
-  val conn = jni.connect(path.getPath);
-  override def close() { jni.close(conn, CF_CLOSEMASK); }
-  lazy val input = new ConnectionInputStream(this);
-  lazy val output = new ConnectionOutputStream(this);
-  override protected def finalize() { super.finalize(); close(); }
-}
-
-class ConnectionInputStream(val conn: Connection) extends InputStream {
-  override def read(): Int = {
-    val buf = new Array[Byte](1);
-    val n = read(buf, 0, 1);
-    if (n < 0) -1 else buf(0)&0xff;
-  }
-  override def read(buf: Array[Byte]): Int =
-    read(buf, 0, buf.length);
-  override def read(buf: Array[Byte], start: Int, len: Int) =
-    jni.recv(conn.conn, buf, start, len);
-  override def close() { jni.close(conn.conn, CF_CLOSERD); }
-}
-
-class ConnectionOutputStream(val conn: Connection) extends OutputStream {
-  override def write(b: Int) = {
-    val buf = Array[Byte](b.toByte);
-    write(buf, 0, 1);
-  }
-  override def write(buf: Array[Byte]) { write(buf, 0, buf.length); }
-  override def write(buf: Array[Byte], start: Int, len: Int) =
-    jni.send(conn.conn, buf, start, len);
-  override def close() { jni.close(conn.conn, CF_CLOSEWR); }
-}