Exemplo n.º 1
0
 public void SendFile(int out_fd, int in_fd, long offset, long length, Action <long, int> callback)
 {
     Libeio.sendfile(out_fd, in_fd, offset, length, (arg1, arg2) => {
         outstanding.Enqueue(() => callback(arg1, arg2));
         pulse.Send();
     });
 }
Exemplo n.º 2
0
 public void Write(int fd, byte[] buffer, long offset, long length, Action <int, int> callback)
 {
     Libeio.write(fd, buffer, offset, length, (arg1, arg2) => {
         outstanding.Enqueue(() => callback(arg1, arg2));
         pulse.Send();
     });
 }
Exemplo n.º 3
0
 public void Read(int fd, byte[] buffer, long offset, long length, Action <int, byte[], int> callback)
 {
     Libeio.read(fd, buffer, offset, length, (arg1, arg2, arg3) => {
         outstanding.Enqueue(() => callback(arg1, arg2, arg3));
         pulse.Send();
     });
 }
Exemplo n.º 4
0
 void OpenFile()
 {
     Libeio.open(file, OpenFlags.O_RDONLY, FilePermissions.ALLPERMS, (fd, err) => {
         this.sourceFd = fd;
         if (fd == -1)
         {
             completed = true;
             Console.Error.WriteLine("Error sending file '{0}' errno: '{1}'", file, err);
         }
         else
         {
             Libeio.fstat(fd, (r, stat, error) => {
                 if (r == -1)
                 {
                     completed = true;
                 }
                 else
                 {
                     length = stat.st_size;
                     target.ResumeWriting();
                 }
             });
         }
     });
 }
Exemplo n.º 5
0
 public override void Close()
 {
     if (Handle != IntPtr.Zero)
     {
         Libeio.close(Handle.ToInt32(), OnCloseDone);
         Handle = IntPtr.Zero;
     }
     base.Close();
 }
Exemplo n.º 6
0
        void ReadNextBuffer()
        {
            if (!readEnabled)
            {
                return;
            }

            var length = (int)Math.Min(readBuffer.Length, readLimit);

            Libeio.read(Handle.ToInt32(), readBuffer, position, length, OnReadDone);
        }
Exemplo n.º 7
0
        protected override int WriteSingleBuffer(ByteBuffer buffer)
        {
            var bytes = buffer.Bytes;

            if (buffer.Position > 0)
            {
                bytes = new byte[buffer.Length];
                Array.Copy(buffer.Bytes, buffer.Position, bytes, 0, buffer.Length);
            }
            Libeio.write(Handle.ToInt32(), bytes, position, buffer.Length, OnWriteDone);
            return(buffer.Length);
        }
Exemplo n.º 8
0
 void SendNextBlock()
 {
     Libeio.sendfile(target.Handle.ToInt32(), sourceFd, position, length - position, (len, err) => {
         if (len >= 0)
         {
             position += len;
         }
         else
         {
             completed = true;
         }
         if (position == length)
         {
             completed = true;
         }
         target.ResumeWriting();
     });
 }
Exemplo n.º 9
0
 void CloseFile()
 {
     Libeio.close(sourceFd, err => { });
     sourceFd = 0;
 }