Skip to content

Commit

Permalink
Merge pull request #578 from metasim/metasim/deprecation-cleanup
Browse files Browse the repository at this point in the history
Compilation warning cleanup, including removal of deprecated octal literals.
  • Loading branch information
muuki88 committed May 8, 2015
2 parents acaf389 + 34cbfca commit 35a3e3b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/main/scala/com/typesafe/sbt/packager/FileUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,10 @@ object permissions {
case 6 => "rw-"
case 7 => "rwx"
}
}

/** Enriches string with `oct` interpolator, parsing string as base 8 integer. */
implicit class OctalString(val sc: StringContext) extends AnyVal {
def oct(args: Any*) = Integer.parseInt(sc.s(args: _*), 8)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ object ZipHelper {
* @param outputZip The location of the output file.
*/
def zip(sources: Traversable[(File, String)], outputZip: File): Unit = {
import permissions.OctalString
val mappings =
for {
(file, name) <- sources.toSeq
// TODO - Figure out if this is good enough....
perm = if (file.isDirectory || file.canExecute) 0755 else 0644
perm = if (file.isDirectory || file.canExecute) oct"0755" else oct"0644"
} yield FileMapping(file, name, Some(perm))
archive(mappings, outputZip)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ object WixHelper {
val name = simpleName(target)
val desc = "Edit configuration file: " + name
val cleanName = name.replaceAll("[\\.-\\\\//]+", "_")
<Shortcut Id={ id + "_SC" + (s"%0${targetSize}d").format(i+1) } Name={ cleanName } Description={ desc } Target={ "[INSTALLDIR]\\" + target.replaceAll("\\/", "\\\\") } WorkingDirectory="INSTALLDIR"/>
<Shortcut Id={ id + "_SC" + (s"%0${targetSize}d").format(i + 1) } Name={ cleanName } Description={ desc } Target={ "[INSTALLDIR]\\" + target.replaceAll("\\/", "\\\\") } WorkingDirectory="INSTALLDIR"/>
}
}
<RemoveFolder Id="ApplicationProgramsFolderRemove" Directory="ApplicationProgramsFolder" On="uninstall"/>
Expand Down Expand Up @@ -238,7 +238,7 @@ object WixHelper {
* @return A tuple where the first item is all the Component Ids created,
* and the second is the Directory/File/Component XML.
*/
@deprecated
@deprecated("Use higher level abstraction", "6/28/13")
def generateComponentsAndDirectoryXml(dir: File, id_prefix: String = ""): (Seq[String], scala.xml.Node) = {
def makeId(f: File) = cleanStringForId(IO.relativize(dir, f) map (id_prefix+) getOrElse (id_prefix + f.getName))
def handleFile(f: File): (Seq[String], scala.xml.Node) = {
Expand Down
14 changes: 12 additions & 2 deletions src/test/scala/com/typesafe/sbt/packager/FileUtilSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ class FileUtilSpec extends FlatSpec with Matchers {
val perm2 = permissions("0755")
perm2 should not be (empty)
perm2 should contain only (OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, GROUP_READ, GROUP_EXECUTE, OTHERS_READ, OTHERS_EXECUTE)

}

}
"oct" should "parse octal string and convert to an integer" taggedAs (LinuxTag, WindowsTag) in {
import permissions._
oct"0000" should equal (0)
oct"0" should equal (0)
oct"777" should equal (511)
oct"0777" should equal (511)
oct"070" should equal (56)
oct"123" should equal (83)

a [NumberFormatException] should be thrownBy oct"foobar"
}
}

0 comments on commit 35a3e3b

Please sign in to comment.