Changeset 539
- Timestamp:
- 08/27/08 13:24:19 (4 months ago)
- Files:
-
- Mika/trunk/core-vm/java/java/io/File.java (modified) (1 diff)
- Mika/trunk/core-vm/src/native/java/io/File.c (modified) (4 diffs)
- Mika/trunk/core-vm/src/vm/core-classes.in (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Mika/trunk/core-vm/java/java/io/File.java
r418 r539 433 433 } 434 434 435 public boolean setReadOnly() throws SecurityException { 436 return false; 437 } 435 public native boolean setReadOnly() throws SecurityException; 438 436 439 437 public native long length() throws SecurityException; Mika/trunk/core-vm/src/native/java/io/File.c
r456 r539 2 2 * Parts copyright (c) 2001, 2002, 2003 by Punch Telematix. * 3 3 * All rights reserved. * 4 * Parts copyright (c) 2004 by Chris Gray, /k/ Embedded Java Solutions.*5 * All rights reserved.*4 * Parts copyright (c) 2004, 2008 by Chris Gray, /k/ Embedded Java * 5 * Solutions. All rights reserved. * 6 6 * * 7 7 * Redistribution and use in source and binary forms, with or without * … … 139 139 } 140 140 141 w_boolean File_setReadOnly (JNIEnv *env, w_instance thisFile) { 142 char *pathname; 143 struct vfs_STAT statbuf; 144 jboolean result; 145 const int WRITABLE = VFS_S_IWUSR | VFS_S_IWGRP | VFS_S_IWOTH; 146 147 pathname = getFileName(thisFile); 148 result = vfs_stat(pathname, &statbuf) == 0 149 && vfs_chmod(pathname, statbuf.st_mode & ~WRITABLE) == 0; 150 151 freeFileName(pathname); 152 153 return result; 154 } 155 141 156 w_boolean Java_File_canRead (JNIEnv *env, w_instance thisFile) { 142 157 struct vfs_STAT statbuf; … … 183 198 return 0; 184 199 } 200 } 201 202 w_boolean File_delete (JNIEnv *env, w_instance thisFile) { 203 char *pathname; 204 struct vfs_STAT statbuf; 205 w_boolean result; 206 207 pathname = getFileName(thisFile); 208 209 result == (vfs_stat(pathname, &statbuf) == 0); 210 if (result) { 211 if(VFS_S_ISDIR(statbuf.st_mode)) { 212 result = (vfs_rmdir(pathname) == 0); 213 woempa(9, "%s is a directory, result = %d\n", pathname, result); 214 wprintf("%s is a directory, result = %d\n", pathname, result); 215 } else { 216 result = (vfs_unlink(pathname) == 0); 217 woempa(9, "%s is a file, result = %d\n", pathname, result); 218 wprintf("%s is a file, result = %d\n", pathname, result); 219 } 220 } 221 222 freeFileName(pathname); 223 224 return result; 225 185 226 } 186 227 … … 293 334 } 294 335 295 /*296 * Class: File297 * Method: delete298 * Signature: ()Z299 */300 JNIEXPORT jboolean JNICALL Java_File_delete301 (JNIEnv *env, jobject thisObj) {302 303 jboolean isCopy;304 const char *pathname;305 jstring path;306 struct vfs_STAT statbuf;307 jboolean result = JNI_FALSE;308 309 path = (jstring)(*env)->GetObjectField(env, thisObj, absname);310 pathname = (*env)->GetStringUTFChars(env, path, &isCopy);311 312 if(vfs_stat((w_ubyte *)pathname, &statbuf) != -1) {313 if(VFS_S_ISDIR(statbuf.st_mode)) {314 if(vfs_rmdir(pathname) == 0) result = JNI_TRUE;315 woempa(9, "%s is a directory, result = %d\n", pathname, result);316 } else {317 if(vfs_unlink(pathname) == 0) result = JNI_TRUE;318 woempa(9, "%s is a file, result = %d\n", pathname, result);319 }320 }321 322 if(isCopy == JNI_TRUE) (*env)->ReleaseStringUTFChars(env, path, pathname);323 324 return result;325 326 }327 328 336 #ifdef __cplusplus 329 337 } Mika/trunk/core-vm/src/vm/core-classes.in
r485 r539 750 750 mkdir ()Z Java_File_mkdir 751 751 rename (Ljava/lang/String;Ljava/lang/String;)Z Java_File_rename 752 delete ()Z Java_File_delete 752 setReadOnly ()Z File_setReadOnly 753 delete ()Z File_delete 753 754 get_CWD ()Ljava/lang/String; Java_File_get_CWD 754 755 get_fsroot ()Ljava/lang/String; Java_File_get_fsroot … … 769 770 close ()V Java_RandomAccessFile_close 770 771 wonka/vm/ProcessInfo 771 wotsit I772 wotsit + 772 773 id I 773 774 destroyed Z
