mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
fix misuse of FindFirstFile
This commit is contained in:
parent
6519047342
commit
e47c149fb1
@ -405,14 +405,21 @@ Java_java_io_File_openDir(JNIEnv* e, jclass, jstring path)
|
|||||||
{
|
{
|
||||||
const char* chars = e->GetStringUTFChars(path, 0);
|
const char* chars = e->GetStringUTFChars(path, 0);
|
||||||
if (chars) {
|
if (chars) {
|
||||||
|
unsigned length = strlen(chars);
|
||||||
|
|
||||||
|
RUNTIME_ARRAY(char, buffer, length + 3);
|
||||||
|
memcpy(RUNTIME_ARRAY_BODY(buffer), chars, length);
|
||||||
|
memcpy(RUNTIME_ARRAY_BODY(buffer) + length, "\\*", 3);
|
||||||
|
|
||||||
|
e->ReleaseStringUTFChars(path, chars);
|
||||||
|
|
||||||
Directory* d = new (malloc(sizeof(Directory))) Directory;
|
Directory* d = new (malloc(sizeof(Directory))) Directory;
|
||||||
d->handle = FindFirstFile(chars, &(d->data));
|
d->handle = FindFirstFile(buffer, &(d->data));
|
||||||
if (d->handle == INVALID_HANDLE_VALUE) {
|
if (d->handle == INVALID_HANDLE_VALUE) {
|
||||||
d->dispose();
|
d->dispose();
|
||||||
d = 0;
|
d = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
e->ReleaseStringUTFChars(path, chars);
|
|
||||||
return reinterpret_cast<jlong>(d);
|
return reinterpret_cast<jlong>(d);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -678,8 +678,13 @@ class MySystem: public System {
|
|||||||
virtual Status open(System::Directory** directory, const char* name) {
|
virtual Status open(System::Directory** directory, const char* name) {
|
||||||
Status status = 1;
|
Status status = 1;
|
||||||
|
|
||||||
|
unsigned length = strlen(name);
|
||||||
|
RUNTIME_ARRAY(char, buffer, length + 3);
|
||||||
|
memcpy(RUNTIME_ARRAY_BODY(buffer), name, length);
|
||||||
|
memcpy(RUNTIME_ARRAY_BODY(buffer) + length, "\\*", 3);
|
||||||
|
|
||||||
Directory* d = new (allocate(this, sizeof(Directory))) Directory(this);
|
Directory* d = new (allocate(this, sizeof(Directory))) Directory(this);
|
||||||
d->handle = FindFirstFile(name, &(d->data));
|
d->handle = FindFirstFile(RUNTIME_ARRAY_BODY(buffer), &(d->data));
|
||||||
if (d->handle == INVALID_HANDLE_VALUE) {
|
if (d->handle == INVALID_HANDLE_VALUE) {
|
||||||
d->dispose();
|
d->dispose();
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user