コード例 #1
0
 private void Get(string filename, Action <int> callback)
 {
     UVFile.Open(filename, UVFileAccess.Read, (e, file) => {
         byte[] r = new byte[512];
         file.Read(r, r.Length, 0, (e2, size) => {
             if (callback != null)
             {
                 callback(int.Parse(Encoding.ASCII.GetString(r, 0, size)));
             }
         });
     });
 }
コード例 #2
0
        public void CreateNotexistingFile()
        {
            if (File.Exists(Default.File))
            {
                File.Delete(Default.File);
            }

            UVFile.Open(Default.File, UVFileAccess.Write, (e, file) => {
                Assert.IsNull(e);
                Assert.IsNotNull(file);
            });

            Loop.Default.Run();
        }
コード例 #3
0
        public static Task <int> WriteAsync(this UVFile file, Loop loop, Encoding encoding, string text, int offset)
        {
            var tcs = new TaskCompletionSource <int>();

            try {
                file.Write(loop, encoding, text, (e, result) => {
                    if (e == null)
                    {
                        tcs.SetResult(result);
                    }
                    else
                    {
                        tcs.SetException(e);
                    }
                }, offset);
            } catch (Exception e) {
                tcs.SetException(e);
            }
            return(tcs.Task);
        }
コード例 #4
0
        public static Task <int> WriteAsync(this UVFile file, Loop loop, byte[] data, int index, int count, int offset)
        {
            var tcs = new TaskCompletionSource <int>();

            try {
                file.Write(loop, data, index, count, (e, result) => {
                    if (e == null)
                    {
                        tcs.SetResult(result);
                    }
                    else
                    {
                        tcs.SetException(e);
                    }
                }, offset);
            } catch (Exception e) {
                tcs.SetException(e);
            }
            return(tcs.Task);
        }
コード例 #5
0
        private void Set(int value, Action <bool> callback)
        {
            UVFile.Open(PWM, UVFileAccess.Write, (e, file) => {
                if (e != null)
                {
                    callback(false);
                    return;
                }

                file.Write(Encoding.ASCII, value.ToString(), (e2, length) => {
                    if (e2 != null)
                    {
                        callback(false);
                        return;
                    }
                    if (callback != null)
                    {
                        callback(true);
                    }
                });
            });
        }
コード例 #6
0
 public static Task <int?> ReadAsync(this UVFile file, ArraySegment <byte> data)
 {
     return(HelperFunctions.Wrap <ArraySegment <byte>, int?>(data, file.Read));
 }
コード例 #7
0
 public static Task <UVFileStat?> StatAsync(this UVFile file)
 {
     return(file.StatAsync(file.Loop));
 }
コード例 #8
0
 public static Task ChownAsync(this UVFile file, int uid, int gid)
 {
     return(file.ChownAsync(file.Loop, uid, gid));
 }
コード例 #9
0
 public static Task ChmodAsync(this UVFile file, int mode)
 {
     return(file.ChmodAsync(file.Loop, mode));
 }
コード例 #10
0
 public static Task TruncateSync(this UVFile file, int offset)
 {
     return(file.TruncateSync(file.Loop, offset));
 }
コード例 #11
0
 public static Task DataSyncAsync(this UVFile file)
 {
     return(file.DataSyncAsync(file.Loop));
 }
コード例 #12
0
 public static Task <int> WriteAsync(this UVFile file, int offset, byte[] data, int index)
 {
     return(HelperFunctions.Wrap <int, byte[], int, int>(offset, data, index, file.Write));
 }
コード例 #13
0
 public static Task <int> ReadAsync(this UVFile file, byte[] data)
 {
     return(HelperFunctions.Wrap <byte[], int>(data, file.Read));
 }
コード例 #14
0
 public static Task <UVFileStat> StatAsync(this UVFile file, Loop loop)
 {
     return(FWrap <UVFileStat>(loop, file.Stat));
 }
コード例 #15
0
 public static Task ChmodAsync(this UVFile file, Loop loop, int mode)
 {
     return(Wrap(loop, mode, file.Chmod));
 }
コード例 #16
0
 public static Task <int?> WriteAsync(this UVFile file, byte[] data)
 {
     return(HelperFunctions.Wrap <byte[], int?>(data, file.Write));
 }
コード例 #17
0
 public static Task DataSyncAsync(this UVFile file, Loop loop)
 {
     return(HelperFunctions.Wrap(loop, file.DataSync));
 }
コード例 #18
0
        public static Task <int?> ReadAsync(this UVFile file, byte[] data, int index, int count)

        {
            return(HelperFunctions.Wrap <byte[], int, int, int?>(data, index, count, file.Read));
        }
コード例 #19
0
 public static Task TruncateSync(this UVFile file, Loop loop, int offset)
 {
     return(HelperFunctions.Wrap(loop, offset, file.Truncate));
 }
コード例 #20
0
 public static Task <int?> ReadAsync(this UVFile file, int offset, byte[] data)
 {
     return(HelperFunctions.Wrap <int, byte[], int?>(offset, data, file.Read));
 }
コード例 #21
0
 public static Task ChmodAsync(this UVFile file, Loop loop, int mode)
 {
     return(HelperFunctions.Wrap(loop, mode, file.Chmod));
 }
コード例 #22
0
 public static Task <int?> ReadAsync(this UVFile file, Loop loop, byte[] data)
 {
     return(HelperFunctions.Wrap <Loop, byte[], int?>(loop, data, file.Read));
 }
コード例 #23
0
 public static Task ChownAsync(this UVFile file, Loop loop, int uid, int gid)
 {
     return(HelperFunctions.Wrap(loop, uid, gid, file.Chown));
 }
コード例 #24
0
 public static Task <int?> WriteAsync(this UVFile file, int offset, ArraySegment <byte> data)
 {
     return(HelperFunctions.Wrap <int, ArraySegment <byte>, int?>(offset, data, file.Write));
 }
コード例 #25
0
 public static Task <UVFileStat?> StatAsync(this UVFile file, Loop loop)
 {
     return(HelperFunctions.Wrap <Loop, UVFileStat>(loop, file.Stat));
 }
コード例 #26
0
 public static Task <int?> WriteAsync(this UVFile file, Loop loop, ArraySegment <byte> data)
 {
     return(HelperFunctions.Wrap <Loop, ArraySegment <byte>, int?>(loop, data, file.Write));
 }
コード例 #27
0
 public static Task <int?> ReadAsync(this UVFile file, Loop loop, int offset, ArraySegment <byte> data)
 {
     return(HelperFunctions.Wrap <Loop, int, ArraySegment <byte>, int?>(loop, offset, data, file.Read));
 }
コード例 #28
0
 public static Task <int?> WriteAsync(this UVFile file, Loop loop, byte[] data, int index, int count)
 {
     return(HelperFunctions.Wrap <Loop, byte[], int, int, int?>(loop, data, index, count, file.Write));
 }
コード例 #29
0
 public static Task <int?> ReadAsync(this UVFile file, Loop loop, int offset, byte[] data, int index, int count)
 {
     return(HelperFunctions.Wrap <Loop, int, byte[], int, int, int?>(loop, offset, data, index, count, file.Read));
 }
コード例 #30
0
 public static Task <int?> WriteAsync(this UVFile file, Loop loop, int offset, byte[] data)
 {
     return(HelperFunctions.Wrap <Loop, int, byte[], int?>(loop, offset, data, file.Write));
 }