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))); } }); }); }
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(); }
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); }
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); }
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); } }); }); }
public static Task <int?> ReadAsync(this UVFile file, ArraySegment <byte> data) { return(HelperFunctions.Wrap <ArraySegment <byte>, int?>(data, file.Read)); }
public static Task <UVFileStat?> StatAsync(this UVFile file) { return(file.StatAsync(file.Loop)); }
public static Task ChownAsync(this UVFile file, int uid, int gid) { return(file.ChownAsync(file.Loop, uid, gid)); }
public static Task ChmodAsync(this UVFile file, int mode) { return(file.ChmodAsync(file.Loop, mode)); }
public static Task TruncateSync(this UVFile file, int offset) { return(file.TruncateSync(file.Loop, offset)); }
public static Task DataSyncAsync(this UVFile file) { return(file.DataSyncAsync(file.Loop)); }
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)); }
public static Task <int> ReadAsync(this UVFile file, byte[] data) { return(HelperFunctions.Wrap <byte[], int>(data, file.Read)); }
public static Task <UVFileStat> StatAsync(this UVFile file, Loop loop) { return(FWrap <UVFileStat>(loop, file.Stat)); }
public static Task ChmodAsync(this UVFile file, Loop loop, int mode) { return(Wrap(loop, mode, file.Chmod)); }
public static Task <int?> WriteAsync(this UVFile file, byte[] data) { return(HelperFunctions.Wrap <byte[], int?>(data, file.Write)); }
public static Task DataSyncAsync(this UVFile file, Loop loop) { return(HelperFunctions.Wrap(loop, file.DataSync)); }
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)); }
public static Task TruncateSync(this UVFile file, Loop loop, int offset) { return(HelperFunctions.Wrap(loop, offset, file.Truncate)); }
public static Task <int?> ReadAsync(this UVFile file, int offset, byte[] data) { return(HelperFunctions.Wrap <int, byte[], int?>(offset, data, file.Read)); }
public static Task ChmodAsync(this UVFile file, Loop loop, int mode) { return(HelperFunctions.Wrap(loop, mode, file.Chmod)); }
public static Task <int?> ReadAsync(this UVFile file, Loop loop, byte[] data) { return(HelperFunctions.Wrap <Loop, byte[], int?>(loop, data, file.Read)); }
public static Task ChownAsync(this UVFile file, Loop loop, int uid, int gid) { return(HelperFunctions.Wrap(loop, uid, gid, file.Chown)); }
public static Task <int?> WriteAsync(this UVFile file, int offset, ArraySegment <byte> data) { return(HelperFunctions.Wrap <int, ArraySegment <byte>, int?>(offset, data, file.Write)); }
public static Task <UVFileStat?> StatAsync(this UVFile file, Loop loop) { return(HelperFunctions.Wrap <Loop, UVFileStat>(loop, file.Stat)); }
public static Task <int?> WriteAsync(this UVFile file, Loop loop, ArraySegment <byte> data) { return(HelperFunctions.Wrap <Loop, ArraySegment <byte>, int?>(loop, data, file.Write)); }
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)); }
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)); }
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)); }
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)); }