public static java.io.FileDescriptor getFD(java.nio.channels.FileChannel fc) { throw new System.NotImplementedException(); }
public FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access) { ThrowHelper.ThrowIfNull(path); if ((int)access < 1 || (int)access > 3) { throw new System.ArgumentOutOfRangeException(); } switch (mode) { case System.IO.FileMode.CreateNew: CreateIfNotExist(); break; case System.IO.FileMode.Create: CreateOrTruncate(); break; case System.IO.FileMode.Open: OpenExisting(); break; case System.IO.FileMode.OpenOrCreate: OpenOrCreate(); break; case System.IO.FileMode.Truncate: TruncateExisting(); break; case System.IO.FileMode.Append: AppendOrCreate(); break; default: throw new System.ArgumentOutOfRangeException(); } void CreateIfNotExist() { // create a new file; throw IOException if exists if (access == System.IO.FileAccess.Read) { throw new System.ArgumentException(access.ToString()); } try { var stream = new java.io.RandomAccessFile(path, "r"); stream.close(); throw new System.IO.IOException("Exists: " + path); } catch (java.io.FileNotFoundException) { } JavaChannel = new java.io.RandomAccessFile(path, "rw").getChannel(); Flags = CAN_WRITE | CAN_SEEK; } void CreateOrTruncate() { // create a new file or truncate an existing file if (access == System.IO.FileAccess.Read) { throw new System.ArgumentException(access.ToString()); } var stream = new java.io.RandomAccessFile(path, "rw"); stream.setLength(0); JavaChannel = stream.getChannel(); Flags = CAN_WRITE | CAN_SEEK; } void OpenExisting() { // open existing file, throwing FileNotFoundException if cannot var stream = new java.io.RandomAccessFile(path, "r"); if (access != System.IO.FileAccess.Read) { // knowing the file exists, reopen for writing if necessary stream.close(); stream = new java.io.RandomAccessFile(path, "rw"); Flags = CAN_READ | CAN_WRITE | CAN_SEEK; } else { Flags = CAN_READ | CAN_SEEK; } JavaChannel = stream.getChannel(); } void OpenOrCreate() { // open existing file, or create a new file JavaChannel = new java.io.RandomAccessFile(path, "rw").getChannel(); if (access != System.IO.FileAccess.Read) { Flags = CAN_READ | CAN_WRITE | CAN_SEEK; } else { Flags = CAN_READ | CAN_SEEK; } } void TruncateExisting() { // truncate existing file, or throws FileNotFoundException if (access == System.IO.FileAccess.Read) { throw new System.ArgumentException(access.ToString()); } var stream = new java.io.RandomAccessFile(path, "r"); stream.close(); stream = new java.io.RandomAccessFile(path, "rw"); stream.setLength(0); JavaChannel = stream.getChannel(); Flags = CAN_WRITE | CAN_SEEK; } void AppendOrCreate() { var stream = new java.io.RandomAccessFile(path, "rw"); stream.seek(stream.length()); JavaChannel = stream.getChannel(); Flags = CAN_WRITE | CAN_SEEK; } }
// // constructors // public FileStream(java.nio.channels.FileChannel channel, int flags) { JavaChannel = channel; Flags = flags; }
protected FileLock(java.nio.channels.FileChannel arg0, long arg1, long arg2, bool arg3) : base(global::MonoJavaBridge.JNIEnv.ThreadEnv) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; global::MonoJavaBridge.JniLocalHandle handle = @__env.NewObject(java.nio.channels.FileLock.staticClass, global::java.nio.channels.FileLock._FileLock14464, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg3)); Init(@__env, handle); }