touch variant that doesn't set last modified time

This commit is contained in:
Mark Harrah 2011-05-18 07:56:58 -04:00
parent c534b8c289
commit 0c572bc4aa
2 changed files with 4 additions and 4 deletions

View File

@ -86,7 +86,7 @@ object Streams
def make[T <: Closeable](a: Key, sid: String)(f: File => T): T = synchronized {
checkOpen()
val file = taskDirectory(a) / sid
IO.touch(file)
IO.touch(file, false)
val t = f( file )
opened ::= t
t

View File

@ -70,15 +70,15 @@ object IO
(name, "")
}
def touch(files: Traversable[File]): Unit = files.foreach(touch)
def touch(files: Traversable[File]): Unit = files.foreach(f => touch(f))
/** Creates a file at the given location.*/
def touch(file: File)
def touch(file: File, setModified: Boolean = true)
{
createDirectory(file.getParentFile)
val created = translate("Could not create file " + file) { file.createNewFile() }
if(created || file.isDirectory)
()
else if(!file.setLastModified(System.currentTimeMillis))
else if(setModified && !file.setLastModified(System.currentTimeMillis))
error("Could not update last modified time for file " + file)
}
def createDirectories(dirs: Traversable[File]): Unit =