mirror of
https://github.com/corda/corda.git
synced 2025-06-23 01:19:00 +00:00
skip "." and ".." in File.list{Files} to match Sun
This commit is contained in:
@ -452,11 +452,17 @@ Java_java_io_File_readDir(JNIEnv* e, jclass, jlong handle)
|
|||||||
{
|
{
|
||||||
Directory* d = reinterpret_cast<Directory*>(handle);
|
Directory* d = reinterpret_cast<Directory*>(handle);
|
||||||
|
|
||||||
const char* s = d->next();
|
while (true) {
|
||||||
if (s) {
|
const char* s = d->next();
|
||||||
return e->NewStringUTF(s);
|
if (s) {
|
||||||
} else {
|
if (strcmp(s, ".") == 0 || strcmp(s, "..") == 0) {
|
||||||
return 0;
|
// skip . or .. and try again
|
||||||
|
} else {
|
||||||
|
return e->NewStringUTF(s);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,13 +491,20 @@ extern "C" JNIEXPORT jstring JNICALL
|
|||||||
Java_java_io_File_readDir(JNIEnv* e, jclass, jlong handle)
|
Java_java_io_File_readDir(JNIEnv* e, jclass, jlong handle)
|
||||||
{
|
{
|
||||||
struct dirent * directoryEntry;
|
struct dirent * directoryEntry;
|
||||||
|
|
||||||
if (handle!=0) {
|
if (handle!=0) {
|
||||||
directoryEntry = readdir(reinterpret_cast<DIR*>(handle));
|
while (true) {
|
||||||
if (directoryEntry == NULL) {
|
directoryEntry = readdir(reinterpret_cast<DIR*>(handle));
|
||||||
return NULL;
|
if (directoryEntry == NULL) {
|
||||||
|
return NULL;
|
||||||
|
} else if (strcmp(directoryEntry->d_name, ".") == 0
|
||||||
|
|| strcmp(directoryEntry->d_name, "..") == 0)
|
||||||
|
{
|
||||||
|
// skip . or .. and try again
|
||||||
|
} else {
|
||||||
|
return e->NewStringUTF(directoryEntry->d_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return e->NewStringUTF(directoryEntry->d_name);
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user