Beispiel #1
0
 public void Dispose()
 {
     if (fd != null)
     {
         Libeio.close(fd, err => { });
     }
 }
Beispiel #2
0
 public void EndWrite(IIOStream stream)
 {
     Libeio.close(fd, err =>
     {
         fd = null;
     });
     if (callback != null)
     {
         callback();
     }
 }
Beispiel #3
0
 void OpenFile()
 {
     stream.DisableWriting();
     Libeio.open(fileName, OpenFlags.O_RDONLY, FilePermissions.ALLPERMS, (fd, err) =>
     {
         if (fd == null)
         {
             OnComplete(-1, err);
         }
         else
         {
             this.fd = fd;
             stream.EnableWriting();
             HandleWrite(stream);
         }
     });
 }
Beispiel #4
0
 void InitializeTransfer()
 {
     stream.DisableWriting();
     Libeio.fstat(fd, (stat, err) =>
     {
         if (err != null)
         {
             OnComplete(-1, err);
         }
         else
         {
             Length             = stat.Length;
             var chunkHeader    = string.Format("{0:x}\r\n", Length);
             var headerBytes    = Encoding.ASCII.GetBytes(chunkHeader);
             currentPrefixBlock = new SendBytesOperation(new[] {
                 new ByteBuffer(headerBytes, 0, headerBytes.Length)
             }, null);
             stream.EnableWriting();
             currentPrefixBlock.BeginWrite(stream);
         }
     });
 }
Beispiel #5
0
 protected void SendNextBlock()
 {
     stream.DisableWriting();
     Libeio.read(fd, transferBuffer, position, transferBuffer.Length, (len, buf, err) =>
     {
         if (position == Length)
         {
             OnComplete(len, err);
         }
         if (len > 0)
         {
             position          += len;
             currentPrefixBlock = new SendBytesOperation(new[] {
                 new ByteBuffer(transferBuffer, 0, len)
             }, null);
             currentPrefixBlock.BeginWrite(stream);
         }
         else
         {
             OnComplete(len, err);
         }
         stream.EnableWriting();
     });
 }