// Path: src/main/java/de/neuland/jade4j/exceptions/JadeTemplateLoaderException.java
// public class JadeTemplateLoaderException extends JadeException {
//     public JadeTemplateLoaderException(String message) {
//         super(message);
//     }
// }


import de.neuland.jade4j.exceptions.JadeTemplateLoaderException;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;

	public FileTemplateLoader(String folderPath, String encoding, String extension) {
		validateFolderPath(folderPath);
		this.encoding = encoding;
		this.folderPath = folderPath;
		this.extension = extension;
	}

	private void validateFolderPath(String folderPath) {
		if(StringUtils.isNotEmpty(folderPath)) {
            File file = new File(folderPath);
            if (!file.exists() || !file.isDirectory()) {
                throw new IllegalArgumentException("The folder path '" + folderPath + "' does not exist");
            }
        }
	}

	public long getLastModified(String name) {
		File templateSource = getFile(name);
		return templateSource.lastModified();
	}

	@Override
	public Reader getReader(String name) throws IOException {
		File templateSource = getFile(name);
		return new InputStreamReader(new FileInputStream(templateSource), encoding);
	}

	private File getFile(String name) {
		if(name.startsWith("../")){
// Path: src/main/java/de/neuland/jade4j/exceptions/JadeTemplateLoaderException.java
// public class JadeTemplateLoaderException extends JadeException {
//     public JadeTemplateLoaderException(String message) {
//         super(message);
//     }
// }


// Path: src/main/java/de/neuland/jade4j/template/FileTemplateLoader.java
import de.neuland.jade4j.exceptions.JadeTemplateLoaderException;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;


	public FileTemplateLoader(String folderPath, String encoding, String extension) {
		validateFolderPath(folderPath);
		this.encoding = encoding;
		this.folderPath = folderPath;
		this.extension = extension;
	}

	private void validateFolderPath(String folderPath) {
		if(StringUtils.isNotEmpty(folderPath)) {
            File file = new File(folderPath);
            if (!file.exists() || !file.isDirectory()) {
                throw new IllegalArgumentException("The folder path '" + folderPath + "' does not exist");
            }
        }
	}

	public long getLastModified(String name) {
		File templateSource = getFile(name);
		return templateSource.lastModified();
	}

	@Override
	public Reader getReader(String name) throws IOException {
		File templateSource = getFile(name);
		return new InputStreamReader(new FileInputStream(templateSource), encoding);
	}

	private File getFile(String name) {
		if(name.startsWith("../")){
			throw new JadeTemplateLoaderException("relative Path is not allowed");