mirror of
https://github.com/corda/corda.git
synced 2025-06-05 17:01:45 +00:00
implement java.io.File.renameTo
This commit is contained in:
parent
fb40b046fd
commit
447741d6ec
@ -355,6 +355,27 @@ Java_java_io_File_delete(JNIEnv* e, jclass, jstring path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT jboolean JNICALL
|
||||||
|
Java_java_io_File_rename(JNIEnv* e, jclass, jstring old, jstring new_)
|
||||||
|
{
|
||||||
|
const char* oldChars = e->GetStringUTFChars(old, 0);
|
||||||
|
const char* newChars = e->GetStringUTFChars(new_, 0);
|
||||||
|
if (oldChars) {
|
||||||
|
bool v;
|
||||||
|
if (newChars) {
|
||||||
|
v = rename(oldChars, newChars) == 0;
|
||||||
|
|
||||||
|
e->ReleaseStringUTFChars(new_, newChars);
|
||||||
|
} else {
|
||||||
|
v = false;
|
||||||
|
}
|
||||||
|
e->ReleaseStringUTFChars(old, oldChars);
|
||||||
|
return v;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" JNIEXPORT jboolean JNICALL
|
extern "C" JNIEXPORT jboolean JNICALL
|
||||||
Java_java_io_File_isDirectory(JNIEnv* e, jclass, jstring path)
|
Java_java_io_File_isDirectory(JNIEnv* e, jclass, jstring path)
|
||||||
{
|
{
|
||||||
|
@ -35,6 +35,12 @@ public class File {
|
|||||||
this(parent.getPath() + FileSeparator + child);
|
this(parent.getPath() + FileSeparator + child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static native boolean rename(String old, String new_);
|
||||||
|
|
||||||
|
public boolean renameTo(File newName) {
|
||||||
|
return rename(path, newName.path);
|
||||||
|
}
|
||||||
|
|
||||||
private static native boolean isDirectory(String path);
|
private static native boolean isDirectory(String path);
|
||||||
|
|
||||||
public boolean isDirectory() {
|
public boolean isDirectory() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user