legacy/extras/java/trunk/src/jni/libisofs/IsoTreeNode.c

132 lines
3.1 KiB
C

/*
* IsoTreeNode.c
*
* Copyright (c) 2007 Vreixo Formoso
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* See COPYING file for details.
*/
#include "org_pykix_libburnia_libisofs_IsoTreeNode.h"
#include "libisofs.h"
/*
* Class: org_pykix_libburnia_libisofs_IsoTreeNode
* Method: iso_tree_add_node
* Signature: (JLjava/lang/String;)J
*/
JNIEXPORT jlong JNICALL
Java_org_pykix_libburnia_libisofs_IsoTreeNode_iso_1tree_1add_1node
(
JNIEnv *env, jclass cls, jlong parent, jstring path
)
{
const char *cpath;
struct iso_tree_node *node;
cpath = (*env)->GetStringUTFChars(env, path, NULL);
if ( cpath == NULL ) {
return 0; /* OutOfMemoryError already thrown */
}
node = iso_tree_add_node( (struct iso_tree_node *) parent, cpath);
(*env)->ReleaseStringUTFChars(env, path, cpath);
return (jlong) node;
}
/*
* Class: org_pykix_libburnia_libisofs_IsoTreeNode
* Method: iso_tree_radd_dir
* Signature: (JLjava/lang/String;)J
*/
JNIEXPORT jlong JNICALL
Java_org_pykix_libburnia_libisofs_IsoTreeNode_iso_1tree_1radd_1dir
(
JNIEnv *env, jclass cls, jlong parent, jstring path
)
{
const char *cpath;
struct iso_tree_node *node;
cpath = (*env)->GetStringUTFChars(env, path, NULL);
if ( cpath == NULL ) {
return 0; /* OutOfMemoryError already thrown */
}
node = iso_tree_radd_dir( (struct iso_tree_node *) parent, cpath);
(*env)->ReleaseStringUTFChars(env, path, cpath);
return (jlong) node;
}
/*
* Class: org_pykix_libburnia_libisofs_IsoTreeNode
* Method: iso_tree_print
* Signature: (JI)V
*/
JNIEXPORT void JNICALL
Java_org_pykix_libburnia_libisofs_IsoTreeNode_iso_1tree_1print
(
JNIEnv *env, jclass cls, jlong root, jint spaces
)
{
iso_tree_print( (const struct iso_tree_node *) root, spaces);
fflush(stdout);
}
/*
* Class: org_pykix_libburnia_libisofs_IsoTreeNode
* Method: iso_tree_node_set_name
* Signature: (JLjava/lang/String;)V
*/
JNIEXPORT void JNICALL
Java_org_pykix_libburnia_libisofs_IsoTreeNode_iso_1tree_1node_1set_1name
(
JNIEnv *env, jclass cls, jlong file, jstring name
)
{
const char *cname;
cname = (*env)->GetStringUTFChars(env, name, NULL);
if ( cname == NULL ) {
return; /* OutOfMemoryError already thrown */
}
iso_tree_node_set_name( (struct iso_tree_node *) file, cname);
(*env)->ReleaseStringUTFChars(env, name, cname);
}
/*
* Class: org_pykix_libburnia_libisofs_IsoTreeNode
* Method: iso_tree_add_new_dir
* Signature: (JLjava/lang/String;)J
*/
JNIEXPORT jlong JNICALL
Java_org_pykix_libburnia_libisofs_IsoTreeNode_iso_1tree_1add_1new_1dir
(
JNIEnv *env, jclass cls, jlong parent, jstring name
)
{
const char *cname;
struct iso_tree_node *node;
cname = (*env)->GetStringUTFChars(env, name, NULL);
if ( cname == NULL ) {
return; /* OutOfMemoryError already thrown */
}
node = iso_tree_add_new_dir( (struct iso_tree_node *) parent, cname);
(*env)->ReleaseStringUTFChars(env, name, cname);
return (jlong) node;
}