2using System.Runtime.InteropServices;
16#if FIRST_PASS == false
18 static FileDescriptorAccessor fileDescriptorAccessor;
20 static FileDescriptorAccessor FileDescriptorAccessor =>
JVM.
Internal.BaseAccessors.Get(
ref fileDescriptorAccessor);
29 static void SetPtr(
object self,
long ptr)
32 throw new NotImplementedException();
36 var p = FileDescriptorAccessor.GetPtr(
self);
37 if (p != ptr || ptr == -1)
39 var stream = (IDisposable)FileDescriptorAccessor.GetStream(
self);
43 FileDescriptorAccessor.SetStream(
self,
null);
47 FileDescriptorAccessor.SetPtr(
self, ptr);
57 public static int getFd(
object self)
60 throw new NotImplementedException();
63 return (
int)FileDescriptorAccessor.GetPtr(
self);
72 public static void setFd(
object self,
int value)
85 throw new NotImplementedException();
88 return FileDescriptorAccessor.GetPtr(
self);
97 public static void setHandle(
object self,
long value)
110 throw new NotImplementedException();
112 var fdo = FileDescriptorAccessor.Init();
113 FileDescriptorAccessor.SetPtr(fdo, GetStandardHandle(fd));
118 [DllImport(
"Kernel32")]
119 static extern IntPtr GetStdHandle(
int nStdHandle);
126 static long GetStandardHandle(
int fd)
128 if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
131 return (
long)GetStdHandle(-10);
133 return (
long)GetStdHandle(-11);
135 return (
long)GetStdHandle(-12);
Implements the native methods for 'FileDescriptor'.
static object standardStream(int fd)
Implements the native method 'standardStream'.
static int getFd(object self)
Implements the native method 'getFd'.
static void setHandle(object self, long value)
Implements the native method 'setHandle'.
static void setFd(object self, int value)
Implements the native method 'setFd'.
static long getHandle(object self)
Implements the native method 'getHandle'.
Main state of the running JVM.