Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation warning cleanup, including removal of deprecated octal literals. #578

Merged
merged 1 commit into from
May 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"
}
}