isWithinOutputPath function

bool isWithinOutputPath(
  1. String outputDir,
  2. String filePath
)

Ensure filePath is contained in the outputDir folder, to make sure archives aren't trying to write to some system path.

Implementation

bool isWithinOutputPath(String outputDir, String filePath) {
  return path.isWithin(
      path.canonicalize(outputDir), path.canonicalize(filePath));
}