/[classpath]/classpath/native/jni/java-io/javaio.c
ViewVC logotype

Diff of /classpath/native/jni/java-io/javaio.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by cbj, Mon Nov 12 23:37:03 2001 UTC revision 1.3 by cbj, Tue Nov 27 03:12:02 2001 UTC
# Line 32  executable file might be covered by the Line 32  executable file might be covered by the
32  #include <fcntl.h>  #include <fcntl.h>
33  #include <unistd.h>  #include <unistd.h>
34  #include <sys/stat.h>  #include <sys/stat.h>
35    #include <malloc.h>
36    
37  #include <jni.h>  #include <jni.h>
38    #include <jcl.h>
39    
40  #include "javaio.h"  #include "javaio.h"
41    
 #include <malloc.h>  
42    
43  /*  /*
44   * Function to open a file   * Function to open a file
# Line 58  _javaio_open(JNIEnv *env, jstring name, Line 59  _javaio_open(JNIEnv *env, jstring name,
59    if (fd == -1)    if (fd == -1)
60      {      {
61        if (errno == ENOENT)        if (errno == ENOENT)
62          _javaio_ThrowException(env, "java/io/FileNotFoundException",          JCL_ThrowException(env, "java/io/FileNotFoundException",
63                             strerror(errno));                             strerror(errno));
64        else        else
65          _javaio_ThrowException(env, "java/io/IOException", strerror(errno));          JCL_ThrowException(env, "java/io/IOException", strerror(errno));
66      }      }
67    
68    return(fd);    return(fd);
# Line 80  _javaio_close(JNIEnv *env, jint fd) Line 81  _javaio_close(JNIEnv *env, jint fd)
81    
82    rc = close(fd);    rc = close(fd);
83    if (rc == -1)    if (rc == -1)
84      _javaio_ThrowException(env, "java/io/IOException", strerror(errno));      JCL_ThrowException(env, "java/io/IOException", strerror(errno));
85  }  }
86    
87  /*************************************************************************/  /*************************************************************************/
# Line 96  _javaio_skip_bytes(JNIEnv *env, jint fd, Line 97  _javaio_skip_bytes(JNIEnv *env, jint fd,
97    
98    cur = lseek(fd, 0, SEEK_CUR);    cur = lseek(fd, 0, SEEK_CUR);
99    if (cur == -1)    if (cur == -1)
100      _javaio_ThrowException(env, "java/io/IOException", strerror(errno));      JCL_ThrowException(env, "java/io/IOException", strerror(errno));
101    
102    new = lseek(fd, num_bytes, SEEK_CUR);    new = lseek(fd, num_bytes, SEEK_CUR);
103    if (new == -1)    if (new == -1)
104      _javaio_ThrowException(env, "java/io/IOException", strerror(errno));      JCL_ThrowException(env, "java/io/IOException", strerror(errno));
105    
106    return(new - cur);    return(new - cur);
107  }  }
# Line 120  _javaio_get_file_length(JNIEnv *env, jin Line 121  _javaio_get_file_length(JNIEnv *env, jin
121    rc = fstat(fd, &buf);    rc = fstat(fd, &buf);
122    if (rc == -1)    if (rc == -1)
123      {      {
124        _javaio_ThrowException(env, "java/io/IOException", strerror(errno));        JCL_ThrowException(env, "java/io/IOException", strerror(errno));
125        return(-1);        return(-1);
126      }      }
127    
# Line 143  _javaio_read(JNIEnv *env, jobject obj, j Line 144  _javaio_read(JNIEnv *env, jobject obj, j
144    bufptr = (*env)->GetByteArrayElements(env, buf, JNI_FALSE);    bufptr = (*env)->GetByteArrayElements(env, buf, JNI_FALSE);
145    if (!bufptr)    if (!bufptr)
146      {      {
147        _javaio_ThrowException(env, "java/io/IOException", "Internal Error");        JCL_ThrowException(env, "java/io/IOException", "Internal Error");
148        return(-1);        return(-1);
149      }      }
150    
151    rc = read(fd, (bufptr + offset), len);    rc = read(fd, (bufptr + offset), len);
152    if (rc == -1)    if (rc == -1)
153      _javaio_ThrowException(env, "java/io/IOException", strerror(errno));      JCL_ThrowException(env, "java/io/IOException", strerror(errno));
154    
155    (*env)->ReleaseByteArrayElements(env, buf, bufptr, 0);    (*env)->ReleaseByteArrayElements(env, buf, bufptr, 0);
156    
# Line 175  _javaio_write(JNIEnv *env, jobject obj, Line 176  _javaio_write(JNIEnv *env, jobject obj,
176    bufptr = (*env)->GetByteArrayElements(env, buf, 0);    bufptr = (*env)->GetByteArrayElements(env, buf, 0);
177    if (!bufptr)    if (!bufptr)
178      {      {
179        _javaio_ThrowException(env, "java/io/IOException", "Internal Error");        JCL_ThrowException(env, "java/io/IOException", "Internal Error");
180        return(-1);        return(-1);
181      }      }
182    
183    rc = write(fd, (bufptr + offset), len);    rc = write(fd, (bufptr + offset), len);
184    if (rc == -1)    if (rc == -1)
185      _javaio_ThrowException(env, "java/io/IOException", strerror(errno));      JCL_ThrowException(env, "java/io/IOException", strerror(errno));
186    
187    (*env)->ReleaseByteArrayElements(env, buf, bufptr, 0);    (*env)->ReleaseByteArrayElements(env, buf, bufptr, 0);
188    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26