67 public static void open0(
object self,
string name,
int mode)
70 throw new NotImplementedException();
72 if (
JVM.Vfs.IsPath(name))
74 var fd = RandomAccessFileAccessor.GetFd(
self);
76 throw new global::java.io.IOException(
"Invalid file handle.");
80 var fileMode = (FileMode)0;
81 if ((mode & O_RDONLY) == O_RDONLY)
82 fileMode |= FileMode.Open;
83 if ((mode & O_RDWR) == O_RDWR)
84 fileMode |= FileMode.OpenOrCreate;
86 var fileAccess = (FileAccess)0;
87 if ((mode & O_RDONLY) == O_RDONLY)
88 fileAccess |= FileAccess.Read;
89 if ((mode & O_RDWR) == O_RDWR)
90 fileAccess |= FileAccess.ReadWrite;
92 FileDescriptorAccessor.SetPtr(fd, -1);
93 FileDescriptorAccessor.SetStream(fd,
JVM.Vfs.Open(name, fileMode, fileAccess));
96 catch (ObjectDisposedException e)
98 throw new global::java.io.IOException(e.Message);
100 catch (ArgumentException e)
102 throw new global::java.io.FileNotFoundException(e.Message);
104 catch (SecurityException e)
106 throw new global::java.lang.SecurityException(e.Message);
108 catch (UnauthorizedAccessException)
110 throw new global::java.io.FileNotFoundException(name +
" (Access is denied)");
112 catch (IOException e)
114 throw new global::java.io.FileNotFoundException(e.Message);
116 catch (NotSupportedException e)
118 throw new global::java.io.FileNotFoundException(e.Message);
123 __callerID ??= global::ikvm.@
internal.CallerID.create(typeof(global::java.io.RandomAccessFile).TypeHandle);
124 __jniPtr__open0 ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__open0>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/RandomAccessFile", nameof(
open0),
"(Ljava/lang/String;I)V"));
126 var jniEnv = jniFrm.Enter(__callerID);
129 __jniPtr__open0(jniEnv, jniFrm.MakeLocalRef(
self), jniFrm.MakeLocalRef(name), mode);
133 System.Console.WriteLine(
"*** exception in native code ***");
134 System.Console.WriteLine(ex);
150 public static int read0(
object self)
153 throw new NotImplementedException();
155 var fd = RandomAccessFileAccessor.GetFd(
self);
157 throw new global::java.io.IOException(
"Invalid file handle.");
159 if (FileDescriptorAccessor.GetStream(fd) is Stream stream)
161 if (stream.CanRead ==
false)
162 throw new global::java.io.IOException(
"Read failed.");
167 return stream.ReadByte();
169 catch (ObjectDisposedException e)
171 throw new global::java.io.IOException(e.Message);
173 catch (NotSupportedException e)
175 throw new global::java.io.IOException(e.Message);
177 catch (IOException e)
179 throw new global::java.io.IOException(e.Message);
184 __callerID ??= global::ikvm.@
internal.CallerID.create(typeof(global::java.io.RandomAccessFile).TypeHandle);
185 __jniPtr__read0 ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__read0>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/RandomAccessFile", nameof(
read0),
"()I"));
187 var jniEnv = jniFrm.Enter(__callerID);
190 return __jniPtr__read0(jniEnv, jniFrm.MakeLocalRef(
self));
194 System.Console.WriteLine(
"*** exception in native code ***");
195 System.Console.WriteLine(ex);
214 public static int readBytes(
object self,
byte[] bytes,
int off,
int len)
217 throw new NotImplementedException();
219 var fd = RandomAccessFileAccessor.GetFd(
self);
221 throw new global::java.io.IOException(
"Invalid file handle.");
223 if (FileDescriptorAccessor.GetStream(fd) is Stream stream)
226 throw new global::java.lang.NullPointerException();
228 if ((off < 0) || (off > bytes.Length) || (len < 0) || (len > (bytes.Length - off)))
229 throw new global::java.lang.IndexOutOfBoundsException();
234 if (stream.CanRead ==
false)
235 throw new global::java.io.IOException(
"Read failed.");
239 var n = stream.Read(bytes, off, len);
240 return n == 0 ? -1 : n;
242 catch (ObjectDisposedException e)
244 throw new global::java.io.IOException(e.Message);
246 catch (NotSupportedException e)
248 throw new global::java.io.IOException(e.Message);
250 catch (IOException e)
252 throw new global::java.io.IOException(e.Message);
257 __callerID ??= global::ikvm.@
internal.CallerID.create(typeof(global::java.io.RandomAccessFile).TypeHandle);
258 __jniPtr__readBytes ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__readBytes>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/RandomAccessFile", nameof(
readBytes),
"([BII)I"));
260 var jniEnv = jniFrm.Enter(__callerID);
263 return __jniPtr__readBytes(jniEnv, jniFrm.MakeLocalRef(
self), jniFrm.MakeLocalRef(bytes), off, len);
267 System.Console.WriteLine(
"*** exception in native code ***");
268 System.Console.WriteLine(ex);
284 public static void write0(
object self,
int @
byte)
287 throw new NotImplementedException();
289 var fd = RandomAccessFileAccessor.GetFd(
self);
291 throw new global::java.io.IOException(
"Invalid file handle.");
293 if (FileDescriptorAccessor.GetStream(fd) is Stream stream)
295 if (stream.CanWrite ==
false)
296 throw new global::java.io.IOException(
"Write failed.");
300 stream.WriteByte((
byte)@
byte);
302 catch (ObjectDisposedException e)
304 throw new global::java.io.IOException(e.Message);
306 catch (NotSupportedException e)
308 throw new global::java.io.IOException(e.Message);
310 catch (IOException e)
312 throw new global::java.io.IOException(e.Message);
317 __callerID ??= global::ikvm.@
internal.CallerID.create(typeof(global::java.io.RandomAccessFile).TypeHandle);
318 __jniPtr__write0 ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__write0>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/RandomAccessFile", nameof(
write0),
"(I)V"));
320 var jniEnv = jniFrm.Enter(__callerID);
323 __jniPtr__write0(jniEnv, jniFrm.MakeLocalRef(
self), @
byte);
327 System.Console.WriteLine(
"*** exception in native code ***");
328 System.Console.WriteLine(ex);
346 public static void writeBytes(
object self,
byte[] bytes,
int off,
int len)
349 throw new NotImplementedException();
351 var fd = RandomAccessFileAccessor.GetFd(
self);
353 throw new global::java.io.IOException(
"Invalid file handle.");
355 if (FileDescriptorAccessor.GetStream(fd) is Stream stream)
357 if ((off < 0) || (off > bytes.Length) || (len < 0) || (len > (bytes.Length - off)))
358 throw new global::java.lang.IndexOutOfBoundsException();
359 if (stream.CanWrite ==
false)
360 throw new global::java.io.IOException(
"Write failed.");
364 stream.Write(bytes, off, len);
366 catch (ObjectDisposedException e)
368 throw new global::java.io.IOException(e.Message);
370 catch (NotSupportedException e)
372 throw new global::java.io.IOException(e.Message);
374 catch (IOException e)
376 throw new global::java.io.IOException(e.Message);
381 __callerID ??= global::ikvm.@
internal.CallerID.create(typeof(global::java.io.RandomAccessFile).TypeHandle);
382 __jniPtr__writeBytes ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__writeBytes>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/RandomAccessFile", nameof(
writeBytes),
"([BII)V"));
384 var jniEnv = jniFrm.Enter(__callerID);
387 __jniPtr__writeBytes(jniEnv, jniFrm.MakeLocalRef(
self), jniFrm.MakeLocalRef(bytes), off, len);
391 System.Console.WriteLine(
"*** exception in native code ***");
392 System.Console.WriteLine(ex);
411 throw new NotImplementedException();
413 var fd = RandomAccessFileAccessor.GetFd(
self);
415 throw new global::java.io.IOException(
"Invalid file handle.");
417 if (FileDescriptorAccessor.GetStream(fd) is Stream stream)
421 return stream.Position;
423 catch (ObjectDisposedException e)
425 throw new global::java.io.IOException(e.Message);
427 catch (NotSupportedException e)
429 throw new global::java.io.IOException(e.Message);
431 catch (IOException e)
433 throw new global::java.io.IOException(e.Message);
438 __callerID ??= global::ikvm.@
internal.CallerID.create(typeof(global::java.io.RandomAccessFile).TypeHandle);
439 __jniPtr__getFilePointer ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__getFilePointer>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/RandomAccessFile", nameof(
getFilePointer),
"()J"));
441 var jniEnv = jniFrm.Enter(__callerID);
444 return __jniPtr__getFilePointer(jniEnv, jniFrm.MakeLocalRef(
self));
448 System.Console.WriteLine(
"*** exception in native code ***");
449 System.Console.WriteLine(ex);
465 public static void seek0(
object self,
long pos)
468 throw new NotImplementedException();
470 var fd = RandomAccessFileAccessor.GetFd(
self);
472 throw new global::java.io.IOException(
"Invalid file handle.");
474 if (FileDescriptorAccessor.GetStream(fd) is Stream stream)
478 stream.Position = pos;
480 catch (ObjectDisposedException e)
482 throw new global::java.io.IOException(e.Message);
484 catch (NotSupportedException e)
486 throw new global::java.io.IOException(e.Message);
488 catch (ArgumentOutOfRangeException)
490 throw new global::java.io.IOException(
"Negative seek offset.");
492 catch (IOException e)
494 throw new global::java.io.IOException(e.Message);
499 __callerID ??= global::ikvm.@
internal.CallerID.create(typeof(global::java.io.RandomAccessFile).TypeHandle);
500 __jniPtr__seek0 ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__seek0>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/RandomAccessFile", nameof(
seek0),
"(J)V"));
502 var jniEnv = jniFrm.Enter(__callerID);
505 __jniPtr__seek0(jniEnv, jniFrm.MakeLocalRef(
self), pos);
509 System.Console.WriteLine(
"*** exception in native code ***");
510 System.Console.WriteLine(ex);
529 throw new NotImplementedException();
531 var fd = RandomAccessFileAccessor.GetFd(
self);
533 throw new global::java.io.IOException(
"Invalid file handle.");
535 if (FileDescriptorAccessor.GetStream(fd) is Stream stream)
539 return stream.Length;
541 catch (ObjectDisposedException e)
543 throw new global::java.io.IOException(e.Message);
545 catch (NotSupportedException e)
547 throw new global::java.io.IOException(e.Message);
549 catch (IOException e)
551 throw new global::java.io.IOException(e.Message);
556 __callerID ??= global::ikvm.@
internal.CallerID.create(typeof(global::java.io.RandomAccessFile).TypeHandle);
557 __jniPtr__length ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__length>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/RandomAccessFile", nameof(
length),
"()J"));
559 var jniEnv = jniFrm.Enter(__callerID);
562 return __jniPtr__length(jniEnv, jniFrm.MakeLocalRef(
self));
566 System.Console.WriteLine(
"*** exception in native code ***");
567 System.Console.WriteLine(ex);
583 public static void setLength(
object self,
long newLength)
586 throw new NotImplementedException();
588 var fd = RandomAccessFileAccessor.GetFd(
self);
590 throw new global::java.io.IOException(
"Invalid file handle.");
592 if (FileDescriptorAccessor.GetStream(fd) is Stream stream)
594 var p = stream.Position;
598 stream.SetLength(newLength);
599 stream.Position = Math.Min(p, stream.Length);
601 catch (ObjectDisposedException e)
604 throw new global::java.io.IOException(e.Message);
606 catch (NotSupportedException e)
609 throw new global::java.io.IOException(e.Message);
611 catch (UnauthorizedAccessException e)
614 throw new global::java.io.IOException(e.Message);
616 catch (IOException e)
619 throw new global::java.io.IOException(e.Message);
624 __callerID ??= global::ikvm.@
internal.CallerID.create(typeof(global::java.io.RandomAccessFile).TypeHandle);
625 __jniPtr__setLength ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__setLength>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/RandomAccessFile", nameof(
setLength),
"(J)V"));
627 var jniEnv = jniFrm.Enter(__callerID);
630 __jniPtr__setLength(jniEnv, jniFrm.MakeLocalRef(
self), newLength);
634 System.Console.WriteLine(
"*** exception in native code ***");
635 System.Console.WriteLine(ex);
653 throw new NotImplementedException();
655 var fd = RandomAccessFileAccessor.GetFd(
self);
659 if (FileDescriptorAccessor.GetStream(fd) is Stream stream)
664 FileDescriptorAccessor.SetPtr(fd, -1);
673 __callerID ??= global::ikvm.@
internal.CallerID.create(typeof(global::java.io.RandomAccessFile).TypeHandle);
674 __jniPtr__close0 ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__close0>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/RandomAccessFile", nameof(
close0),
"()V"));
676 var jniEnv = jniFrm.Enter(__callerID);
679 __jniPtr__close0(jniEnv, jniFrm.MakeLocalRef(
self));
683 System.Console.WriteLine(
"*** exception in native code ***");
684 System.Console.WriteLine(ex);