leaningtech / cheerpj-applet-runner

CheerpJ Applet Runner - Chrome Extension to Enable Java Applets
http://www.leaningtech.com/cheerpj
57 stars 3 forks source link

f.createNewFile() and f.delete() not working for '/files/' #28

Closed ghost closed 4 years ago

ghost commented 5 years ago

We were expecting that '/files/' accepts file and directory operations. But they seem to only work partially. It seems that new FileOutputStream() does created an entry, but createNewFile() doesn't.

Also directory listing list() works but delete() doesn't work. I was checking the operations on the instances of the Java class java.io.File.

unbenannt

ghost commented 5 years ago

We found another anomaly related to java.io.File. It seems that through reflection, the field File.separatorChar is returned as the value 0. Here is what is expected:

Ordinary Java (for example on the Windows platform):

unbenannt

In CheerpJ (\0\ is the Prolog string escape for value character code 0):

unbenannt2

This could be related to the issue here: https://github.com/leaningtech/cheerpj-appletrunner/issues/24

ghost commented 5 years ago

On the other hand we could find a fix for the missing f.createNewFile(). We just use new FileOutputStream(), and it will also create files for us in the file tree /files/. As a result we have Prolog settings for our Prolog interpreter immediately without further ado.

This is due to the system settings which are cleverly set by CheerpJ, and make everything work for us without further fixes. Settings can now be used in our Prolog interpreter applet. An example setting, that is stored in this file. is the command line history. Great job!

unbenannt

As we understand /files/ is mapped to IndexedDB somehow. This also means that the end-user can clear it at any time through some browser menu item. This is no loss, this can also happen for our settings on the other platforms, since they can be also manually removed there.

alexp-sssup commented 5 years ago

f.createNewFile() and the separatorChar issue should be fixed in CheerpJ Applet Runner 6.7. f.delete() is indeed not supported at this time.

alexp-sssup commented 4 years ago

File deletion is supported in CheerpJ Applet Runner 8.7