Esempio n. 1
0
JNIEXPORT jlong JNICALL
Java_java_util_zip_ZipFile_open(JNIEnv *env, jclass cls, jstring name, jint mode)
{
    const char *path = JNU_GetStringPlatformChars(env, name, 0);
    jlong result = 0;
    int flag = 0;
    
    if (mode & OPEN_READ) flag |= O_RDONLY;
    if (mode & OPEN_DELETE) flag |= JVM_O_DELETE;

    if (path != 0) {
	char *msg;
	jzfile *zip = ZIP_Open_Generic(path, &msg, flag);
	JNU_ReleaseStringPlatformChars(env, name, path);
	if (zip != 0) {
	    result = ptr_to_jlong(zip);
	} else if (msg != 0) {
	    ThrowZipException(env, msg);
	} else if (errno == ENOMEM) {
	    JNU_ThrowOutOfMemoryError(env, 0);
	} else {
	    ThrowZipException(env, "error in opening zip file");
	}
    }
    return result;
}
Esempio n. 2
0
/*
 * Opens a zip file for reading. Returns the jzfile object or NULL
 * if an error occurred. If a zip error occurred then *msg will be
 * set to the error message text if msg != 0. Otherwise, *msg will be
 * set to NULL. Caller doesn't need to free the error message.
 */
jzfile * JNICALL
ZIP_Open(const char *name, char **pmsg)
{
    jzfile *file = ZIP_Open_Generic(name, pmsg, O_RDONLY, 0);
    if (file == NULL && pmsg != NULL && *pmsg != NULL) {
        free(*pmsg);
        *pmsg = "Zip file open error";
    }
    return file;
}
Esempio n. 3
0
/*
 * Opens a zip file for reading. Returns the jzfile object or NULL
 * if an error occurred. If a zip error occurred then *msg will be
 * set to the error message text if msg != 0. Otherwise, *msg will be
 * set to NULL.
 */
jzfile * JNICALL
ZIP_Open(const char *name, char **pmsg)
{
    return ZIP_Open_Generic(name, pmsg, O_RDONLY, 0);
}