1 /*
2 * Copyright (c) 1994, 2013, 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
184 break;
185 }
186 if (append == JNI_TRUE) {
187 n = IO_Append(fd, buf+off, len);
188 } else {
189 n = IO_Write(fd, buf+off, len);
190 }
191 if (n == -1) {
192 JNU_ThrowIOExceptionWithLastError(env, "Write error");
193 break;
194 }
195 off += n;
196 len -= n;
197 }
198 }
199 if (buf != stackBuf) {
200 free(buf);
201 }
202 }
203
204 void
205 throwFileNotFoundException(JNIEnv *env, jstring path)
206 {
207 char buf[256];
208 size_t n;
209 jobject x;
210 jstring why = NULL;
211
212 n = getLastErrorString(buf, sizeof(buf));
213 if (n > 0) {
214 #ifdef WIN32
215 why = (*env)->NewStringUTF(env, buf);
216 #else
217 why = JNU_NewStringPlatform(env, buf);
218 #endif
219 CHECK_NULL(why);
220 }
221 x = JNU_NewObjectByName(env,
222 "java/io/FileNotFoundException",
223 "(Ljava/lang/String;Ljava/lang/String;)V",
224 path, why);
|
1 /*
2 * Copyright (c) 1994, 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
184 break;
185 }
186 if (append == JNI_TRUE) {
187 n = IO_Append(fd, buf+off, len);
188 } else {
189 n = IO_Write(fd, buf+off, len);
190 }
191 if (n == -1) {
192 JNU_ThrowIOExceptionWithLastError(env, "Write error");
193 break;
194 }
195 off += n;
196 len -= n;
197 }
198 }
199 if (buf != stackBuf) {
200 free(buf);
201 }
202 }
203
204 JNIEXPORT void JNICALL
205 throwFileNotFoundException(JNIEnv *env, jstring path)
206 {
207 char buf[256];
208 size_t n;
209 jobject x;
210 jstring why = NULL;
211
212 n = getLastErrorString(buf, sizeof(buf));
213 if (n > 0) {
214 #ifdef WIN32
215 why = (*env)->NewStringUTF(env, buf);
216 #else
217 why = JNU_NewStringPlatform(env, buf);
218 #endif
219 CHECK_NULL(why);
220 }
221 x = JNU_NewObjectByName(env,
222 "java/io/FileNotFoundException",
223 "(Ljava/lang/String;Ljava/lang/String;)V",
224 path, why);
|