Skip to content

Commit

Permalink
Merge pull request #105 from cunei/wip-milli4
Browse files Browse the repository at this point in the history
Cherry-pick "Don't import IO.getModifiedTime"
  • Loading branch information
eed3si9n authored Dec 15, 2017
2 parents 2460fc9 + af98bc8 commit 778a277
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
9 changes: 4 additions & 5 deletions io/src/main/scala/sbt/internal/io/Resources.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
package sbt.internal.io

import java.io.File
import sbt.io.IO._
import Resources.error
import sbt.io.IO

private[sbt] object Resources {
def apply(basePath: String) = {
Expand All @@ -14,7 +13,7 @@ private[sbt] object Resources {
if (resource == null)
error("Resource base directory '" + basePath + "' not on classpath.")
else {
val file = toFile(resource)
val file = IO.toFile(resource)
if (file.exists)
new Resources(file)
else
Expand Down Expand Up @@ -48,9 +47,9 @@ private[sbt] final class Resources(val baseDirectory: File) {
require(readOnly.isDirectory)
def readWrite(readOnly: File)(temporary: File): T = {
val readWriteDirectory = new File(temporary, readOnly.getName)
copyDirectory(readOnly, readWriteDirectory)
IO.copyDirectory(readOnly, readWriteDirectory)
withDirectory(readWriteDirectory)
}
withTemporaryDirectory(readWrite(readOnly))
IO.withTemporaryDirectory(readWrite(readOnly))
}
}
9 changes: 4 additions & 5 deletions io/src/main/scala/sbt/io/Path.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package sbt.io
import java.io.File
import java.net.URL
import scala.collection.mutable
import IO.{ wrapNull, getModifiedTime }
import java.nio.file.attribute._
import java.nio.file.{ Path => NioPath, LinkOption, FileSystem, Files }
import scala.collection.JavaConverters._
Expand All @@ -21,7 +20,7 @@ final class RichFile(val asFile: File) extends AnyVal with RichNioPath {
def isDirectory: Boolean = asFile.isDirectory

/** The last modified time of the wrapped file.*/
def lastModified: Long = getModifiedTime(asFile)
def lastModified: Long = IO.getModifiedTime(asFile)

/**
* True if and only if the wrapped file `asFile` exists and the file 'other'
Expand Down Expand Up @@ -278,7 +277,7 @@ object Path extends Mapper {
separated.mkString(sep)
}
def newerThan(a: File, b: File): Boolean =
a.exists && (!b.exists || getModifiedTime(a) > getModifiedTime(b))
a.exists && (!b.exists || IO.getModifiedTime(a) > IO.getModifiedTime(b))

/** The separator character of the platform.*/
val sep: Char = java.io.File.separatorChar
Expand Down Expand Up @@ -426,7 +425,7 @@ private abstract class FilterFiles extends PathFinder with FileFilter {
final def accept(file: File) = filter.accept(file)

protected def handleFile(file: File, fileSet: mutable.Set[File]): Unit =
for (matchedFile <- wrapNull(file.listFiles(this)))
for (matchedFile <- IO.wrapNull(file.listFiles(this)))
fileSet += new File(file, matchedFile.getName)
}

Expand All @@ -441,7 +440,7 @@ private class DescendantOrSelfPathFinder(val parent: PathFinder, val filter: Fil

private def handleFileDescendant(file: File, fileSet: mutable.Set[File]): Unit = {
handleFile(file, fileSet)
for (childDirectory <- wrapNull(file listFiles DirectoryFilter))
for (childDirectory <- IO.wrapNull(file listFiles DirectoryFilter))
handleFileDescendant(new File(file, childDirectory.getName), fileSet)
}
}
Expand Down
3 changes: 1 addition & 2 deletions io/src/main/scala/sbt/io/PollingWatchService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import java.util.{ List => JList }
import sbt.io.syntax._
import scala.collection.mutable
import scala.concurrent.duration.{ Duration, FiniteDuration }
import IO.getModifiedTime

/** A `WatchService` that polls the filesystem every `delay`. */
class PollingWatchService(delay: FiniteDuration) extends WatchService {
Expand Down Expand Up @@ -94,7 +93,7 @@ class PollingWatchService(delay: FiniteDuration) extends WatchService {
watched.toSeq.sortBy(_._1)(pathLengthOrdering).foreach {
case (p, _) =>
if (!results.contains(p))
p.toFile.allPaths.get.foreach(f => results += f.toPath -> getModifiedTime(f))
p.toFile.allPaths.get.foreach(f => results += f.toPath -> IO.getModifiedTime(f))
}
results.toMap
}
Expand Down

0 comments on commit 778a277

Please sign in to comment.