summaryrefslogtreecommitdiffstats
path: root/luni/src/main/native/java_io_File.c
blob: bf896814895d372b4e562d59b9f49dc0ed695ad4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#define MaxPath 1024

#include "JNIHelp.h"

#include <string.h>
#include <fcntl.h>
#include <time.h>
#include <utime.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
#include <assert.h>


/* these were copied from java.io.File */
enum {
    STAT_TYPE_EXISTS = 0x0001,
    STAT_TYPE_DIR = 0x0002,
    STAT_TYPE_FILE = 0x0004
};

static void convertToPlatform(char *path) {
    char *pathIndex;

    pathIndex = path;
    while(*pathIndex != '\0') {
        if(*pathIndex == '\\') {
            *pathIndex = '/';
        }
        pathIndex++;
    }
}

/*
 * private static native byte[][] rootsImpl()
 *
 * Returns the linux root in an array of byte arrays
 */
static jobject java_io_File_rootsImpl(JNIEnv* env, jclass clazz) {
    char rootStrings[3];
    jarray answer;

    rootStrings[0] = '/';
    rootStrings[1] = '\0';
    rootStrings[2] = '\0';

    jclass arrayClass = (*env)->FindClass(env, "[B");
    if (arrayClass == NULL)
        return NULL;

    answer = (*env)->NewObjectArray(env, 1, arrayClass, NULL);
    if (!answer)
        return NULL;

    jbyteArray rootname;

    rootname = (*env)->NewByteArray(env, 3);
    (*env)->SetByteArrayRegion(env, rootname, 0, 3, (jbyte *) rootStrings);
    (*env)->SetObjectArrayElement(env, answer, 0, rootname);
    //(*env)->DeleteLocalRef(env, rootname);

    return answer;
}

static jbyteArray java_io_File_getCanonImpl(JNIEnv * env, jobject recv, 
        jbyteArray path) {
    /* This needs work.  Currently it does no more or less than VAJ-20 ST 
     * implementationbut really should figure out '..', '.', and really 
     * resolve references.
     */
    jbyteArray answer;
    size_t answerlen;
    char *pathIndex;
    char pathCopy[MaxPath];
    jsize length = (jsize) (*env)->GetArrayLength(env, path);
    length = length < MaxPath - 1 ? length : MaxPath - 1;
    (*env)->GetByteArrayRegion(env, path, 0, length, (jbyte *)pathCopy);
    pathCopy[length] = '\0';

    convertToPlatform(pathCopy);

    answerlen = strlen(pathCopy);
    answer = (*env)->NewByteArray(env, answerlen);
    (*env)->SetByteArrayRegion(env, answer, 0, answerlen, (jbyte *) pathCopy);

    return answer;
}

/*
 * native private boolean deleteFileImpl()
 *
 * Returns "true" if the file exists and was successfully deleted.
 */
static jboolean java_io_File_deleteFileImpl(JNIEnv* env, jobject obj, 
        jbyteArray path) {

    int cc;

    if(path == NULL) {
        return JNI_FALSE;       /* exception thrown */
    }

    char pathCopy[MaxPath];
    jsize length = (jsize) (*env)->GetArrayLength(env, path);
    length = length < MaxPath - 1 ? length : MaxPath - 1;
    (*env)->GetByteArrayRegion(env, path, 0, length, (jbyte *)pathCopy);
    pathCopy[length] = '\0';
    convertToPlatform(pathCopy);
    
    cc = unlink(pathCopy);
    if(cc < 0) {
        int err = errno;

        /*
         * According to the man pages, Linux uses EISDIR and Mac OS X
         * uses EPERM to indicate a non-super-user attempt to unlink
         * a directory.  Mac OS does have EISDIR in the header file.
         *
         * We should get EACCES if the problem is directory permissions.
         */
        if(err == EISDIR || err == EPERM) {
            cc = rmdir(pathCopy);
            if(cc < 0) {
                /* probably ENOTEMPTY */
                LOGD("unable to rmdir '%s': %s (errno=%d)\n",
                    pathCopy, strerror(err), err);
            }
        } else {
            LOGD("unable to unlink '%s': %s (errno=%d)\n", 
                    pathCopy, strerror(err), err);
        }
    }

    return (cc == 0);
}

/*
 * harmony implements this method practically identical to the deleteFileImpl, 
 * except that it uses a diffrent helper method from hyport. Dalvik seems to 
 * just need this one method to delete both
 */
static jboolean java_io_File_deleteDirImpl(JNIEnv * env, jobject recv, 
        jbyteArray path) {
    return java_io_File_deleteFileImpl( env, recv, path);
}

/*
 * native public long lengthImpl()
 *
 * Returns the file length, or 0 if the file does not exist.  The result for
 * a directory is not defined.
 */
static jlong java_io_File_lengthImpl(JNIEnv* env, jobject obj, 
        jbyteArray path) {
    struct stat sb;
    jlong result = 0;
    int cc;

    char pathCopy[MaxPath];
    jsize length = (jsize) (*env)->GetArrayLength(env, path);
    length = length < MaxPath - 1 ? length : MaxPath - 1;
    (*env)->GetByteArrayRegion(env, path, 0, length, (jbyte *)pathCopy);
    pathCopy[length] = '\0';
    convertToPlatform(pathCopy);

    cc = stat(pathCopy, &sb);
    if(cc == 0) {
        // BEGIN android-added
        /*
         * This explicitly treats non-regular files (e.g., sockets and
         * block-special devices) as having size zero. Some synthetic
         * "regular" files may report an arbitrary non-zero size, but
         * in these cases they generally report a block count of zero.
         * So, use a zero block count to trump any other concept of
         * size.
         */
        if (S_ISREG(sb.st_mode) && (sb.st_blocks != 0)) {
            result = sb.st_size;
        } else {
            result = 0;
        }
        // END android-added
        // BEGIN android-deleted
        //result = sb.st_size;
        // END android-deleted
    }

    return result;
}

/*
 * native public long lastModified()
 *
 * Get the last modified date of the file. Measured in milliseconds 
 * from epoch (00:00:00 GMT, January 1, 1970). Returns 0 if the file does
 * not exist
 */
static jlong java_io_File_lastModifiedImpl(JNIEnv* env, jobject obj, 
        jbyteArray path) {
    struct stat sb;
    jlong result = 0;
    int cc;

    char pathCopy[MaxPath];
    jsize length = (jsize) (*env)->GetArrayLength(env, path);
    length = length < MaxPath - 1 ? length : MaxPath - 1;
    (*env)->GetByteArrayRegion(env, path, 0, length, (jbyte *)pathCopy);
    pathCopy[length] = '\0';
    convertToPlatform(pathCopy);

    cc = stat(pathCopy, &sb);
    if(cc == 0) {
        // sb.st_mtime is a time_t which is in seconds since epoch.
        result = sb.st_mtime;
        result *= 1000L;
    }

    return result;
}

/*
 * private static native int stattype(String path)
 */
static jint java_io_File_stattype(JNIEnv* env, jobject recv, 
        jbyteArray pathStr) {

    char pathCopy[MaxPath];
    jsize length = (jsize) (*env)->GetArrayLength(env, pathStr);
    length = length < MaxPath - 1 ? length : MaxPath - 1;
    (*env)->GetByteArrayRegion(env, pathStr, 0, length, (jbyte *)pathCopy);
    pathCopy[length] = '\0';
    convertToPlatform(pathCopy);

    struct stat sb;
    int cc, type;

    type = 0;
    cc = stat(pathCopy, &sb);

    if(cc == 0) {
        type |= STAT_TYPE_EXISTS;
        if(S_ISDIR(sb.st_mode)) {
            type |= STAT_TYPE_DIR;
        } else if(S_ISREG(sb.st_mode)) {
            type |= STAT_TYPE_FILE;
        }
    }

    return type;
}

static jboolean java_io_File_isDirectoryImpl(JNIEnv* env, jobject recv, 
        jbyteArray pathStr) {
    return ((java_io_File_stattype(env, recv, pathStr) & STAT_TYPE_DIR) 
            == STAT_TYPE_DIR);
}

static jboolean java_io_File_existsImpl(JNIEnv* env, jobject recv, 
        jbyteArray pathStr) {
    return ((java_io_File_stattype(env, recv, pathStr) & STAT_TYPE_EXISTS) 
            == STAT_TYPE_EXISTS);
}

static jboolean java_io_File_isFileImpl(JNIEnv* env, jobject recv, 
        jbyteArray pathStr) {
    return ((java_io_File_stattype(env, recv, pathStr) & STAT_TYPE_FILE) 
            == STAT_TYPE_FILE);
}

static jboolean java_io_File_isHiddenImpl(JNIEnv * env, jobject recv, 
        jbyteArray path) {

    char pathCopy[MaxPath];
    jsize index;
    jsize length = (*env)->GetArrayLength(env, path);
    length = length < MaxPath - 1 ? length : MaxPath - 1;

    if(length == 0) {
        return 0;
    }

    ((*env)->GetByteArrayRegion(env, path, 0, length, (jbyte *)pathCopy));
    pathCopy[length] = '\0';
    convertToPlatform(pathCopy);

    if(!java_io_File_existsImpl(env, recv, path)) {
        return 0;
    }

    for(index = length; index >= 0; index--) {
        if(pathCopy[index] == '.' 
                && (index > 0 && pathCopy[index - 1] == '/')) {
            return -1;
        }
    }

    return 0;
}

static jboolean java_io_File_readable(JNIEnv* env, jobject recv, 
        jbyteArray pathStr) {
    char path[MaxPath];
    struct stat sb;
    int cc, type;

    if(pathStr == NULL) {
        jniThrowException(env, "java/lang/NullPointerException", NULL);
        return -1;
    }
    
    jsize length = (jsize) (*env)->GetArrayLength(env, pathStr);

    length = length < MaxPath - 1 ? length : MaxPath - 1;
    (*env)->GetByteArrayRegion(env, pathStr, 0, length, (jbyte *)path);
    path[length] = '\0';
    convertToPlatform(path);

    cc = access(path, R_OK);

    return cc == 0;
}

static jboolean java_io_File_writable(JNIEnv* env, jobject recv, 
        jbyteArray pathStr) {
    char path[MaxPath];
    struct stat sb;
    int cc, type;

    if(pathStr == NULL) {
        jniThrowException(env, "java/lang/NullPointerException", NULL);
        return -1;
    }
    
    jsize length = (jsize) (*env)->GetArrayLength(env, pathStr);

    length = length < MaxPath - 1 ? length : MaxPath - 1;
    (*env)->GetByteArrayRegion(env, pathStr, 0, length, (jbyte *)path);
    path[length] = '\0';
    convertToPlatform(path);
    
    cc = access(path, W_OK);

    return cc == 0;
}

// BEGIN android-deleted
#if 0
static jboolean java_io_File_isReadOnlyImpl(JNIEnv* env, jobject recv, 
        jbyteArray path) {

    return (java_io_File_readable(env, recv, path) 
            && !java_io_File_writable(env, recv, path));
}

static jboolean java_io_File_isWriteOnlyImpl(JNIEnv* env, jobject recv, 
        jbyteArray path) {

    return (!java_io_File_readable(env, recv, path) 
            && java_io_File_writable(env, recv, path));
}
#endif
// END android-deleted

static jbyteArray java_io_File_getLinkImpl(JNIEnv* env, jobject recv, 
        jbyteArray path) {
    jbyteArray answer;
    jsize answerlen;
    char pathCopy[MaxPath];

    jsize length = (jsize) (*env)->GetArrayLength(env, path);

    length = length < MaxPath - 1 ? length : MaxPath - 1;
    (*env)->GetByteArrayRegion(env, path, 0, length, (jbyte *)pathCopy);
    pathCopy[length] = '\0';
    convertToPlatform(pathCopy);

    jboolean test = -1;

    char *link = pathCopy;

    int size = readlink(link, link, MaxPath);
    if(size <= 0) {
        test = 0;
    } else {
        if(size >= MaxPath) {
            link[MaxPath - 1] = 0;
        } else {
            link[size] = 0;
        }
    }

    if(test) {
        answerlen = strlen(pathCopy);
        answer = (*env)->NewByteArray(env, answerlen);
        (*env)->SetByteArrayRegion(env, answer, 0, answerlen,
                                  (jbyte *) pathCopy);
    } else {
        answer = path;
    }

    return answer;
}

static jboolean java_io_File_setLastModifiedImpl(JNIEnv* env, jobject recv, 
        jbyteArray path, jlong time) {
    jboolean result;
    
    jsize length = (*env)->GetArrayLength(env, path);
    char pathCopy[MaxPath];
    length = length < MaxPath - 1 ? length : MaxPath - 1;
    ((*env)->GetByteArrayRegion(env, path, 0, length, (jbyte *)pathCopy));
    pathCopy[length] = '\0';
    convertToPlatform(pathCopy);

    struct stat statbuf;
    struct utimbuf timebuf;
    if(stat(pathCopy, &statbuf)) {
        result = 0;
    } else {
        timebuf.actime = statbuf.st_atime;
        timebuf.modtime = (time_t) (time / 1000);
        result = utime(pathCopy, &timebuf) == 0;
    }

    return result;
}

static jboolean java_io_File_setReadOnlyImpl(JNIEnv* env, jobject recv, 
        jbyteArray path) {
    jsize length = (*env)->GetArrayLength(env, path);
    char pathCopy[MaxPath];
    length = length < MaxPath - 1 ? length : MaxPath - 1;

    ((*env)->GetByteArrayRegion(env, path, 0, length, (jbyte *)pathCopy));

    pathCopy[length] = '\0';
    convertToPlatform(pathCopy);

    struct stat buffer;
    mode_t mode;
    if(stat(pathCopy, &buffer)) {
        return 0;
    }
    mode = buffer.st_mode;
    mode = mode & 07555;

    return chmod(pathCopy, mode) == 0;
}

static jobject java_io_File_listImpl(JNIEnv* env, jclass clazz, 
        jbyteArray path) {
    
    struct dirEntry {
        char pathEntry[MaxPath];
        struct dirEntry *next;
    } *dirList, *currentEntry;

    jsize length = (*env)->GetArrayLength(env, path);
    char pathCopy[MaxPath];
    char filename[MaxPath];
    jint result = 0, index;
    jint numEntries = 0;
    jarray answer = NULL;
    jclass javaClass = NULL;

    dirList = NULL;
    currentEntry = NULL;

    length = length < MaxPath - 1 ? length : MaxPath - 1;
    ((*env)->GetByteArrayRegion(env, path, 0, length, (jbyte *)pathCopy));
    if(length >= 1 && pathCopy[length - 1] != '\\' 
            && pathCopy[length - 1] != '/') {
        pathCopy[length] = '/';
        length++;
    }
    pathCopy[length] = '\0';
    
    convertToPlatform(pathCopy);

    DIR *dirp = NULL;
    struct dirent *entry;

    dirp = opendir(pathCopy);

    if(dirp == NULL) {
        return NULL;
    }

    entry = readdir(dirp);

    if(entry == NULL) {
        closedir(dirp);
        return NULL;
    }
    strcpy(filename, entry->d_name);

    while(result > -1) {
        if(strcmp(".", filename) != 0 && (strcmp("..", filename) != 0)) {
            if(numEntries > 0) {
                currentEntry->next = 
                        (struct dirEntry *) malloc(sizeof(struct dirEntry));
                currentEntry = currentEntry->next;
            } else {
                dirList = (struct dirEntry *) malloc(sizeof(struct dirEntry));
                currentEntry = dirList;
            }
            if(currentEntry == NULL) {
                closedir(dirp);
                jniThrowException(env, "java/lang/OutOfMemoryError", NULL);
                goto cleanup;
            }
            strcpy(currentEntry->pathEntry, filename);
            numEntries++;
        }

        entry = readdir(dirp);

        if(entry == NULL) {
            result = -1;
        } else {
            strcpy(filename, entry->d_name);
        }
    }
    closedir(dirp);

    if(numEntries == 0) {
        return NULL;
    }

    javaClass = (*env)->FindClass(env, "[B");
    if(javaClass == NULL) {
        return NULL;
    }
    answer = (*env)->NewObjectArray(env, numEntries, javaClass, NULL);

cleanup:
    for(index = 0; index < numEntries; index++)
    {
        jbyteArray entrypath;
        jsize entrylen = strlen(dirList->pathEntry);
        currentEntry = dirList;
        if(answer)
        {
            entrypath = (*env)->NewByteArray(env, entrylen);
            (*env)->SetByteArrayRegion(env, entrypath, 0, entrylen,
                                      (jbyte *) dirList->pathEntry);
            (*env)->SetObjectArrayElement(env, answer, index, entrypath);
            (*env)->DeleteLocalRef(env, entrypath);
        }
        dirList = dirList->next;
        free((void *)currentEntry);
    }

    return answer;
}

static jboolean java_io_File_mkdirImpl(JNIEnv* env, jobject recv, 
        jbyteArray path) {
    jint result;
    char pathCopy[MaxPath];
    jsize length = (*env)->GetArrayLength(env, path);
    length = length < MaxPath - 1 ? length : MaxPath - 1;
    ((*env)->GetByteArrayRegion(env, path, 0, length, (jbyte *)pathCopy));
    pathCopy[length] = '\0';
    convertToPlatform(pathCopy);

// BEGIN android-changed
// don't want default permissions to allow global access.
    result = mkdir(pathCopy, S_IRWXU);
// END android-changed

    if(-1 != result)
    {
      result = 0;
    }

    return result == 0;
}

static jint java_io_File_newFileImpl(JNIEnv* env, jobject recv, 
        jbyteArray path) {
    
    if(path == NULL) {
        jniThrowException(env, "java/lang/NullPointerException", NULL);
        return -1;
    }
    
    jint result;
    jsize length = (*env)->GetArrayLength(env, path);
    char pathCopy[MaxPath];
    length = length < MaxPath - 1 ? length : MaxPath - 1;
    (*env)->GetByteArrayRegion(env, path, 0, length, (jbyte *)pathCopy);
    pathCopy[length] = '\0';
    convertToPlatform(pathCopy);

    /* First check to see if file already exists */
    if(java_io_File_existsImpl(env, recv, path))
    {
        return 1;
    }

    /* Now create the file and close it */
// BEGIN android-changed
// don't want default permissions to allow global access.
    int fd = open(pathCopy, O_EXCL | O_CREAT, 0600);
// END android-changed
    if(fd == -1)
    {
        if(errno == EEXIST) {
            return 1;
        }
        return -1;
    }
    close(fd);

    return 0;
}

static jboolean java_io_File_renameToImpl(JNIEnv* env, jobject recv, 
        jbyteArray pathExist, jbyteArray pathNew) {
    jint result;
    jsize length;
    char pathExistCopy[MaxPath], pathNewCopy[MaxPath];

    length = (*env)->GetArrayLength(env, pathExist);
    length = length < MaxPath - 1 ? length : MaxPath - 1;
    ((*env)->GetByteArrayRegion(env, pathExist, 0, length, 
            (jbyte *)pathExistCopy));
    pathExistCopy[length] = '\0';

    length = (*env)->GetArrayLength(env, pathNew);
    length = length < MaxPath - 1 ? length : MaxPath - 1;
    ((*env)->GetByteArrayRegion(env, pathNew, 0, length, 
            (jbyte *)pathNewCopy));
    pathNewCopy[length] = '\0';

    convertToPlatform(pathExistCopy);
    convertToPlatform(pathNewCopy);

    result = rename(pathExistCopy, pathNewCopy);

    return result == 0;
}

static void java_io_File_oneTimeInitialization(JNIEnv * env, jclass clazz)
{
  // dummy to stay compatible to harmony
}

/*
 * JNI registration
 */
static JNINativeMethod gMethods[] = {
    /* name, signature, funcPtr */
    { "rootsImpl",          "()[[B",  (void*) java_io_File_rootsImpl },
    { "deleteDirImpl",      "([B)Z",  (void*) java_io_File_deleteDirImpl },
    { "deleteFileImpl",     "([B)Z",  (void*) java_io_File_deleteFileImpl },
    { "existsImpl",         "([B)Z",  (void*) java_io_File_existsImpl },
    { "getCanonImpl",       "([B)[B", (void*) java_io_File_getCanonImpl },
    { "isDirectoryImpl",    "([B)Z",  (void*) java_io_File_isDirectoryImpl },
    { "isFileImpl",         "([B)Z",  (void*) java_io_File_isFileImpl },
    { "isHiddenImpl",       "([B)Z",  (void*) java_io_File_isHiddenImpl },
    // BEGIN android-changed
    { "isReadableImpl",     "([B)Z",  (void*) java_io_File_readable },
    { "isWriteableImpl",    "([B)Z",  (void*) java_io_File_writable },
    // END android-changed
    { "getLinkImpl",        "([B)[B", (void*) java_io_File_getLinkImpl },
    { "lastModifiedImpl",   "([B)J",  (void*) java_io_File_lastModifiedImpl },
    { "setReadOnlyImpl",    "([B)Z",  (void*) java_io_File_setReadOnlyImpl },
    { "lengthImpl",         "([B)J",  (void*) java_io_File_lengthImpl },
    { "listImpl",           "([B)[[B",(void*) java_io_File_listImpl },
    { "mkdirImpl",          "([B)Z",  (void*) java_io_File_mkdirImpl },
    { "newFileImpl",        "([B)I",  (void*) java_io_File_newFileImpl },
    { "renameToImpl",       "([B[B)Z",(void*) java_io_File_renameToImpl },
    { "setLastModifiedImpl","([BJ)Z",
        (void*) java_io_File_setLastModifiedImpl },
    { "oneTimeInitialization","()V", 
        (void*) java_io_File_oneTimeInitialization }
};
int register_java_io_File(JNIEnv* env)
{
    return jniRegisterNativeMethods(env, "java/io/File",
                gMethods, NELEM(gMethods));
}