Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -22,57 +22,62 @@ using System;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
||||
namespace Server {
|
||||
public static class NativeReader {
|
||||
namespace Server
|
||||
{
|
||||
public static class NativeReader
|
||||
{
|
||||
private static readonly INativeReader m_NativeReader;
|
||||
|
||||
private static readonly INativeReader m_NativeReader;
|
||||
static NativeReader()
|
||||
{
|
||||
if (Core.Unix)
|
||||
m_NativeReader = new NativeReaderUnix();
|
||||
else
|
||||
m_NativeReader = new NativeReaderWin32();
|
||||
}
|
||||
|
||||
static NativeReader() {
|
||||
if ( Core.Unix )
|
||||
m_NativeReader = new NativeReaderUnix();
|
||||
else
|
||||
m_NativeReader = new NativeReaderWin32();
|
||||
}
|
||||
public static unsafe void Read(IntPtr ptr, void* buffer, int length)
|
||||
{
|
||||
m_NativeReader.Read(ptr, buffer, length);
|
||||
}
|
||||
}
|
||||
|
||||
public static unsafe void Read( IntPtr ptr, void *buffer, int length ) {
|
||||
m_NativeReader.Read( ptr, buffer, length );
|
||||
}
|
||||
}
|
||||
public interface INativeReader
|
||||
{
|
||||
unsafe void Read(IntPtr ptr, void* buffer, int length);
|
||||
}
|
||||
|
||||
public interface INativeReader {
|
||||
unsafe void Read( IntPtr ptr, void *buffer, int length );
|
||||
}
|
||||
public sealed class NativeReaderWin32 : INativeReader
|
||||
{
|
||||
public unsafe void Read(IntPtr ptr, void* buffer, int length)
|
||||
{
|
||||
//UnsafeNativeMethods._lread( ptr, buffer, length );
|
||||
uint lpNumberOfBytesRead = 0;
|
||||
UnsafeNativeMethods.ReadFile(ptr, buffer, (uint)length, ref lpNumberOfBytesRead, null);
|
||||
}
|
||||
|
||||
public sealed class NativeReaderWin32 : INativeReader {
|
||||
internal class UnsafeNativeMethods {
|
||||
/*[DllImport("kernel32")]
|
||||
internal unsafe static extern int _lread(IntPtr hFile, void* lpBuffer, int wBytes);*/
|
||||
internal class UnsafeNativeMethods
|
||||
{
|
||||
/*[DllImport("kernel32")]
|
||||
internal unsafe static extern int _lread(IntPtr hFile, void* lpBuffer, int wBytes);*/
|
||||
|
||||
[DllImport("kernel32")]
|
||||
internal unsafe static extern bool ReadFile(IntPtr hFile, void* lpBuffer, uint nNumberOfBytesToRead, ref uint lpNumberOfBytesRead, NativeOverlapped* lpOverlapped);
|
||||
}
|
||||
[DllImport("kernel32")]
|
||||
internal static extern unsafe bool ReadFile(IntPtr hFile, void* lpBuffer, uint nNumberOfBytesToRead,
|
||||
ref uint lpNumberOfBytesRead, NativeOverlapped* lpOverlapped);
|
||||
}
|
||||
}
|
||||
|
||||
public NativeReaderWin32() {
|
||||
}
|
||||
public sealed class NativeReaderUnix : INativeReader
|
||||
{
|
||||
public unsafe void Read(IntPtr ptr, void* buffer, int length)
|
||||
{
|
||||
UnsafeNativeMethods.read(ptr, buffer, length);
|
||||
}
|
||||
|
||||
public unsafe void Read( IntPtr ptr, void *buffer, int length ) {
|
||||
//UnsafeNativeMethods._lread( ptr, buffer, length );
|
||||
uint lpNumberOfBytesRead = 0;
|
||||
UnsafeNativeMethods.ReadFile(ptr, buffer, (uint)length, ref lpNumberOfBytesRead, null);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class NativeReaderUnix : INativeReader {
|
||||
internal class UnsafeNativeMethods {
|
||||
[DllImport("libc")]
|
||||
internal unsafe static extern int read(IntPtr ptr, void* buffer, int length);
|
||||
}
|
||||
|
||||
public NativeReaderUnix() {
|
||||
}
|
||||
|
||||
public unsafe void Read( IntPtr ptr, void *buffer, int length ) {
|
||||
UnsafeNativeMethods.read( ptr, buffer, length );
|
||||
}
|
||||
}
|
||||
internal class UnsafeNativeMethods
|
||||
{
|
||||
[DllImport("libc")]
|
||||
internal static extern unsafe int read(IntPtr ptr, void* buffer, int length);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue