Ejemplo n.º 1
0
 private void OnOpen(IntPtr req)
 {
     this.File = this.FreeRequest(req);
     this.Status = this.File > 0 ? FileHandleStatus.Open : FileHandleStatus.Closed;
     this.OnOpen();
 }
Ejemplo n.º 2
0
 private void OnClose(IntPtr req)
 {
     this.File = this.FreeRequest(req);
     this.Status = FileHandleStatus.Closed;
     this.OnClose();
 }
Ejemplo n.º 3
0
        public void Open(string path, FileAccessMode rw, FileOpenMode open, FilePermissions permissions)
        {
            if (this.Status != FileHandleStatus.Closed)
                return;

            var req = this.CreateRequest();

            try
            {
                CheckError(Uvi.uv_fs_open(this.Loop.Handle, req, path, rw, open, permissions, this.OnOpen));
                this.Status = FileHandleStatus.Opening;
            }
            catch (Exception)
            {
                this.FreeRequest(req, false);
                throw;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Closes the stream. After this call the stream will not be valid
        /// </summary>
        public void Read()
        {
            if (this.Status != FileHandleStatus.Open)
                throw new InvalidOperationException("File handle must be open in order to read data");

            var req = this.CreateRequest();

            try
            {
                CheckError(Uvi.uv_fs_read(this.Loop.Handle, req, this.File, this.ReadBuffer, DefaultReadBufferSize, -1, this.OnRead));
                this.Status = FileHandleStatus.Closing;
            }
            catch (Exception)
            {
                this.FreeRequest(req, false);
                throw;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Closes the stream. After this call the stream will not be valid
        /// </summary>
        public void Close()
        {
            if (this.Status != FileHandleStatus.Open)
                return;

            var req = this.CreateRequest();

            try
            {
                CheckError(Uvi.uv_fs_close(this.Loop.Handle, req, this.File, this.OnClose));
                this.Status = FileHandleStatus.Closing;
            }
            catch (Exception)
            {
                this.FreeRequest(req, false);
                throw;
            }
        }