mirror of
https://github.com/corda/corda.git
synced 2025-01-19 03:06:36 +00:00
add File.canRead()/File.canWrite() implementation
This commit is contained in:
parent
7376425b24
commit
6752505cb8
@ -377,6 +377,31 @@ Java_java_io_File_delete(JNIEnv* e, jclass, jstring path)
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_java_io_File_canRead(JNIEnv* e, jclass, jstring path)
|
||||
{
|
||||
string_t chars = getChars(e, path);
|
||||
if (chars) {
|
||||
int r = access(chars, R_OK);
|
||||
releaseChars(e, path, chars);
|
||||
return (r == 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_java_io_File_canWrite(JNIEnv* e, jclass, jstring path)
|
||||
{
|
||||
string_t chars = getChars(e, path);
|
||||
if (chars) {
|
||||
int r = access(chars, W_OK);
|
||||
releaseChars(e, path, chars);
|
||||
return (r == 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_java_io_File_rename(JNIEnv* e, jclass, jstring old, jstring new_)
|
||||
{
|
||||
|
@ -60,7 +60,19 @@ public class File {
|
||||
public boolean isFile() {
|
||||
return isFile(path);
|
||||
}
|
||||
|
||||
private static native boolean canRead(String path);
|
||||
|
||||
public boolean canRead() {
|
||||
return canRead(path);
|
||||
}
|
||||
|
||||
private static native boolean canWrite(String path);
|
||||
|
||||
public boolean canWrite() {
|
||||
return canWrite(path);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
int index = path.lastIndexOf(FileSeparator);
|
||||
if (index >= 0) {
|
||||
|
@ -1,3 +1,4 @@
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.File;
|
||||
|
Loading…
Reference in New Issue
Block a user