Inheritance: PermaRequest
Esempio n. 1
0
		public static void Rename(Loop loop, string path, string newPath, Action<Exception> callback)
		{
			var fsr = new FileSystemRequest();
			fsr.Callback = callback;
			int r = uv_fs_rename(loop.NativeHandle, fsr.Handle, path, newPath, fsr.End);
			Ensure.Success(r);
		}
Esempio n. 2
0
 public static void Chown(Loop loop, string path, int uid, int gid, Action<Exception> callback)
 {
     var fsr = new FileSystemRequest();
     fsr.Callback = callback;
     int r = uv_fs_chown(loop.NativeHandle, fsr.Handle, path, uid, gid, FileSystemRequest.CallbackDelegate);
     Ensure.Success(r);
 }
Esempio n. 3
0
		public static void Create(Loop loop, string path, int mode, Action<Exception> callback)
		{
			var fsr = new FileSystemRequest();
			fsr.Callback = callback;
			int r = uv_fs_mkdir(loop.NativeHandle, fsr.Handle, path, mode, FileSystemRequest.CallbackDelegate);
			Ensure.Success(r);
		}
Esempio n. 4
0
 public static void Delete(Loop loop, string path, Action<Exception> callback)
 {
     var fsr = new FileSystemRequest();
     fsr.Callback = callback;
     int r = uv_fs_rmdir(loop.NativeHandle, fsr.Handle, path, FileSystemRequest.StaticEnd);
     Ensure.Success(r, loop);
 }
Esempio n. 5
0
		public void Close(Loop loop, Action<Exception> callback)
		{
			var fsr = new FileSystemRequest();
			fsr.Callback = callback;
			int r = uv_fs_close(loop.NativeHandle, fsr.Handle, FileDescriptor, FileSystemRequest.CallbackDelegate);
			Ensure.Success(r);
		}
Esempio n. 6
0
 public static void Chown(Loop loop, string path, int uid, int gid, Action<Exception> callback)
 {
     var fsr = new FileSystemRequest();
     fsr.Callback = (ex, fsr2) => { callback(ex); };
     int r = uv_fs_chown(loop.Handle, fsr.Handle, path, uid, gid, FileSystemRequest.StaticEnd);
     Ensure.Success(r, loop);
 }
Esempio n. 7
0
 public static void Delete(Loop loop, string path, Action<Exception> callback)
 {
     var fsr = new FileSystemRequest();
     fsr.Callback = (ex, fsr2) => {
         if (callback != null) {
             callback(ex);
         };
     };
     int r = uv_fs_rmdir(loop.Handle, fsr.Handle, path, FileSystemRequest.StaticEnd);
     Ensure.Success(r, loop);
 }
Esempio n. 8
0
		public void Read(Loop loop, int offset, ArraySegment<byte> segment, Action<Exception, int> callback)
		{
			var datagchandle = GCHandle.Alloc(segment.Array, GCHandleType.Pinned);
			var fsr = new FileSystemRequest();
			fsr.Callback = (ex) => {
				Ensure.Success(ex, callback, fsr.Result.ToInt32());
				datagchandle.Free();
			};
			UnixBufferStruct[] buf = new UnixBufferStruct[1];
			buf[0] = new UnixBufferStruct(datagchandle.AddrOfPinnedObject() + segment.Offset, segment.Count);
			int r = uv_fs_read(loop.NativeHandle, fsr.Handle, FileDescriptor, buf, 1, offset, FileSystemRequest.CallbackDelegate);
			Ensure.Success(r);
		}
Esempio n. 9
0
		public static void Open(Loop loop, string path, UVFileAccess access, Action<Exception, UVFile> callback)
		{
			var fsr = new FileSystemRequest(path);
			fsr.Callback = (ex) => {
				UVFile file = null;
				if (fsr.Result != IntPtr.Zero) {
					file = new UVFile(loop, fsr.Result.ToInt32());
				}
				Ensure.Success(ex, callback, file);
			};
			int r = uv_fs_open(loop.NativeHandle, fsr.Handle, path, (int)access, 0, FileSystemRequest.CallbackDelegate);
			Ensure.Success(r);
		}
Esempio n. 10
0
        public void Read(Loop loop, byte[] data, int index, int count, Action <Exception, int> callback, int offset)
        {
            GCHandle datagchandle = GCHandle.Alloc(data, GCHandleType.Pinned);
            var      fsr          = new FileSystemRequest();

            fsr.Callback += (ex) => {
                callback(ex, fsr.Result.ToInt32());
                datagchandle.Free();
            };
            var ptr = (IntPtr)(datagchandle.AddrOfPinnedObject().ToInt64() + index);
            int r   = uv_fs_read(loop.NativeHandle, fsr.Handle, FileHandle, ptr, (IntPtr)count, offset, FileSystemRequest.StaticEnd);

            Ensure.Success(r, loop);
        }
Esempio n. 11
0
        public static void Delete(Loop loop, string path, Action <Exception> callback)
        {
            var fsr = new FileSystemRequest();

            fsr.Callback = (ex, fsr2) => {
                if (callback != null)
                {
                    callback(ex);
                }
                ;
            };
            int r = uv_fs_rmdir(loop.Handle, fsr.Handle, path, FileSystemRequest.StaticEnd);

            Ensure.Success(r, loop);
        }
Esempio n. 12
0
        public void Send(Loop loop, Tcp socket, int offset, int length, Action <Exception, int> callback)
        {
            var fsr = new FileSystemRequest();

            fsr.Callback = (ex, fsr2) => {
                if (callback != null)
                {
                    callback(ex, (int)fsr.Result);
                }
                ;
            };
            int r = uv_fs_sendfile(loop.Handle, fsr.Handle, socket.handle, FileHandle, offset, length, FileSystemRequest.StaticEnd);

            Ensure.Success(r, loop);
        }
Esempio n. 13
0
        public void Write(Loop loop, int offset, ArraySegment <byte> segment, Action <Exception, int> callback)
        {
            var datagchandle = GCHandle.Alloc(segment.Array, GCHandleType.Pinned);
            var fsr          = new FileSystemRequest();

            fsr.Callback = (ex) => {
                Ensure.Success(ex, callback, fsr.Result.ToInt32());
                datagchandle.Free();
            };
            var ptr = new IntPtr(datagchandle.AddrOfPinnedObject().ToInt64() + segment.Offset);
            var buf = new uv_buf_t[] { new uv_buf_t(ptr, segment.Count) };
            int r   = uv_fs_write(loop.NativeHandle, fsr.Handle, FileDescriptor, buf, segment.Count, offset, FileSystemRequest.CallbackDelegate);

            Ensure.Success(r);
        }
Esempio n. 14
0
        public void Read(Loop loop, int offset, ArraySegment <byte> segment, Action <Exception, int> callback)
        {
            var datagchandle = GCHandle.Alloc(segment.Array, GCHandleType.Pinned);
            var fsr          = new FileSystemRequest();

            fsr.Callback = (ex) => {
                Ensure.Success(ex, callback, fsr.Result.ToInt32());
                datagchandle.Free();
            };
            UnixBufferStruct[] buf = new UnixBufferStruct[1];
            buf[0] = new UnixBufferStruct(datagchandle.AddrOfPinnedObject() + segment.Offset, segment.Count);
            int r = uv_fs_read(loop.NativeHandle, fsr.Handle, FileDescriptor, buf, 1, offset, FileSystemRequest.CallbackDelegate);

            Ensure.Success(r);
        }
Esempio n. 15
0
        public static void Readlink(Loop loop, string path, Action <Exception, string> callback)
        {
            var fsr = new FileSystemRequest(path);

            fsr.Callback = (ex) => {
                string res = null;
                if (ex == null)
                {
                    res = Marshal.PtrToStringAuto(fsr.Pointer);
                }
                Ensure.Success(ex, callback, res);
            };
            int r = uv_fs_readlink(loop.NativeHandle, fsr.Handle, path, FileSystemRequest.CallbackDelegate);

            Ensure.Success(r);
        }
Esempio n. 16
0
        public void Write(Loop loop, byte[] data, int length, int offset, Action <Exception, int> callback)
        {
            var datagchandle = GCHandle.Alloc(data, GCHandleType.Pinned);
            var fsr          = new FileSystemRequest();

            fsr.Callback += (ex, fsr2) => {
                if (callback != null)
                {
                    callback(ex, (int)fsr.Result);
                }
                datagchandle.Free();
            };
            int r = uv_fs_write(loop.Handle, fsr.Handle, FileHandle, datagchandle.AddrOfPinnedObject(), (IntPtr)length, offset, FileSystemRequest.StaticEnd);

            Ensure.Success(r, loop);
        }
Esempio n. 17
0
        public static void Open(Loop loop, string path, UVFileAccess access, Action <Exception, UVFile> callback)
        {
            var fsr = new FileSystemRequest(path);

            fsr.Callback = (ex) => {
                UVFile file = null;
                if (fsr.Result != IntPtr.Zero)
                {
                    file = new UVFile(loop, fsr.Result.ToInt32());
                }
                Ensure.Success(ex, callback, file);
            };
            int r = uv_fs_open(loop.NativeHandle, fsr.Handle, path, (int)access, 0, FileSystemRequest.CallbackDelegate);

            Ensure.Success(r);
        }
Esempio n. 18
0
        unsafe public static void Stat(Loop loop, string path, Action <Exception> callback)
        {
            var fsr = new FileSystemRequest();

            fsr.Callback = (ex, fsr2) => {
                // TODO: do this
                lin_stat *stats = (lin_stat *)fsr.Pointer;

                if (callback != null)
                {
                    callback(ex);
                }
            };
            int r = uv_fs_stat(loop.Handle, fsr.Handle, path, FileSystemRequest.StaticEnd);

            Ensure.Success(r, loop);
        }
Esempio n. 19
0
        public static void Open(Loop loop, string path, FileAccess access, Action <Exception, UVFile> callback)
        {
            var fsr = new FileSystemRequest();

            fsr.Callback = (ex, fsr2) => {
                UVFile file = null;
                if (fsr.Result != IntPtr.Zero)
                {
                    file = new UVFile(loop, fsr.Result);
                }
                if (callback != null)
                {
                    callback(ex, file);
                }
            };
            int r = uv_fs_open(loop.Handle, fsr.Handle, path, (int)access, 0, FileSystemRequest.StaticEnd);

            Ensure.Success(r, loop);
        }
Esempio n. 20
0
        public static unsafe void Read(Loop loop, string path, Action<Exception, string[]> callback)
        {
            var fsr = new FileSystemRequest();
            fsr.Callback = (ex) => {
                if (ex != null) {
                    callback(ex, null);
                    return;
                }

                int length = (int)fsr.Result;
                string[] res = new string[length];
                sbyte *ptr = (sbyte *)fsr.Pointer;
                for (int i = 0; i < length; i++) {
                    res[i] = new string(ptr);
                    ptr += res[i].Length + 1;
                }
                callback(ex, res);
            };
            uv_fs_readdir(loop.NativeHandle, fsr.Handle, path, 0, FileSystemRequest.StaticEnd);
        }
Esempio n. 21
0
        unsafe public void Stat(Loop loop, Action <Exception, UVFileStat> callback)
        {
            var fsr = new FileSystemRequest();

            fsr.Callback = (ex) => {
                if (callback != null)
                {
                    UVFileStat stat = null;
                    if (UV.isUnix)
                    {
                        stat = lin_stat.Convert(fsr.Pointer);
                    }
                    if (callback != null)
                    {
                        callback(ex, stat);
                    }
                }
            };
            int r = uv_fs_fstat(loop.NativeHandle, fsr.Handle, FileHandle, FileSystemRequest.StaticEnd);

            Ensure.Success(r, loop);
        }
Esempio n. 22
0
        unsafe public static void Read(Loop loop, string path, Action <Exception, string[]> callback)
        {
            var fsr = new FileSystemRequest();

            fsr.Callback = (ex) => {
                if (ex != null)
                {
                    callback(ex, null);
                    return;
                }

                int      length = (int)fsr.Result;
                string[] res    = new string[length];
                sbyte *  ptr    = (sbyte *)fsr.Pointer;
                for (int i = 0; i < length; i++)
                {
                    res[i] = new string(ptr);
                    ptr   += res[i].Length + 1;
                }
                callback(ex, res);
            };
            uv_fs_readdir(loop.NativeHandle, fsr.Handle, path, 0, FileSystemRequest.StaticEnd);
        }
Esempio n. 23
0
        unsafe public static void Read(Loop loop, string path, Action <Exception, string[]> callback)
        {
            var fsr = new FileSystemRequest();

            fsr.Callback = (ex, fsr2) => {
                if (ex != null)
                {
                    callback(ex, null);
                    return;
                }

                int           length = (int)fsr.Result;
                List <string> list   = new List <string>(length);
                sbyte *       ptr    = (sbyte *)fsr.Pointer;
                for (int i = 0; i < length; i++)
                {
                    list.Add(new string(ptr));
                    ptr += strlen((IntPtr)ptr) + 1;
                }
                callback(ex, list.ToArray());
            };
            uv_fs_readdir(loop.Handle, fsr.Handle, path, 0, fsr.End);
        }
Esempio n. 24
0
        public static void Read(Loop loop, string path, Action <Exception, UVDirectoryEntity[]> callback)
        {
            var fsr = new FileSystemRequest();

            fsr.Callback = (ex) => {
                if (ex != null)
                {
                    callback(ex, null);
                    return;
                }

                var         list = new List <UVDirectoryEntity>();
                uv_dirent_t entity;
                while (UVException.Map(uv_fs_scandir_next(fsr.Handle, out entity)) != UVErrorCode.EOF)
                {
                    list.Add(new UVDirectoryEntity(entity));
                }

                Ensure.Success(ex, callback, list.ToArray());
            };
            int r = uv_fs_scandir(loop.NativeHandle, fsr.Handle, path, 0, FileSystemRequest.CallbackDelegate);

            Ensure.Success(r);
        }
Esempio n. 25
0
 public void Truncate(Loop loop, int offset, Action<Exception> callback)
 {
     var fsr = new FileSystemRequest();
     fsr.Callback = callback;
     int r = uv_fs_ftruncate(loop.NativeHandle, fsr.Handle, FileDescriptor, offset, FileSystemRequest.StaticEnd);
     Ensure.Success(r, loop);
 }
Esempio n. 26
0
 public void Sync(Loop loop, Action<Exception> callback)
 {
     var fsr = new FileSystemRequest();
     fsr.Callback = (ex) => {
         if (callback != null) {
             callback(ex);
         }
     };
     int r = uv_fs_fsync(loop.NativeHandle, fsr.Handle, FileDescriptor, FileSystemRequest.StaticEnd);
     Ensure.Success(r, loop);
 }
Esempio n. 27
0
 public unsafe void Stat(Loop loop, Action<Exception, UVFileStat> callback)
 {
     var fsr = new FileSystemRequest();
     fsr.Callback = (ex) => {
         if (callback != null) {
             UVFileStat stat = null;
             if (UV.isUnix) {
                 stat = lin_stat.Convert(fsr.Pointer);
             }
             if (callback != null) {
                 callback(ex, stat);
             }
         }
     };
     int r = uv_fs_fstat(loop.NativeHandle, fsr.Handle, FileDescriptor, FileSystemRequest.StaticEnd);
     Ensure.Success(r, loop);
 }
Esempio n. 28
0
 public void Read(Loop loop, byte[] data, int length, int offset, Action<Exception, int> callback)
 {
     GCHandle datagchandle = GCHandle.Alloc(data, GCHandleType.Pinned);
     var fsr = new FileSystemRequest();
     fsr.Callback += (ex, fsr2) => {
         callback(ex, fsr.Result.ToInt32());
         datagchandle.Free();
     };
     int r = uv_fs_read(loop.Handle, fsr.Handle, FileHandle, datagchandle.AddrOfPinnedObject(), (IntPtr)length, offset, FileSystemRequest.StaticEnd);
     Ensure.Success(r, loop);
 }
Esempio n. 29
0
 public static void Symlink(Loop loop, string path, string newPath, Action<Exception> callback)
 {
     var fsr = new FileSystemRequest();
     fsr.Callback = callback;
     int r = uv_fs_symlink(loop.NativeHandle, fsr.Handle, path, newPath, 0, FileSystemRequest.CallbackDelegate);
     Ensure.Success(r);
 }
Esempio n. 30
0
        public static unsafe void Read(Loop loop, string path, Action<Exception, string[]> callback)
        {
            var fsr = new FileSystemRequest();
            fsr.Callback = (ex, fsr2) => {
                if (ex != null) {
                    callback(ex, null);
                    return;
                }

                int length = (int)fsr.Result;
                List<string> list = new List<string>(length);
                sbyte *ptr = (sbyte *)fsr.Pointer;
                for (int i = 0; i < length; i++) {
                    list.Add(new string(ptr));
                    ptr += strlen((IntPtr)ptr) + 1;
                }
                callback(ex, list.ToArray());
            };
            uv_fs_readdir(loop.Handle, fsr.Handle, path, 0, fsr.End);
        }
Esempio n. 31
0
 public static void Open(Loop loop, string path, FileAccess access, Action<Exception, UVFile> callback)
 {
     var fsr = new FileSystemRequest();
     fsr.Callback = (ex, fsr2) => {
         UVFile file = null;
         if (fsr.Result != IntPtr.Zero) {
             file = new UVFile(loop, fsr.Result);
         }
         if (callback != null) {
             callback(ex, file);
         }
     };
     int r = uv_fs_open(loop.Handle, fsr.Handle, path, (int)access, 0, FileSystemRequest.StaticEnd);
     Ensure.Success(r, loop);
 }
Esempio n. 32
0
 public void Write(Loop loop, byte[] data, int length, int offset, Action<Exception, int> callback)
 {
     var datagchandle = GCHandle.Alloc(data, GCHandleType.Pinned);
     var fsr = new FileSystemRequest();
     fsr.Callback += (ex, fsr2) => {
         if (callback != null) {
             callback(ex, (int)fsr.Result);
         }
         datagchandle.Free();
     };
     int r = uv_fs_write(loop.Handle, fsr.Handle, FileHandle, datagchandle.AddrOfPinnedObject(), (IntPtr)length, offset, FileSystemRequest.StaticEnd);
     Ensure.Success(r, loop);
 }
Esempio n. 33
0
 public void Truncate(Loop loop, int offset, Action<Exception> callback)
 {
     var fsr = new FileSystemRequest();
     fsr.Callback = (ex, fsr2) => { callback(ex); };
     int r = uv_fs_ftruncate(loop.Handle, fsr.Handle, FileHandle, offset, FileSystemRequest.StaticEnd);
     Ensure.Success(r, loop);
 }
Esempio n. 34
0
 public unsafe void Stat(Loop loop, Action<Exception> callback)
 {
     var fsr = new FileSystemRequest();
     fsr.Callback = (ex, fsr2) => {
         lin_stat stats = new lin_stat();
         uv_fs_req_stat(fsr.Handle, &stats);
         Console.WriteLine (stats);
         callback(ex);
     };
     int r = uv_fs_fstat(loop.Handle, fsr.Handle, FileHandle, FileSystemRequest.StaticEnd);
     Ensure.Success(r, loop);
 }
Esempio n. 35
0
        public static unsafe void Stat(Loop loop, string path, Action<Exception> callback)
        {
            var fsr = new FileSystemRequest();
            fsr.Callback = (ex, fsr2) => {
                // TODO: do this
                lin_stat *stats = (lin_stat *)fsr.Pointer;

                if (callback != null) {
                    callback(ex);
                }
            };
            int r = uv_fs_stat(loop.Handle, fsr.Handle, path, FileSystemRequest.StaticEnd);
            Ensure.Success(r, loop);
        }
Esempio n. 36
0
 public void Write(Loop loop, byte[] data, int index, int count, Action<Exception, int> callback, int offset)
 {
     var datagchandle = GCHandle.Alloc(data, GCHandleType.Pinned);
     var fsr = new FileSystemRequest();
     fsr.Callback += (ex) => {
         if (callback != null) {
             callback(ex, (int)fsr.Result);
         }
         datagchandle.Free();
     };
     var ptr = (IntPtr)(datagchandle.AddrOfPinnedObject().ToInt64() + index);
     int r = uv_fs_write(loop.NativeHandle, fsr.Handle, FileDescriptor, ptr, (IntPtr)count, offset, FileSystemRequest.StaticEnd);
     Ensure.Success(r, loop);
 }
Esempio n. 37
0
 public static void Link(Loop loop, string path, string newPath, Action<Exception> callback)
 {
     var fsr = new FileSystemRequest();
     fsr.Callback = (ex, fsr2) => { callback(ex); };
     int r = uv_fs_link(loop.Handle, fsr.Handle, path, newPath, FileSystemRequest.StaticEnd);
     Ensure.Success(r, loop);
 }
Esempio n. 38
0
 public static void Readlink(Loop loop, string path, Action<Exception, string> callback)
 {
     var fsr = new FileSystemRequest(path);
     fsr.Callback = (ex) => {
         string res = null;
         if (ex == null) {
             res = Marshal.PtrToStringAuto(fsr.Pointer);
         }
         if (callback != null) {
             callback(ex, res);
         }
     };
     int r = uv_fs_readlink(loop.NativeHandle, fsr.Handle, path, FileSystemRequest.StaticEnd);
     Ensure.Success(r);
 }
Esempio n. 39
0
 public void Stat(Loop loop, Action<Exception, UVFileStat> callback)
 {
     var fsr = new FileSystemRequest();
     fsr.Callback = (ex) => {
         if (callback != null) {
             Ensure.Success(ex, callback, new UVFileStat(fsr.stat));
         }
     };
     int r = uv_fs_fstat(loop.NativeHandle, fsr.Handle, FileDescriptor, FileSystemRequest.CallbackDelegate);
     Ensure.Success(r);
 }
Esempio n. 40
0
 public void Chown(Loop loop, int uid, int gid, Action<Exception> callback)
 {
     var fsr = new FileSystemRequest();
     fsr.Callback = callback;
     int r = uv_fs_fchown(loop.NativeHandle, fsr.Handle, FileDescriptor, uid, gid, FileSystemRequest.StaticEnd);
     Ensure.Success(r, loop);
 }
Esempio n. 41
0
 public void Read(Loop loop, byte[] data, int index, int count, Action<Exception, int> callback, int offset)
 {
     GCHandle datagchandle = GCHandle.Alloc(data, GCHandleType.Pinned);
     var fsr = new FileSystemRequest();
     fsr.Callback += (ex) => {
         callback(ex, fsr.Result.ToInt32());
         datagchandle.Free();
     };
     var ptr = (IntPtr)(datagchandle.AddrOfPinnedObject().ToInt64() + index);
     int r = uv_fs_read(loop.NativeHandle, fsr.Handle, FileHandle, ptr, (IntPtr)count, offset, FileSystemRequest.StaticEnd);
     Ensure.Success(r, loop);
 }
Esempio n. 42
0
 public void DataSync(Loop loop, Action<Exception> callback)
 {
     var fsr = new FileSystemRequest();
     fsr.Callback = callback;
     int r = uv_fs_fdatasync(loop.NativeHandle, fsr.Handle, FileDescriptor, FileSystemRequest.StaticEnd);
     Ensure.Success(r, loop);
 }
Esempio n. 43
0
 public void Send(Loop loop, Tcp socket, int offset, int length, Action<Exception, int> callback)
 {
     var fsr = new FileSystemRequest();
     fsr.Callback = (ex, fsr2) => {
         if (callback != null) {
             callback(ex, (int)fsr.Result);
         };
     };
     int r = uv_fs_sendfile(loop.Handle, fsr.Handle, socket.handle, FileHandle, offset, length, FileSystemRequest.StaticEnd);
     Ensure.Success(r, loop);
 }
Esempio n. 44
0
 public void DataSync(Loop loop, Action<Exception> callback)
 {
     var fsr = new FileSystemRequest();
     fsr.Callback = (ex, fsr2) => { callback(ex); };
     int r = uv_fs_fdatasync(loop.Handle, fsr.Handle, FileHandle, FileSystemRequest.StaticEnd);
     Ensure.Success(r, loop);
 }