in freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/datasource/DataSourcesSupplier.java [124:149]
private static DataSource fromFile(
NamedUri sourceUri,
String name,
String group,
File file,
Charset charset,
Map<String, String> properties) {
Validate.isTrue(file.exists(), "File not found: " + file);
final FileDataSource dataSource = new FileDataSource(file);
// content type is determined from file extension
dataSource.setFileTypeMap(MimetypesFileTypeMapFactory.create());
final String relativePath = FileUtils.getRelativePath(sourceUri.getFile(), file);
final String contentType = dataSource.getContentType();
return DataSource.builder()
.name(name)
.group(group)
.uri(file.toURI())
.dataSource(dataSource)
.relativeFilePath(relativePath)
.contentType(contentType)
.charset(charset)
.properties(properties)
.build();
}