synchronized (fs)
{
// VFS-210
if (!fs.hasCapability(Capability.LIST_CHILDREN))
{
throw new FileNotFolderException(fileName);
}
/* VFS-210
if (!getType().hasChildren())
{
throw new FileSystemException("vfs.provider/list-children-not-folder.error", name);
}
*/
attach();
// Use cached info, if present
if (children != null)
{
return resolveFiles(children);
}
// allow the filesystem to return resolved children. e.g. prefill type for webdav
FileObject[] childrenObjects;
try
{
childrenObjects = doListChildrenResolved();
children = extractNames(childrenObjects);
}
catch (final FileSystemException exc)
{
// VFS-210
throw exc;
}
catch (final Exception exc)
{
throw new FileSystemException("vfs.provider/list-children.error", exc, fileName);
}
if (childrenObjects != null)
{
return childrenObjects;
}
// List the children
final String[] files;
try
{
files = doListChildren();
}
catch (final FileSystemException exc)
{
// VFS-210
throw exc;
}
catch (final Exception exc)
{
throw new FileSystemException("vfs.provider/list-children.error", exc, fileName);
}
if (files == null)
{
// VFS-210
// honor the new doListChildren contract
// return null;
throw new FileNotFolderException(fileName);
}
else if (files.length == 0)
{
// No children
children = EMPTY_FILE_ARRAY;