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;
        }
Exemple #2
0
 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);
 }
Exemple #3
0
 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);
 }
Exemple #4
0
 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);
 }
Exemple #5
0
        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);
        }
Exemple #6
0
        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));
        }
Exemple #7
0
        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);
        }
Exemple #8
0
        public override void endEdition()
        {
            ByteArrayOutputStream request = new ByteArrayOutputStream();

            request.writeInt((int)id);
            netfs.doRequest(5, request.getArray(), this);
        }
Exemple #9
0
        public override byte[] getContents()
        {
            ByteArrayOutputStream request = new ByteArrayOutputStream();

            request.writeInt((int)id);
            return(netfs.doRequest(2, request.getArray(), this));
        }
Exemple #10
0
        public override void startEdition()
        {
            ByteArrayOutputStream request = new ByteArrayOutputStream();

            request.writeInt(id);
            netfs.doRequest(4, request.getArray(), this);
        }
Exemple #11
0
        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);
        }
Exemple #12
0
 public override void endEdition()
 {
     ByteArrayOutputStream request = new ByteArrayOutputStream();
     request.writeInt(id);
     netfs.doRequest(5, request.getArray(), this);
 }
Exemple #13
0
 public override byte[] getContents()
 {
     ByteArrayOutputStream request = new ByteArrayOutputStream();
     request.writeInt(id);
     return netfs.doRequest(2, request.getArray(), this);
 }