Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/hakchi2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'TrackableFileStream.cs')
-rw-r--r--TrackableFileStream.cs39
1 files changed, 39 insertions, 0 deletions
diff --git a/TrackableFileStream.cs b/TrackableFileStream.cs
new file mode 100644
index 00000000..3ff953dd
--- /dev/null
+++ b/TrackableFileStream.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+
+namespace com.clusterrr.util
+{
+ public class TrackableFileStream : FileStream
+ {
+ public delegate void OnProgressDelegate(long Position, long Length);
+ public event OnProgressDelegate OnProgress = delegate { };
+
+ public TrackableFileStream(string path, FileMode mode) : base(path, mode) { }
+
+ public override void Write(byte[] array, int offset, int count)
+ {
+ base.Write(array, offset, count);
+ OnProgress(this.Position, this.Length);
+ }
+ public override void WriteByte(byte value)
+ {
+ base.WriteByte(value);
+ OnProgress(this.Position, this.Length);
+ }
+ public override int Read(byte[] array, int offset, int count)
+ {
+ var r = base.Read(array, offset, count);
+ OnProgress(this.Position, this.Length);
+ return r;
+ }
+ public override int ReadByte()
+ {
+ var r = base.ReadByte();
+ OnProgress(this.Position, this.Length);
+ return r;
+ }
+ }
+}