// Path: src/main/java/com/danielflower/apprunner/FileSandbox.java
// public static String fullPath(File file) {
//     try {
//         return file.getCanonicalPath();
//     } catch (IOException e) {
//         return file.getAbsolutePath();
//     }
// }


import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import java.io.File;
import java.io.IOException;
import java.util.UUID;
import static com.danielflower.apprunner.FileSandbox.fullPath;
import static org.apache.commons.io.FilenameUtils.separatorsToSystem;
package scaffolding;




public class Photocopier {

    public static File sampleDir() {
        return new File(separatorsToSystem("sample-apps"));
    }

    public static File copySampleAppToTempDir(String sampleAppName) throws IOException {
        File target = folderForSampleProject(sampleAppName);
        copySampleAppToDir(sampleAppName, target);
        return target;
    }

    public static void copySampleAppToDir(String sampleAppName, File target) throws IOException {
        String pathname = FilenameUtils.concat(fullPath(sampleDir()), sampleAppName);
        File source = new File(pathname);
        if (!source.isDirectory()) {
            source = new File(separatorsToSystem("../") + pathname);
        }
        if (!source.isDirectory()) {
// Path: src/main/java/com/danielflower/apprunner/FileSandbox.java
// public static String fullPath(File file) {
//     try {
//         return file.getCanonicalPath();
//     } catch (IOException e) {
//         return file.getAbsolutePath();
//     }
// }


// Path: src/test/java/scaffolding/Photocopier.java
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import java.io.File;
import java.io.IOException;
import java.util.UUID;
import static com.danielflower.apprunner.FileSandbox.fullPath;
import static org.apache.commons.io.FilenameUtils.separatorsToSystem;

package scaffolding;




public class Photocopier {

    public static File sampleDir() {
        return new File(separatorsToSystem("sample-apps"));
    }

    public static File copySampleAppToTempDir(String sampleAppName) throws IOException {
        File target = folderForSampleProject(sampleAppName);
        copySampleAppToDir(sampleAppName, target);
        return target;
    }

    public static void copySampleAppToDir(String sampleAppName, File target) throws IOException {
        String pathname = FilenameUtils.concat(fullPath(sampleDir()), sampleAppName);
        File source = new File(pathname);
        if (!source.isDirectory()) {
            source = new File(separatorsToSystem("../") + pathname);
        }
        if (!source.isDirectory()) {
            throw new RuntimeException("Could not find module " + sampleAppName + " at " + new File(pathname) + " nor " + fullPath(source));