< prev index next >

src/java.base/windows/native/libjava/io_util_md.h

Print this page


   1 /*
   2  * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  33 
  34 /*
  35  * Prototypes for functions in io_util_md.c called from io_util.c,
  36  * FileDescriptor.c, FileInputStream.c, FileOutputStream.c,
  37  * ProcessImpl_md.c
  38  */
  39 WCHAR* pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE);
  40 WCHAR* fileToNTPath(JNIEnv *env, jobject file, jfieldID id);
  41 WCHAR* getPrefixed(const WCHAR* path, int pathlen);
  42 WCHAR* currentDir(int di);
  43 int currentDirLength(const WCHAR* path, int pathlen);
  44 int handleAvailable(FD fd, jlong *pbytes);
  45 int handleSync(FD fd);
  46 int handleSetLength(FD fd, jlong length);
  47 jlong handleGetLength(FD fd);
  48 JNIEXPORT jint handleRead(FD fd, void *buf, jint len);
  49 jint handleWrite(FD fd, const void *buf, jint len);
  50 jint handleAppend(FD fd, const void *buf, jint len);
  51 void handleClose(JNIEnv *env, jobject this, jfieldID fid);
  52 void fileDescriptorClose(JNIEnv *env, jobject this);
  53 jlong handleLseek(FD fd, jlong offset, jint whence);

  54 
  55 /*
  56  * Returns an opaque handle to file named by "path".  If an error occurs,
  57  * returns -1 and an exception is pending.
  58  */
  59 FD winFileHandleOpen(JNIEnv *env, jstring path, int flags);

  60 
  61 /*
  62  * Macros to set/get fd from the java.io.FileDescriptor.
  63  * If GetObjectField returns null, SET_FD will stop and GET_FD
  64  * will simply return -1 to avoid crashing VM.
  65  */
  66 #define SET_FD(this, fd, fid) \
  67     if ((*env)->GetObjectField(env, (this), (fid)) != NULL) \
  68         (*env)->SetLongField(env, (*env)->GetObjectField(env, (this), (fid)), IO_handle_fdID, (fd))
  69 
  70 #define GET_FD(this, fid) \
  71     ((*env)->GetObjectField(env, (this), (fid)) == NULL) ? \
  72       -1 : (*env)->GetLongField(env, (*env)->GetObjectField(env, (this), (fid)), IO_handle_fdID)
  73 
  74 /*
  75  * Macros to set/get fd when inside java.io.FileDescriptor
  76  */
  77 #define THIS_FD(obj) (*env)->GetLongField(env, obj, IO_handle_fdID)
  78 
  79 /*


   1 /*
   2  * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  33 
  34 /*
  35  * Prototypes for functions in io_util_md.c called from io_util.c,
  36  * FileDescriptor.c, FileInputStream.c, FileOutputStream.c,
  37  * ProcessImpl_md.c
  38  */
  39 WCHAR* pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE);
  40 WCHAR* fileToNTPath(JNIEnv *env, jobject file, jfieldID id);
  41 WCHAR* getPrefixed(const WCHAR* path, int pathlen);
  42 WCHAR* currentDir(int di);
  43 int currentDirLength(const WCHAR* path, int pathlen);
  44 int handleAvailable(FD fd, jlong *pbytes);
  45 int handleSync(FD fd);
  46 int handleSetLength(FD fd, jlong length);
  47 jlong handleGetLength(FD fd);
  48 JNIEXPORT jint handleRead(FD fd, void *buf, jint len);
  49 jint handleWrite(FD fd, const void *buf, jint len);
  50 jint handleAppend(FD fd, const void *buf, jint len);
  51 void handleClose(JNIEnv *env, jobject this, jfieldID fid);
  52 void fileDescriptorClose(JNIEnv *env, jobject this);
  53 JNIEXPORT jlong JNICALL
  54 handleLseek(FD fd, jlong offset, jint whence);
  55 
  56 /*
  57  * Returns an opaque handle to file named by "path".  If an error occurs,
  58  * returns -1 and an exception is pending.
  59  */
  60 JNIEXPORT FD JNICALL
  61 winFileHandleOpen(JNIEnv *env, jstring path, int flags);
  62 
  63 /*
  64  * Macros to set/get fd from the java.io.FileDescriptor.
  65  * If GetObjectField returns null, SET_FD will stop and GET_FD
  66  * will simply return -1 to avoid crashing VM.
  67  */
  68 #define SET_FD(this, fd, fid) \
  69     if ((*env)->GetObjectField(env, (this), (fid)) != NULL) \
  70         (*env)->SetLongField(env, (*env)->GetObjectField(env, (this), (fid)), IO_handle_fdID, (fd))
  71 
  72 #define GET_FD(this, fid) \
  73     ((*env)->GetObjectField(env, (this), (fid)) == NULL) ? \
  74       -1 : (*env)->GetLongField(env, (*env)->GetObjectField(env, (this), (fid)), IO_handle_fdID)
  75 
  76 /*
  77  * Macros to set/get fd when inside java.io.FileDescriptor
  78  */
  79 #define THIS_FD(obj) (*env)->GetLongField(env, obj, IO_handle_fdID)
  80 
  81 /*


< prev index next >