public byte[] doRequest(byte type, byte[] data = null, File f = null) { ByteArrayOutputStream bout = new ByteArrayOutputStream(); if (data == null) { bout.writeInt(1); bout.writeByte(type); } else { bout.writeInt(data.Length+1); bout.writeByte(type); bout.write(data); } byte[] aout = bout.getArray(); stream.Write(aout, 0, aout.Length); stream.Flush(); byte[] resp = readBytes(8); ByteArrayInputStream bin = new ByteArrayInputStream(resp); int error = bin.readInt(); int len = bin.readInt(); resp = readBytes(len); if (error == 2) throw new AlreadyEditingException(f); if (error != 0) { ByteArrayInputStream i = new ByteArrayInputStream(resp); string s = i.ReadString(); throw new Exception("Network error: " + s); } return resp; }
public override void replace(byte[] newFile, object editor) { ByteArrayOutputStream request = new ByteArrayOutputStream(); request.writeInt(id); request.writeInt(newFile.Length); request.write(newFile); netfs.doRequest(6, request.getArray(), this); }
public override byte[] getInterval(int start, int end) { ByteArrayOutputStream request = new ByteArrayOutputStream(); request.writeInt(id); request.writeInt(start); request.writeInt(end); return netfs.doRequest(3, request.getArray(), this); }
public override void replaceInterval(byte[] newFile, int start) { ByteArrayOutputStream request = new ByteArrayOutputStream(); request.writeInt(id); request.writeInt(start); request.writeInt(start + newFile.Length); request.write(newFile); netfs.doRequest(7, request.getArray(), this); }
public override void replace(byte[] newFile, object editor) { ByteArrayOutputStream request = new ByteArrayOutputStream(); request.writeInt((int)id); request.writeInt(newFile.Length); request.write(newFile); netfs.doRequest(6, request.getArray(), this); }
public override byte[] getInterval(int start, int end) { ByteArrayOutputStream request = new ByteArrayOutputStream(); request.writeInt((int)id); request.writeInt(start); request.writeInt(end); return(netfs.doRequest(3, request.getArray(), this)); }
public override void replaceInterval(byte[] newFile, int start) { ByteArrayOutputStream request = new ByteArrayOutputStream(); request.writeInt((int)id); request.writeInt(start); request.writeInt(start + newFile.Length); request.write(newFile); netfs.doRequest(7, request.getArray(), this); }
public override void endEdition() { ByteArrayOutputStream request = new ByteArrayOutputStream(); request.writeInt((int)id); netfs.doRequest(5, request.getArray(), this); }
public override byte[] getContents() { ByteArrayOutputStream request = new ByteArrayOutputStream(); request.writeInt((int)id); return(netfs.doRequest(2, request.getArray(), this)); }
public override void startEdition() { ByteArrayOutputStream request = new ByteArrayOutputStream(); request.writeInt(id); netfs.doRequest(4, request.getArray(), this); }
public byte[] doRequest(byte type, byte[] data = null, File f = null) { ByteArrayOutputStream bout = new ByteArrayOutputStream(); if (data == null) { bout.writeInt(1); bout.writeByte(type); } else { bout.writeInt(data.Length + 1); bout.writeByte(type); bout.write(data); } byte[] aout = bout.getArray(); stream.Write(aout, 0, aout.Length); stream.Flush(); byte[] resp = readBytes(8); ByteArrayInputStream bin = new ByteArrayInputStream(resp); int error = bin.readInt(); int len = bin.readInt(); resp = readBytes(len); if (error == 2) { throw new AlreadyEditingException(f); } if (error != 0) { ByteArrayInputStream i = new ByteArrayInputStream(resp); string s = i.ReadString(); throw new Exception("Network error: " + s); } return(resp); }
public override void endEdition() { ByteArrayOutputStream request = new ByteArrayOutputStream(); request.writeInt(id); netfs.doRequest(5, request.getArray(), this); }
public override byte[] getContents() { ByteArrayOutputStream request = new ByteArrayOutputStream(); request.writeInt(id); return netfs.doRequest(2, request.getArray(), this); }