Changeset 1748 for trunk/lang/java


Ignore:
Timestamp:
Jun 4, 2010 1:57:37 PM (10 years ago)
Author:
braffert
Message:

added putData and putFile for java bindings

Location:
trunk/lang/java
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lang/java/Library.java

    r1732 r1748  
    5858  }
    5959
     60  public void putData(String path, byte[] b, boolean append){
     61    jRpPutData(libPtr, path, b, b.length, append);
     62  }
     63
     64  public void putData(String path, byte[] b){
     65    jRpPutData(libPtr, path, b, b.length, false);
     66  }
     67
     68  public void putFile(String path, String fileName,
     69                      boolean compress, boolean append){
     70    jRpPutFile(libPtr, path, fileName, compress, append);
     71  }
     72
     73  public void putFile(String path, String fileName, boolean compress){
     74    jRpPutFile(libPtr, path, fileName, compress, false);
     75  }
     76
     77  public void putFile(String path, String fileName){
     78    jRpPutFile(libPtr, path, fileName, true, false);
     79  }
     80
    6081  public void result(int exitStatus){
    6182    jRpResult(libPtr, exitStatus);
     
    7697  private native void jRpPut(long libPtr, String path,
    7798                             String value, boolean append);
     99  private native void jRpPutData(long libPtr, String path,
     100                                 byte[] b, int nbytes, boolean append);
     101  private native void jRpPutFile(long libPtr, String path, String fileName,
     102                                 boolean compress, boolean append);
    78103
    79104  private native void jRpResult(long libPtr, int exitStatus); 
  • trunk/lang/java/jRpLibrary.cc

    r1727 r1748  
    7676}
    7777
     78// putData
     79JNIEXPORT void JNICALL Java_rappture_Library_jRpPutData
     80  (JNIEnv *env, jobject obj, jlong libPtr, jstring javaPath,
     81    jbyteArray jb, jint nbytes, jboolean append){
     82  const char* nativePath = env->GetStringUTFChars(javaPath, 0);
     83  jbyte* b = env->GetByteArrayElements(jb, NULL);
     84  ((RpLibrary*)libPtr)->putData(nativePath, (const char*)b, nbytes, append);
     85  env->ReleaseByteArrayElements(jb, b, 0);
     86  env->ReleaseStringUTFChars(javaPath, nativePath);
     87}
     88
     89// putFile
     90JNIEXPORT void JNICALL Java_rappture_Library_jRpPutFile
     91  (JNIEnv *env, jobject obj, jlong libPtr, jstring javaPath,
     92   jstring javaFileName, jboolean compress, jboolean append){
     93  const char* nativePath = env->GetStringUTFChars(javaPath, 0);
     94  const char* nativeFileName = env->GetStringUTFChars(javaFileName, 0);
     95  ((RpLibrary*)libPtr)->putFile(nativePath, nativeFileName, compress, append);
     96  env->ReleaseStringUTFChars(javaPath, nativePath);
     97  env->ReleaseStringUTFChars(javaFileName, nativeFileName);
     98}
    7899
    79100// result
Note: See TracChangeset for help on using the changeset viewer.