throws IOException {
List<TOCReference> childTOCReferences = new ArrayList<TOCReference>();
processDirectory(rootDir, file, childTOCReferences, resources, inputEncoding);
if(! childTOCReferences.isEmpty()) {
String sectionName = file.getName().getBaseName();
Resource sectionResource = ResourceUtil.createResource(sectionName, VFSUtil.calculateHref(rootDir,file));
resources.add(sectionResource);
TOCReference section = new TOCReference(sectionName, sectionResource);
section.setChildren(childTOCReferences);
sections.add(section);
}