mirror of
https://github.com/corda/corda.git
synced 2025-01-19 11:16:54 +00:00
skip "." and ".." in File.list{Files} to match Sun
This commit is contained in:
parent
585dba004b
commit
b1a1391093
@ -452,11 +452,17 @@ Java_java_io_File_readDir(JNIEnv* e, jclass, jlong handle)
|
||||
{
|
||||
Directory* d = reinterpret_cast<Directory*>(handle);
|
||||
|
||||
const char* s = d->next();
|
||||
if (s) {
|
||||
return e->NewStringUTF(s);
|
||||
} else {
|
||||
return 0;
|
||||
while (true) {
|
||||
const char* s = d->next();
|
||||
if (s) {
|
||||
if (strcmp(s, ".") == 0 || strcmp(s, "..") == 0) {
|
||||
// skip . or .. and try again
|
||||
} else {
|
||||
return e->NewStringUTF(s);
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -487,11 +493,18 @@ Java_java_io_File_readDir(JNIEnv* e, jclass, jlong handle)
|
||||
struct dirent * directoryEntry;
|
||||
|
||||
if (handle!=0) {
|
||||
directoryEntry = readdir(reinterpret_cast<DIR*>(handle));
|
||||
if (directoryEntry == NULL) {
|
||||
return NULL;
|
||||
while (true) {
|
||||
directoryEntry = readdir(reinterpret_cast<DIR*>(handle));
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user