18#if FIRST_PASS == false
20 static UnixFileSystemAccessor unixFileSystemAccessor;
22 static UnixFileSystemAccessor UnixFileSystemAccessor =>
JVM.
Internal.BaseAccessors.Get(
ref unixFileSystemAccessor);
25 delegate IntPtr __jniDelegate__canonicalize0(IntPtr jniEnv, IntPtr
self, IntPtr pathname);
26 static __jniDelegate__canonicalize0 __jniPtr__canonicalize0;
27 delegate
byte __jniDelegate__delete0(IntPtr jniEnv, IntPtr
self, IntPtr file);
28 static __jniDelegate__delete0 __jniPtr__delete0;
29 delegate
byte __jniDelegate__rename0(IntPtr jniEnv, IntPtr
self, IntPtr f1, IntPtr f2);
30 static __jniDelegate__rename0 __jniPtr__rename0;
31 delegate
int __jniDelegate__getBooleanAttributes0(IntPtr jniEnv, IntPtr
self, IntPtr file);
32 static __jniDelegate__getBooleanAttributes0 __jniPtr__getBooleanAttributes0;
33 delegate
byte __jniDelegate__checkAccess(IntPtr jniEnv, IntPtr
self, IntPtr file,
int a);
34 static __jniDelegate__checkAccess __jniPtr__checkAccess;
35 delegate
long __jniDelegate__getLastModifiedTime(IntPtr jniEnv, IntPtr
self, IntPtr file);
36 static __jniDelegate__getLastModifiedTime __jniPtr__getLastModifiedTime;
37 delegate
long __jniDelegate__getLength(IntPtr jniEnv, IntPtr
self, IntPtr file);
38 static __jniDelegate__getLength __jniPtr__getLength;
39 delegate
byte __jniDelegate__setPermission(IntPtr jniEnv, IntPtr
self, IntPtr file,
int access,
byte enable,
byte owneronly);
40 static __jniDelegate__setPermission __jniPtr__setPermission;
41 delegate
byte __jniDelegate__createFileExclusively(IntPtr jniEnv, IntPtr
self, IntPtr pathname);
42 static __jniDelegate__createFileExclusively __jniPtr__createFileExclusively;
43 delegate IntPtr __jniDelegate__list(IntPtr jniEnv, IntPtr
self, IntPtr file);
44 static __jniDelegate__list __jniPtr__list;
45 delegate
byte __jniDelegate__createDirectory(IntPtr jniEnv, IntPtr
self, IntPtr file);
46 static __jniDelegate__createDirectory __jniPtr__createDirectory;
47 delegate
byte __jniDelegate__setLastModifiedTime(IntPtr jniEnv, IntPtr
self, IntPtr file,
long time);
48 static __jniDelegate__setLastModifiedTime __jniPtr__setLastModifiedTime;
49 delegate
byte __jniDelegate__setReadOnly(IntPtr jniEnv, IntPtr
self, IntPtr f);
50 static __jniDelegate__setReadOnly __jniPtr__setReadOnly;
59 static string CanonicalizePath(
string path)
62 throw new NotImplementedException();
67 var parent = Path.GetDirectoryName(path);
71 return path.Length > 1 && path[1] ==
':' ? $
"{char.ToUpper(path[0])}:{Path.DirectorySeparatorChar}" : path;
73 parent = CanonicalizePath(parent);
76 var name = Path.GetFileName(path);
77 if (name ==
"" || name ==
".")
80 return Path.GetDirectoryName(parent);
84 if (
JVM.Vfs.IsPath(path) ==
false)
87 var all = Directory.EnumerateFileSystemEntries(parent, name);
88 if (all.FirstOrDefault() is
string one)
89 name = Path.GetFileName(one);
92 catch (UnauthorizedAccessException)
101 return Path.Combine(parent, name);
103 catch (UnauthorizedAccessException)
111 catch (SecurityException)
115 catch (NotSupportedException)
134 throw new NotImplementedException();
136 if (
JVM.Vfs.IsPath(pathname))
138 return CanonicalizePath(Path.IsPathRooted(pathname) ==
false ? Path.GetFullPath(pathname) : pathname);
142 __callerID ??= global::ikvm.@
internal.CallerID.create(UnixFileSystemAccessor.Type.TypeHandle);
143 __jniPtr__canonicalize0 ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__canonicalize0>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/UnixFileSystem", nameof(
canonicalize0),
"(Ljava/lang/String;)Ljava/lang/String;"));
145 var jniEnv = jniFrm.Enter(__callerID);
148 return (
string)jniFrm.UnwrapLocalRef(__jniPtr__canonicalize0(jniEnv, jniFrm.MakeLocalRef(
self), jniFrm.MakeLocalRef(pathname)));
152 System.Console.WriteLine(
"*** exception in native code ***");
153 System.Console.WriteLine(ex);
173 throw new NotImplementedException();
175 if (
JVM.Vfs.IsPath(((global::java.io.File)file).getPath()))
177 return JVM.Vfs.GetBooleanAttributes(((global::java.io.File)file).getPath());
181 __callerID ??= global::ikvm.@
internal.CallerID.create(UnixFileSystemAccessor.Type.TypeHandle);
182 __jniPtr__getBooleanAttributes0 ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__getBooleanAttributes0>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/UnixFileSystem", nameof(
getBooleanAttributes0),
"(Ljava/io/File;)I"));
184 var jniEnv = jniFrm.Enter(__callerID);
187 return __jniPtr__getBooleanAttributes0(jniEnv, jniFrm.MakeLocalRef(
self), jniFrm.MakeLocalRef(file));
191 System.Console.WriteLine(
"*** exception in native code ***");
192 System.Console.WriteLine(ex);
213 throw new NotImplementedException();
215 if (
JVM.Vfs.IsPath(((global::java.io.File)file).getPath()))
217 const int ACCESS_READ = 0x04;
218 return JVM.Vfs.GetEntry(((global::java.io.File)file).getPath())
switch
220 VfsFile f => a == ACCESS_READ && f.CanOpen(FileMode.Open, FileAccess.Read),
221 VfsDirectory =>
true,
227 __callerID ??= global::ikvm.@
internal.CallerID.create(UnixFileSystemAccessor.Type.TypeHandle);
228 __jniPtr__checkAccess ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__checkAccess>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/UnixFileSystem", nameof(
checkAccess),
"(Ljava/io/File;I)Z"));
230 var jniEnv = jniFrm.Enter(__callerID);
233 return __jniPtr__checkAccess(jniEnv, jniFrm.MakeLocalRef(
self), jniFrm.MakeLocalRef(file), a) != 0;
237 System.Console.WriteLine(
"*** exception in native code ***");
238 System.Console.WriteLine(ex);
258 public static bool setPermission(
object self,
object file,
int access,
bool enable,
bool owneronly)
261 throw new NotImplementedException();
263 if (
JVM.Vfs.IsPath(((global::java.io.File)file).getPath()))
269 __callerID ??= global::ikvm.@
internal.CallerID.create(UnixFileSystemAccessor.Type.TypeHandle);
270 __jniPtr__setPermission ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__setPermission>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/UnixFileSystem", nameof(
setPermission),
"(Ljava/io/File;IZZ)Z"));
272 var jniEnv = jniFrm.Enter(__callerID);
275 return __jniPtr__setPermission(jniEnv, jniFrm.MakeLocalRef(
self), jniFrm.MakeLocalRef(file), access, enable ? (
byte)1 : (
byte)0, owneronly ? (
byte)1 : (
byte)0) != 0;
279 System.Console.WriteLine(
"*** exception in native code ***");
280 System.Console.WriteLine(ex);
300 throw new NotImplementedException();
302 if (
JVM.Vfs.IsPath(((global::java.io.File)file).getPath()))
308 __callerID ??= global::ikvm.@
internal.CallerID.create(UnixFileSystemAccessor.Type.TypeHandle);
309 __jniPtr__getLastModifiedTime ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__getLastModifiedTime>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/UnixFileSystem", nameof(
getLastModifiedTime),
"(Ljava/io/File;)J"));
311 var jniEnv = jniFrm.Enter(__callerID);
314 return __jniPtr__getLastModifiedTime(jniEnv, jniFrm.MakeLocalRef(
self), jniFrm.MakeLocalRef(file));
318 System.Console.WriteLine(
"*** exception in native code ***");
319 System.Console.WriteLine(ex);
339 throw new NotImplementedException();
341 if (
JVM.Vfs.IsPath(((global::java.io.File)file).getPath()))
343 return JVM.Vfs.GetEntry(((global::java.io.File)file).getPath()) is VfsFile f ? f.Size : 0;
347 __callerID ??= global::ikvm.@
internal.CallerID.create(UnixFileSystemAccessor.Type.TypeHandle);
348 __jniPtr__getLength ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__getLength>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/UnixFileSystem", nameof(
getLength),
"(Ljava/io/File;)J"));
350 var jniEnv = jniFrm.Enter(__callerID);
353 return __jniPtr__getLength(jniEnv, jniFrm.MakeLocalRef(
self), jniFrm.MakeLocalRef(file));
357 System.Console.WriteLine(
"*** exception in native code ***");
358 System.Console.WriteLine(ex);
378 throw new NotImplementedException();
380 if (
JVM.Vfs.IsPath(pathname))
386 __callerID ??= global::ikvm.@
internal.CallerID.create(UnixFileSystemAccessor.Type.TypeHandle);
387 __jniPtr__createFileExclusively ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__createFileExclusively>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/UnixFileSystem", nameof(
createFileExclusively),
"(Ljava/lang/String;)Z"));
389 var jniEnv = jniFrm.Enter(__callerID);
392 return __jniPtr__createFileExclusively(jniEnv, jniFrm.MakeLocalRef(
self), jniFrm.MakeLocalRef(pathname)) != 0;
396 System.Console.WriteLine(
"*** exception in native code ***");
397 System.Console.WriteLine(ex);
415 public static bool delete0(
object self,
object file)
418 throw new NotImplementedException();
420 if (
JVM.Vfs.IsPath(((global::java.io.File)file).getPath()))
422 throw new NotImplementedException();
426 __callerID ??= global::ikvm.@
internal.CallerID.create(UnixFileSystemAccessor.Type.TypeHandle);
427 __jniPtr__delete0 ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__delete0>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/UnixFileSystem", nameof(
delete0),
"(Ljava/io/File;)Z"));
429 var jniEnv = jniFrm.Enter(__callerID);
432 return __jniPtr__delete0(jniEnv, jniFrm.MakeLocalRef(
self), jniFrm.MakeLocalRef(file)) != 0;
436 System.Console.WriteLine(
"*** exception in native code ***");
437 System.Console.WriteLine(ex);
454 public static string[]
list(
object self,
object file)
457 throw new NotImplementedException();
459 if (
JVM.Vfs.IsPath(((global::java.io.File)file).getPath()))
461 if (
JVM.Vfs.GetEntry(((global::java.io.File)file).getPath()) is VfsDirectory vfs)
468 __callerID ??= global::ikvm.@
internal.CallerID.create(UnixFileSystemAccessor.Type.TypeHandle);
469 __jniPtr__list ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__list>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/UnixFileSystem", nameof(
list),
"(Ljava/io/File;)[Ljava/lang/String;"));
471 var jniEnv = jniFrm.Enter(__callerID);
474 return (
string[])jniFrm.UnwrapLocalRef(__jniPtr__list(jniEnv, jniFrm.MakeLocalRef(
self), jniFrm.MakeLocalRef(file)));
478 System.Console.WriteLine(
"*** exception in native code ***");
479 System.Console.WriteLine(ex);
499 throw new NotImplementedException();
501 if (
JVM.Vfs.IsPath(((global::java.io.File)file).getPath()))
507 __callerID ??= global::ikvm.@
internal.CallerID.create(UnixFileSystemAccessor.Type.TypeHandle);
508 __jniPtr__createDirectory ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__createDirectory>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/UnixFileSystem", nameof(
createDirectory),
"(Ljava/io/File;)Z"));
510 var jniEnv = jniFrm.Enter(__callerID);
513 return __jniPtr__createDirectory(jniEnv, jniFrm.MakeLocalRef(
self), jniFrm.MakeLocalRef(file)) != 0;
517 System.Console.WriteLine(
"*** exception in native code ***");
518 System.Console.WriteLine(ex);
537 public static bool rename0(
object self,
object from,
object to)
540 throw new NotImplementedException();
542 if (
JVM.Vfs.IsPath(((global::java.io.File)from).getPath()) ||
JVM.Vfs.IsPath(((global::java.io.File)to).getPath()))
548 __callerID ??= global::ikvm.@
internal.CallerID.create(UnixFileSystemAccessor.Type.TypeHandle);
549 __jniPtr__rename0 ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__rename0>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/UnixFileSystem", nameof(
rename0),
"(Ljava/io/File;Ljava/io/File;)Z"));
551 var jniEnv = jniFrm.Enter(__callerID);
554 return __jniPtr__rename0(jniEnv, jniFrm.MakeLocalRef(
self), jniFrm.MakeLocalRef(from), jniFrm.MakeLocalRef(to)) != 0;
558 System.Console.WriteLine(
"*** exception in native code ***");
559 System.Console.WriteLine(ex);
580 throw new NotImplementedException();
582 if (
JVM.Vfs.IsPath(((global::java.io.File)file).getPath()))
588 __callerID ??= global::ikvm.@
internal.CallerID.create(UnixFileSystemAccessor.Type.TypeHandle);
589 __jniPtr__setLastModifiedTime ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__setLastModifiedTime>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/UnixFileSystem", nameof(
setLastModifiedTime),
"(Ljava/io/File;J)Z"));
591 var jniEnv = jniFrm.Enter(__callerID);
594 return __jniPtr__setLastModifiedTime(jniEnv, jniFrm.MakeLocalRef(
self), jniFrm.MakeLocalRef(file), time) != 0;
598 System.Console.WriteLine(
"*** exception in native code ***");
599 System.Console.WriteLine(ex);
619 throw new NotImplementedException();
621 if (
JVM.Vfs.IsPath(((global::java.io.File)file).getPath()))
627 __callerID ??= global::ikvm.@
internal.CallerID.create(UnixFileSystemAccessor.Type.TypeHandle);
628 __jniPtr__setReadOnly ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__setReadOnly>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/UnixFileSystem", nameof(
setReadOnly),
"(Ljava/io/File;)Z"));
630 var jniEnv = jniFrm.Enter(__callerID);
633 return __jniPtr__setReadOnly(jniEnv, jniFrm.MakeLocalRef(
self), jniFrm.MakeLocalRef(file)) != 0;
637 System.Console.WriteLine(
"*** exception in native code ***");
638 System.Console.WriteLine(ex);