src/java.base/share/native/libzip/zip_util.c
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 121,131 ****
NULL, /* Security attributes */
disposition, /* creation disposition */
flagsAndAttributes, /* flags and attributes */
NULL);
#else
! return JVM_Open(fname, flags, 0);
#endif
}
/*
* The io_util_md.h files do not provide IO_CLOSE, hence we use platform
--- 121,131 ----
NULL, /* Security attributes */
disposition, /* creation disposition */
flagsAndAttributes, /* flags and attributes */
NULL);
#else
! return open(fname, flags, 0);
#endif
}
/*
* The io_util_md.h files do not provide IO_CLOSE, hence we use platform
*** 134,160 ****
static void
ZFILE_Close(ZFILE zfd) {
#ifdef WIN32
CloseHandle((HANDLE) zfd);
#else
! JVM_Close(zfd);
#endif
}
static int
ZFILE_read(ZFILE zfd, char *buf, jint nbytes) {
#ifdef WIN32
return (int) IO_Read(zfd, buf, nbytes);
#else
- /*
- * Calling JVM_Read will return JVM_IO_INTR when Thread.interrupt is called
- * only on Solaris. Continue reading jar file in this case is the best
- * thing to do since zip file reading is relatively fast and it is very onerous
- * for a interrupted thread to deal with this kind of hidden I/O. However, handling
- * JVM_IO_INTR is tricky and could cause undesired side effect. So we decided
- * to simply call "read" on Solaris/Linux. See details in bug 6304463.
- */
return read(zfd, buf, nbytes);
#endif
}
/*
--- 134,152 ----
static void
ZFILE_Close(ZFILE zfd) {
#ifdef WIN32
CloseHandle((HANDLE) zfd);
#else
! close(zfd);
#endif
}
static int
ZFILE_read(ZFILE zfd, char *buf, jint nbytes) {
#ifdef WIN32
return (int) IO_Read(zfd, buf, nbytes);
#else
return read(zfd, buf, nbytes);
#endif
}
/*
*** 196,208 ****
(jint) limit;
jint n = ZFILE_read(zfd, bp, count);
if (n > 0) {
bp += n;
len -= n;
! } else if (n == JVM_IO_ERR && errno == EINTR) {
! /* Retry after EINTR (interrupted by signal).
! We depend on the fact that JVM_IO_ERR == -1. */
continue;
} else { /* EOF or IO error */
return -1;
}
}
--- 188,199 ----
(jint) limit;
jint n = ZFILE_read(zfd, bp, count);
if (n > 0) {
bp += n;
len -= n;
! } else if (n == -1 && errno == EINTR) {
! /* Retry after EINTR (interrupted by signal). */
continue;
} else { /* EOF or IO error */
return -1;
}
}
*** 826,836 ****
#endif
zip->refs = 1;
zip->lastModified = lastModified;
if (zfd == -1) {
! if (pmsg && JVM_GetLastErrorString(errbuf, sizeof(errbuf)) > 0)
*pmsg = strdup(errbuf);
freeZip(zip);
return NULL;
}
--- 817,827 ----
#endif
zip->refs = 1;
zip->lastModified = lastModified;
if (zfd == -1) {
! if (pmsg && getLastErrorString(errbuf, sizeof(errbuf)) > 0)
*pmsg = strdup(errbuf);
freeZip(zip);
return NULL;
}
*** 847,857 ****
if (len == 0) { /* zip file is empty */
if (pmsg) {
*pmsg = strdup("zip file is empty");
}
} else { /* error */
! if (pmsg && JVM_GetLastErrorString(errbuf, sizeof(errbuf)) > 0)
*pmsg = strdup(errbuf);
}
ZFILE_Close(zfd);
freeZip(zip);
return NULL;
--- 838,848 ----
if (len == 0) { /* zip file is empty */
if (pmsg) {
*pmsg = strdup("zip file is empty");
}
} else { /* error */
! if (pmsg && getLastErrorString(errbuf, sizeof(errbuf)) > 0)
*pmsg = strdup(errbuf);
}
ZFILE_Close(zfd);
freeZip(zip);
return NULL;