JavaVM.st
changeset 442 26a54e4e8485
parent 441 3a589161eadc
child 444 5ec8daa3a023
--- a/JavaVM.st	Thu Nov 12 19:12:16 1998 +0000
+++ b/JavaVM.st	Thu Nov 12 20:32:20 1998 +0000
@@ -13,7 +13,8 @@
 		OpenFileTable CachedNativeMethodTable ExceptionDebug
 		JavaConsoleStream StandardThreadGroup EnteredMonitorsPerProcess
 		JavaClasses JavaMethods DUMMY_LONG_HIGHWORD DUMMY_DOUBLE_HIGHWORD
-		NoAudio FirstWindowCreationSemaphore ScreenUpdaterProcess'
+		NoAudio FirstWindowCreationSemaphore ScreenUpdaterProcess
+		PermittedDirectories'
 	poolDictionaries:''
 	category:'Java-Support'
 !
@@ -459,7 +460,7 @@
    ST/X+J                   
    586 233Mhz
    JIT             128724         116810         20259    39733   83160  27613  52093  33166  43996  545554
-
+                   126269         115670         19521    10105    8282
 ------------------------------------------------------------------------------------------------------------
 
    Sun JDK         274625         244461         52676    50653   65183  26668  78133  28572  61608  882583
@@ -1941,7 +1942,7 @@
 !
 
 commonOpen:nativeContext forAppend:forAppend
-    |fs fd fn name dir stream fileNo|
+    |fs fd fn name dir stream fileNo answer readonly|
 
     fs := nativeContext receiver.
     fd := fs instVarNamed:'fd'.
@@ -1960,28 +1961,41 @@
 
     fn := name asFilename.
     dir := fn directory pathName.
+
     (PermittedDirectories notNil
     and:[PermittedDirectories includes:dir]) ifFalse:[
         FileOpenConfirmation ifTrue:[
-            (self confirm:('JAVA Security check\\Opening ''' , name , ''' for writing.\Grant permission ?') withCRs)
-            ifFalse:[
+            answer := Dialog 
+                    confirmWithCancel:('JAVA Security check\\Opening ''' , name , ''' for read/write.\Grant permission ?') withCRs
+                               labels:#('no' 'grant' 'readonly')
+                               values:#(false true #readonly)
+                              default:3.
+            answer == false ifTrue:[
                 self throwIOExceptionWithMessage:('no permission to open ' , name , ' for writing').
                 ^ self
             ].
-            (self confirm:('JAVA Security check\\Always permit writes in this directory (''' , dir , ''') ?') withCRs)
-            ifTrue:[
-                PermittedDirectories isNil ifTrue:[
-                    PermittedDirectories := Set new
-                ].
-                PermittedDirectories add:dir.
+            readonly := (answer == #readonly).
+
+            readonly ifFalse:[
+                (self confirm:('JAVA Security check\\Always permit writes in this directory (''' , dir , ''') ?') withCRs)
+                ifTrue:[
+                    PermittedDirectories isNil ifTrue:[
+                        PermittedDirectories := Set new
+                    ].
+                    PermittedDirectories add:dir.
+                ]
             ]
         ]
     ].
 
-    forAppend ifTrue:[
-        stream := fn appendingWriteStream.
+    readonly ifTrue:[
+        stream := fn readStream.
     ] ifFalse:[
-        stream := fn writeStream.
+        forAppend ifTrue:[
+            stream := fn appendingWriteStream.
+        ] ifFalse:[
+            stream := fn writeStream.
+        ]
     ].
     stream isNil ifTrue:[
         self throwIOExceptionWithMessage:('cannot open ' , name , ' for writing').
@@ -1996,7 +2010,7 @@
     fd instVarNamed:'fd' put:fileNo.
 
     "Created: / 7.4.1998 / 19:14:09 / cg"
-    "Modified: / 7.4.1998 / 19:19:21 / cg"
+    "Modified: / 12.11.1998 / 21:31:24 / cg"
 !
 
 fileStreamForReading:name
@@ -2687,7 +2701,9 @@
 !
 
 _RandomAccessFile_open:nativeContext
-    |fs fd name dir stream fileNo|
+    |fs fd name dir stream fileNo answer readonly|
+
+    readonly := false.
 
     fs := nativeContext receiver.
     fd := fs instVarNamed:'fd'.
@@ -2706,25 +2722,38 @@
     ].
 
     dir := name asFilename directory pathName.
+
     (PermittedDirectories notNil
     and:[PermittedDirectories includes:dir]) ifFalse:[
         FileOpenConfirmation ifTrue:[
-            (self confirm:('JAVA Security check\\Opening ''' , name , ''' for read/write.\Grant permission ?') withCRs)
-            ifFalse:[
+            answer := Dialog 
+                    confirmWithCancel:('JAVA Security check\\Opening ''' , name , ''' for read/write.\Grant permission ?') withCRs
+                               labels:#('no' 'grant' 'readonly')
+                               values:#(false true #readonly)
+                              default:3.
+            answer == false ifTrue:[
                 self throwIOExceptionWithMessage:('no permission to open ' , name , ' for writing').
                 ^ self
             ].
-            (self confirm:('JAVA Security check\\Always permit writes in this directory (''' , dir , ''') ?') withCRs)
-            ifTrue:[
-                PermittedDirectories isNil ifTrue:[
-                    PermittedDirectories := Set new
-                ].
-                PermittedDirectories add:dir.
+            readonly := (answer == #readonly).
+
+            readonly ifFalse:[
+                (self confirm:('JAVA Security check\\Always permit writes in this directory (''' , dir , ''') ?') withCRs)
+                ifTrue:[
+                    PermittedDirectories isNil ifTrue:[
+                        PermittedDirectories := Set new
+                    ].
+                    PermittedDirectories add:dir.
+                ]
             ]
         ]
     ].
 
-    stream := name asFilename readWriteStream.
+    readonly ifTrue:[
+        stream := name asFilename readStream.
+    ] ifFalse:[
+        stream := name asFilename readWriteStream.
+    ].
     stream isNil ifTrue:[
         self throwIOExceptionWithMessage:('cannot open ' , name , ' for writing').
     ].
@@ -2738,7 +2767,7 @@
     fd instVarNamed:'fd' put:fileNo.
 
     "Created: / 4.2.1998 / 00:14:48 / cg"
-    "Modified: / 20.10.1998 / 21:00:51 / cg"
+    "Modified: / 12.11.1998 / 21:29:46 / cg"
 !
 
 _RandomAccessFile_readBytes:nativeContext
@@ -9286,6 +9315,6 @@
 !JavaVM class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaVM.st,v 1.63 1998/11/12 19:12:16 cg Exp $'
+    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaVM.st,v 1.64 1998/11/12 20:32:20 cg Exp $'
 ! !
 JavaVM initialize!