mirror of
https://github.com/corda/corda.git
synced 2025-01-19 11:16:54 +00:00
implement File.getAbsolutePath()/File.getAbsoluteFile() on Unix platforms
This commit is contained in:
parent
7ed580cf84
commit
3d7c65d314
@ -314,10 +314,29 @@ Java_java_io_File_toCanonicalPath(JNIEnv* /*e*/, jclass, jstring path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" JNIEXPORT jstring JNICALL
|
extern "C" JNIEXPORT jstring JNICALL
|
||||||
Java_java_io_File_toAbsolutePath(JNIEnv* /*e*/, jclass, jstring path)
|
Java_java_io_File_toAbsolutePath(JNIEnv* e, jclass, jstring path)
|
||||||
{
|
{
|
||||||
|
#ifdef PLATFORM_WINDOWS
|
||||||
// todo
|
// todo
|
||||||
return path;
|
return path;
|
||||||
|
#else
|
||||||
|
jstring result = path;
|
||||||
|
string_t chars = getChars(e, path);
|
||||||
|
if (chars) {
|
||||||
|
if (chars[0] != '/') {
|
||||||
|
char* cwd = getcwd(NULL, 0);
|
||||||
|
if (cwd) {
|
||||||
|
unsigned size = strlen(cwd) + strlen(chars) + 2;
|
||||||
|
RUNTIME_ARRAY(char, buffer, size);
|
||||||
|
snprintf(RUNTIME_ARRAY_BODY(buffer), size, "%s/%s", cwd, chars);
|
||||||
|
result = e->NewStringUTF(RUNTIME_ARRAY_BODY(buffer));
|
||||||
|
free(cwd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
releaseChars(e, path, chars);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" JNIEXPORT jlong JNICALL
|
extern "C" JNIEXPORT jlong JNICALL
|
||||||
|
@ -120,6 +120,10 @@ public class File implements Serializable {
|
|||||||
return toAbsolutePath(path);
|
return toAbsolutePath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public File getAbsoluteFile() {
|
||||||
|
return new File(getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
private static native long length(String path);
|
private static native long length(String path);
|
||||||
|
|
||||||
public long length() {
|
public long length() {
|
||||||
|
Loading…
Reference in New Issue
Block a user