Exemple #1
0
        public int Read(SafeFileHandle handle, byte *buffer, int offset, int count)
        {
            var read = 0;

            if (!WinNative.ReadFile(handle, buffer, count, ref read, 0))
            {
                throw new Win32Exception();
            }

            return(read);
        }
Exemple #2
0
        public static int Read(SafeFileHandle handle, byte *buffer, int offset, int count)
        {
#if !__MonoCS__ && !USE_UNIX_IO
            var read = 0;

            if (!WinNative.ReadFile(handle, buffer, count, ref read, 0))
            {
                throw new Win32Exception();
            }
            return(read);
#else
            int r;
            do
            {
                r = (int)Syscall.read(handle.DangerousGetHandle().ToInt32(), buffer, (ulong)count);
            } while (UnixMarshal.ShouldRetrySyscall((int)r));
            if (r == -1)
            {
                UnixMarshal.ThrowExceptionForLastError();
            }
            return(count);
#endif
        }