Add syncPaths method to FileUtilities for arbitrary sources (not just a directory)

git-svn-id: https://simple-build-tool.googlecode.com/svn/trunk@934 d89573ee-9141-11dd-94d4-bdf5e562f29c
This commit is contained in:
dmharrah 2009-08-02 01:09:16 +00:00
parent 28061254b0
commit e3517c7a6f
1 changed files with 3 additions and 1 deletions

View File

@ -544,8 +544,10 @@ object FileUtilities
/** Synchronizes the contents of the <code>sourceDirectory</code> directory to the /** Synchronizes the contents of the <code>sourceDirectory</code> directory to the
* <code>targetDirectory</code> directory.*/ * <code>targetDirectory</code> directory.*/
def sync(sourceDirectory: Path, targetDirectory: Path, log: Logger): Option[String] = def sync(sourceDirectory: Path, targetDirectory: Path, log: Logger): Option[String] =
syncPaths((sourceDirectory ##) ** AllPassFilter, targetDirectory, log)
def syncPaths(sources: PathFinder, targetDirectory: Path, log: Logger): Option[String] =
{ {
copy(((sourceDirectory ##) ** AllPassFilter).get, targetDirectory, log).right.flatMap copy(sources.get, targetDirectory, log).right.flatMap
{ copiedTo => prune(targetDirectory, copiedTo, log).toLeft(()) }.left.toOption { copiedTo => prune(targetDirectory, copiedTo, log).toLeft(()) }.left.toOption
} }
def prune(directory: Path, keepOnly: Iterable[Path], log: Logger): Option[String] = def prune(directory: Path, keepOnly: Iterable[Path], log: Logger): Option[String] =