Example #1
0
        private int ReadData(SafeHandle safeHandle, byte[] buf, int offset,
                             int count)
        {
            MonoIOError error;
            int         amount = 0;

            /* when async == true, if we get here we don't suport AIO or it's disabled
             * and we're using the threadpool */
            amount = MonoIO.Read(safeHandle, buf, offset, count, out error);
            if (error == MonoIOError.ERROR_BROKEN_PIPE)
            {
                amount = 0;                 // might not be needed, but well...
            }
            else if (error != MonoIOError.ERROR_SUCCESS)
            {
                // don't leak the path information for isolated storage
                throw MonoIO.GetException(GetSecureFileName(name), error);
            }

            /* Check for read error */
            if (amount == -1)
            {
                throw new IOException();
            }

            return(amount);
        }