1 /* Structure information for class: java/io/UnixFileSystem */
4 * Class: java/io/UnixFileSystem
6 * Signature: (Ljava/lang/String;)Ljava/lang/String;
8 JNIEXPORT struct java_lang_String* JNICALL Java_java_io_UnixFileSystem_canonicalize (JNIEnv *env , struct java_io_UnixFileSystem* this , struct java_lang_String* par1)
13 JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_isAbsolute (JNIEnv *env , struct java_io_UnixFileSystem* this , struct java_io_File* file)
15 java_lang_String* s = file->path;
16 java_chararray *a = s->value;
18 /* absolute filenames start with '/' */
19 if (a->data[s->offset]=='/') return 1;
25 * Class: java/io/UnixFileSystem
26 * Method: getBooleanAttributes0
27 * Signature: (Ljava/io/File;)I
29 JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_getBooleanAttributes0 (JNIEnv *env , struct java_io_UnixFileSystem* this , struct java_io_File* file)
36 path = javastring_tochar( (java_objectheader*) (file->path));
37 err = stat (path, &buffer);
41 attrib = 0x01; /* file exists */
43 if (S_ISREG(buffer.st_mode)) attrib |= 0x02;
44 if (S_ISDIR(buffer.st_mode)) attrib |= 0x04;
48 /* printf("getBooleanAttributes called for file: %s (%d)\n",path,attrib); */
54 * Class: java/io/UnixFileSystem
56 * Signature: (Ljava/io/File;Z)Z
58 JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_checkAccess (JNIEnv *env , struct java_io_UnixFileSystem* this , struct java_io_File* file, s4 write)
64 /* get file-attributes */
65 path = javastring_tochar( (java_objectheader*) (file->path));
66 err = stat (path, &buffer);
70 /* check access rights */
71 if (((write) && (buffer.st_mode & S_IWUSR)) ||
72 ((!write) && (buffer.st_mode & S_IRUSR)) )
76 /* no access rights */
81 * Class: java/io/UnixFileSystem
82 * Method: getLastModifiedTime
83 * Signature: (Ljava/io/File;)J
85 JNIEXPORT s8 JNICALL Java_java_io_UnixFileSystem_getLastModifiedTime (JNIEnv *env , struct java_io_UnixFileSystem* this , struct java_io_File* file)
92 log_text("Warning: invalid call of native function getLastModifiedTime");
96 /* get file-attributes */
97 err = stat (javastring_tochar( (java_objectheader*) (file->path)), &buffer);
98 if (err!=0) return builtin_i2l(0);
99 return builtin_lmul (builtin_i2l(buffer.st_mtime), builtin_i2l(1000) );
103 * Class: java/io/UnixFileSystem
105 * Signature: (Ljava/io/File;)J
107 JNIEXPORT s8 JNICALL Java_java_io_UnixFileSystem_getLength (JNIEnv *env , struct java_io_UnixFileSystem* this , struct java_io_File* file)
113 log_text("Warning: invalid call of native function getLength");
117 /* get file-attributes */
118 err = stat (javastring_tochar( (java_objectheader*) (file->path)), &buffer);
119 if (err!=0) return builtin_i2l(0);
120 return builtin_i2l(buffer.st_size);
124 * Class: java/io/UnixFileSystem
125 * Method: createFileExclusively
126 * Signature: (Ljava/lang/String;)Z
128 JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_createFileExclusively (JNIEnv *env , struct java_io_UnixFileSystem* this , struct java_lang_String* name)
131 char *fname = javastring_tochar ((java_objectheader*)name);
133 if (!fname) return 0;
135 /* create new file */
136 fd = creat (fname, 0666);
139 threadedFileDescriptor(fd);
146 * Class: java/io/UnixFileSystem
148 * Signature: (Ljava/io/File;)Z
150 JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_delete (JNIEnv *env , struct java_io_UnixFileSystem* this , struct java_io_File* file)
153 /* delete the file */
154 err = remove (javastring_tochar ( (java_objectheader*) (file->path) ) );
155 if (err==0) return 1;
162 * Class: java/io/UnixFileSystem
163 * Method: deleteOnExit
164 * Signature: (Ljava/io/File;)Z
166 JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_deleteOnExit (JNIEnv *env , struct java_io_UnixFileSystem* this , struct java_io_File* file)
168 log_text("Java_java_io_UnixFileSystem_deleteOnExit called");
174 * Class: java/io/UnixFileSystem
176 * Signature: (Ljava/io/File;)[Ljava/lang/String;
178 JNIEXPORT java_objectarray* JNICALL Java_java_io_UnixFileSystem_list (JNIEnv *env , struct java_io_UnixFileSystem* this , struct java_io_File* file)
185 struct java_lang_String *n;
188 name = javastring_tochar ( (java_objectheader*) (file->path) );
193 while (readdir(d) != NULL) len++;
196 a = builtin_anewarray (len, class_java_lang_String);
202 for (i=0; i<len; i++) {
203 if ( (ent = readdir(d)) != NULL) {
204 namlen = strlen(ent->d_name);
205 memcpy (entbuffer, ent->d_name, namlen);
206 entbuffer[namlen] = '\0';
208 n = (struct java_lang_String*)
209 javastring_new_char (entbuffer);
211 a -> data[i] = (java_objectheader*) n;
221 * Class: java/io/UnixFileSystem
222 * Method: createDirectory
223 * Signature: (Ljava/io/File;)Z
225 JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_createDirectory (JNIEnv *env , struct java_io_UnixFileSystem* this , struct java_io_File* file)
232 name = javastring_tochar ( (java_objectheader*) (file->path) );
233 err = mkdir (name, 0777);
235 if (err==0) return 1;
242 * Class: java/io/UnixFileSystem
244 * Signature: (Ljava/io/File;Ljava/io/File;)Z
246 JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_rename (JNIEnv *env , struct java_io_UnixFileSystem* this , struct java_io_File* file, struct java_io_File* new)
249 #define MAXJAVAPATHLEN 200
251 char newname[MAXJAVAPATHLEN];
256 n = javastring_tochar ( (java_objectheader*) (new->path) );
257 if (strlen(n)>=MAXJAVAPATHLEN) return 0;
259 n = javastring_tochar ( (java_objectheader*) (file->path) );
260 err = rename (n, newname);
261 if (err==0) return 1;
268 * Class: java/io/UnixFileSystem
269 * Method: setLastModifiedTime
270 * Signature: (Ljava/io/File;J)Z
272 JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_setLastModifiedTime (JNIEnv *env , struct java_io_UnixFileSystem* this , struct java_io_File* file, s8 time)
275 log_text("Java_java_io_FileSystemImpl_setLastModifiedTime called");
277 ub.actime = time/1000;
278 ub.modtime = time/1000;
279 if (!utime(javastring_tochar( (java_objectheader*) (file->path)), &ub))
286 * Class: java/io/UnixFileSystem
287 * Method: setReadOnly
288 * Signature: (Ljava/io/File;)Z
290 JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_setReadOnly (JNIEnv *env , struct java_io_UnixFileSystem* this , struct java_io_File* file)
297 log_text("Java_java_io_FileSystemImpl_setReadOnly called");
299 path = javastring_tochar( (java_objectheader*) (file->path));
300 /* get file-attributes */
301 err = stat (path, &buffer);
305 buffer.st_mode &= ~( 0x00002 | /* write by others */
306 0x00200 ); /* write by owner */
308 /* set file-attributes */
309 chmod(path,buffer.st_mode);
318 * Class: java/io/UnixFileSystem
322 JNIEXPORT void JNICALL Java_java_io_UnixFileSystem_initIDs (JNIEnv *env )