File: Input.custom

package info (click to toggle)
gsf-sharp 0.8-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,548 kB
  • ctags: 19
  • sloc: sh: 8,694; makefile: 66; ansic: 33
file content (36 lines) | stat: -rw-r--r-- 997 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

		[DllImport("libgsf-1.dll")]
		static extern IntPtr gsf_input_read(IntPtr raw, int num_bytes, IntPtr optional_buffer);

		public byte[] Read(int num_bytes) {
			IntPtr raw_ret = gsf_input_read(Handle, num_bytes, IntPtr.Zero);
			if (raw_ret == IntPtr.Zero) {
				return null;
			}
			byte[] ret = new byte[num_bytes];
			System.Runtime.InteropServices.Marshal.Copy (raw_ret, ret, 0, num_bytes);
			return ret;
		}

		[DllImport("libgsf-1.dll")]
		static extern bool gsf_input_seek(IntPtr raw, long offset, int whence);

		public bool Seek(long offset, System.IO.SeekOrigin origin) {
			int whence;
			switch (origin) {
			case System.IO.SeekOrigin.Begin:
				whence = 1;
				break;
			case System.IO.SeekOrigin.Current:
				whence = 0;
				break;
			case System.IO.SeekOrigin.End:
				whence = 2;
				break;
			default:
				return true;
			}
			bool raw_ret = gsf_input_seek(Handle, offset, whence);
			bool ret = !raw_ret; /* Reverse this so that it's the same as Output. */
			return ret;
		}