48 |
/* do not move; needed here because of some macro definitions */ |
/* do not move; needed here because of some macro definitions */ |
49 |
#include <config.h> |
#include <config.h> |
50 |
|
|
51 |
|
#include <stdlib.h> |
52 |
|
|
53 |
/* FIXME: Need to make configure set these for us */ |
/* FIXME: Need to make configure set these for us */ |
54 |
/* #define HAVE_SYS_IOCTL_H */ |
/* #define HAVE_SYS_IOCTL_H */ |
55 |
/* #define HAVE_SYS_FILIO_H */ |
/* #define HAVE_SYS_FILIO_H */ |
|
#define HAVE_FTRUNCATE |
|
|
#define HAVE_FSYNC |
|
|
#define HAVE_SELECT |
|
56 |
|
|
57 |
#include <jni.h> |
#include <jni.h> |
58 |
#include "jcl.h" |
#include "jcl.h" |
196 |
JCL_ThrowException(env, |
JCL_ThrowException(env, |
197 |
"java/io/FileNotFoundException", |
"java/io/FileNotFoundException", |
198 |
TARGET_NATIVE_LAST_ERROR_STRING()); |
TARGET_NATIVE_LAST_ERROR_STRING()); |
199 |
return JNI_JLONG_CONST_MINUS_1; |
return TARGET_NATIVE_MATH_INT_INT64_CONST_MINUS_1; |
200 |
} |
} |
201 |
|
|
202 |
return CONVERT_INT_TO_JLONG(native_fd); |
return CONVERT_INT_TO_JLONG(native_fd); |
221 |
JCL_ThrowException(env, |
JCL_ThrowException(env, |
222 |
"java/io/IOException", |
"java/io/IOException", |
223 |
TARGET_NATIVE_LAST_ERROR_STRING()); |
TARGET_NATIVE_LAST_ERROR_STRING()); |
224 |
return(JNI_JLONG_CONST_MINUS_1); |
return(TARGET_NATIVE_MATH_INT_INT64_CONST_MINUS_1); |
225 |
} |
} |
226 |
|
|
227 |
return(JNI_JLONG_CONST_0); |
return(TARGET_NATIVE_MATH_INT_INT64_CONST_0); |
228 |
} |
} |
229 |
|
|
230 |
/*************************************************************************/ |
/*************************************************************************/ |
253 |
JCL_ThrowException(env, |
JCL_ThrowException(env, |
254 |
"java/io/IOException", |
"java/io/IOException", |
255 |
TARGET_NATIVE_LAST_ERROR_STRING()); |
TARGET_NATIVE_LAST_ERROR_STRING()); |
256 |
return(JNI_JLONG_CONST_MINUS_1); |
return(TARGET_NATIVE_MATH_INT_INT64_CONST_MINUS_1); |
257 |
} |
} |
258 |
} |
} |
259 |
while (result != TARGET_NATIVE_OK); |
while (result != TARGET_NATIVE_OK); |
260 |
|
|
261 |
return(JNI_JLONG_CONST_0); |
return(TARGET_NATIVE_MATH_INT_INT64_CONST_0); |
262 |
} |
} |
263 |
|
|
264 |
/*************************************************************************/ |
/*************************************************************************/ |
283 |
if (!bufptr) |
if (!bufptr) |
284 |
{ |
{ |
285 |
JCL_ThrowException(env, "java/io/IOException", "Unexpected JNI error"); |
JCL_ThrowException(env, "java/io/IOException", "Unexpected JNI error"); |
286 |
return(JNI_JLONG_CONST_MINUS_1); |
return(TARGET_NATIVE_MATH_INT_INT64_CONST_MINUS_1); |
287 |
} |
} |
288 |
|
|
289 |
bytes_written = 0; |
bytes_written = 0; |
297 |
"java/io/IOException", |
"java/io/IOException", |
298 |
TARGET_NATIVE_LAST_ERROR_STRING()); |
TARGET_NATIVE_LAST_ERROR_STRING()); |
299 |
(*env)->ReleaseByteArrayElements(env, buf, bufptr, 0); |
(*env)->ReleaseByteArrayElements(env, buf, bufptr, 0); |
300 |
return(JNI_JLONG_CONST_MINUS_1); |
return(TARGET_NATIVE_MATH_INT_INT64_CONST_MINUS_1); |
301 |
} |
} |
302 |
bytes_written += n; |
bytes_written += n; |
303 |
} |
} |
304 |
|
|
305 |
(*env)->ReleaseByteArrayElements(env, buf, bufptr, 0); |
(*env)->ReleaseByteArrayElements(env, buf, bufptr, 0); |
306 |
|
|
307 |
return(JNI_JLONG_CONST_0); |
return(TARGET_NATIVE_MATH_INT_INT64_CONST_0); |
308 |
} |
} |
309 |
|
|
310 |
/*************************************************************************/ |
/*************************************************************************/ |
458 |
{ |
{ |
459 |
JCL_ThrowException(env, "java/io/IOException", |
JCL_ThrowException(env, "java/io/IOException", |
460 |
"Cannot represent position correctly on this system"); |
"Cannot represent position correctly on this system"); |
461 |
return(JNI_JLONG_CONST_MINUS_1); |
return(TARGET_NATIVE_MATH_INT_INT64_CONST_MINUS_1); |
462 |
} |
} |
463 |
#endif /* 0 */ |
#endif /* 0 */ |
464 |
|
|
471 |
JCL_ThrowException(env, |
JCL_ThrowException(env, |
472 |
"java/io/IOException", |
"java/io/IOException", |
473 |
TARGET_NATIVE_LAST_ERROR_STRING()); |
TARGET_NATIVE_LAST_ERROR_STRING()); |
474 |
return(JNI_JLONG_CONST_MINUS_1); |
return(TARGET_NATIVE_MATH_INT_INT64_CONST_MINUS_1); |
475 |
} |
} |
476 |
|
|
477 |
/* set file read/write position (seek) */ |
/* set file read/write position (seek) */ |
488 |
JCL_ThrowException(env, |
JCL_ThrowException(env, |
489 |
"java/io/IOException", |
"java/io/IOException", |
490 |
TARGET_NATIVE_LAST_ERROR_STRING()); |
TARGET_NATIVE_LAST_ERROR_STRING()); |
491 |
return(JNI_JLONG_CONST_MINUS_1); |
return(TARGET_NATIVE_MATH_INT_INT64_CONST_MINUS_1); |
492 |
} |
} |
493 |
if (TARGET_NATIVE_MATH_INT_INT64_GT(TARGET_NATIVE_MATH_INT_INT64_ADD(current_offset,offset),file_size)) |
if (TARGET_NATIVE_MATH_INT_INT64_GT(TARGET_NATIVE_MATH_INT_INT64_ADD(current_offset,offset),file_size)) |
494 |
{ |
{ |
498 |
} |
} |
499 |
else if (TARGET_NATIVE_MATH_INT_INT64_GT(offset,0)) /* Default to END case */ |
else if (TARGET_NATIVE_MATH_INT_INT64_GT(offset,0)) /* Default to END case */ |
500 |
{ |
{ |
501 |
offset = JNI_JLONG_CONST_0; |
offset = TARGET_NATIVE_MATH_INT_INT64_CONST_0; |
502 |
} |
} |
503 |
} |
} |
504 |
|
|
505 |
/* Now do it */ |
/* Now do it */ |
506 |
result = TARGET_NATIVE_ERROR; |
result = TARGET_NATIVE_ERROR; |
507 |
new_offset = JNI_JLONG_CONST_MINUS_1; |
new_offset = TARGET_NATIVE_MATH_INT_INT64_CONST_MINUS_1; |
508 |
if (whence == FILEDESCRIPTOR_FILESEEK_SET) |
if (whence == FILEDESCRIPTOR_FILESEEK_SET) |
509 |
TARGET_NATIVE_FILE_SEEK_BEGIN(native_fd, offset, new_offset, result); |
TARGET_NATIVE_FILE_SEEK_BEGIN(native_fd, offset, new_offset, result); |
510 |
if (whence == FILEDESCRIPTOR_FILESEEK_CUR) |
if (whence == FILEDESCRIPTOR_FILESEEK_CUR) |
517 |
JCL_ThrowException(env, |
JCL_ThrowException(env, |
518 |
"java/io/IOException", |
"java/io/IOException", |
519 |
TARGET_NATIVE_LAST_ERROR_STRING()); |
TARGET_NATIVE_LAST_ERROR_STRING()); |
520 |
return(JNI_JLONG_CONST_MINUS_1); |
return(TARGET_NATIVE_MATH_INT_INT64_CONST_MINUS_1); |
521 |
} |
} |
522 |
|
|
523 |
return(new_offset); |
return(new_offset); |
544 |
JCL_ThrowException(env, |
JCL_ThrowException(env, |
545 |
"java/io/IOException", |
"java/io/IOException", |
546 |
TARGET_NATIVE_LAST_ERROR_STRING()); |
TARGET_NATIVE_LAST_ERROR_STRING()); |
547 |
return(JNI_JLONG_CONST_MINUS_1); |
return(TARGET_NATIVE_MATH_INT_INT64_CONST_MINUS_1); |
548 |
} |
} |
549 |
|
|
550 |
return(current_offset); |
return(current_offset); |
570 |
JCL_ThrowException(env, |
JCL_ThrowException(env, |
571 |
"java/io/IOException", |
"java/io/IOException", |
572 |
TARGET_NATIVE_LAST_ERROR_STRING()); |
TARGET_NATIVE_LAST_ERROR_STRING()); |
573 |
return(JNI_JLONG_CONST_MINUS_1); |
return(TARGET_NATIVE_MATH_INT_INT64_CONST_MINUS_1); |
574 |
} |
} |
575 |
|
|
576 |
return(file_size); |
return(file_size); |
613 |
"Cannot represent position correctly on this system"); |
"Cannot represent position correctly on this system"); |
614 |
return; |
return; |
615 |
} |
} |
616 |
#endif |
#endif /* 0 */ |
617 |
|
|
618 |
/* get file size */ |
/* get file size */ |
619 |
TARGET_NATIVE_FILE_SIZE(native_fd, file_size, result); |
TARGET_NATIVE_FILE_SIZE(native_fd, file_size, result); |