Ignore:
Timestamp:
May 1, 2018 3:15:44 AM (2 years ago)
Author:
meeh <meeh@…>
Branches:
master
Children:
975d8a0
Parents:
a3a8ee1
Message:

Improved code documentation and readableness in form of syntax cleanup.

Location:
launchers/common/src/main/scala/net/i2p/launchers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • launchers/common/src/main/scala/net/i2p/launchers/DeployProfile.scala

    ra3a8ee1 r2d15f8e1  
    44
    55
     6/**
     7  *
     8  * This is a singleton ish style. It's an object - it was never a class.
     9  * However it has a class-"brother/sister"
     10  *
     11  * objects like this should be considered like containers for java's
     12  * public static methods.
     13  *
     14  * Many classes/objects benefits from pathJoin, so therefore it's defined
     15  * as an "public static method".
     16  *
     17  * @since 0.9.35
     18  */
    619object DeployProfile {
    720
  • launchers/common/src/main/scala/net/i2p/launchers/OSXDeployment.scala

    ra3a8ee1 r2d15f8e1  
    158158
    159159  /**
     160    * Please note that in Scala, the constructor body is same as class body.
     161    * What's defined outside of methods is considered constructor code and
     162    * executed as it.
     163    *
     164    *
     165    *
    160166    * a map function work as a loop with some built in security
    161167    * for "null" objects.
     
    166172    * the match case is controlling the flow based upon which type of object it is.
    167173    */
    168   staticFilesFromResources.map { fd => fd.getContent match {
    169     case Left(is) => {
    170       // Write file
    171       if (!new File(DeployProfile.pathJoin(baseDir, fd.getPath)).exists()) {
    172         println(s"copyBaseFileResToDisk(${fd.getPath})")
    173         try {
    174           copyBaseFileResToDisk(fd.getPath, is)
    175         } catch {
    176           case ex:IOException => println(s"Error! Exception ${ex}")
     174  staticFilesFromResources.map {
     175    fd => fd.getContent match {
     176        // Case subject is a file/resource
     177      case Left(is) => {
     178        // Write file
     179        if (!new File(DeployProfile.pathJoin(baseDir, fd.getPath)).exists()) {
     180          println(s"copyBaseFileResToDisk(${fd.getPath})")
     181          try {
     182            copyBaseFileResToDisk(fd.getPath, is)
     183          } catch {
     184            case ex:IOException => println(s"Error! Exception ${ex}")
     185          }
    177186        }
    178187      }
     188        // Case subject is a directory
     189      case Right(dir) => {
     190        // Ensure directory
     191        println(s"Directory(${fd.getPath})")
     192        if (!new File(DeployProfile.pathJoin(baseDir,fd.getPath)).exists()) {
     193          new File(DeployProfile.pathJoin(baseDir,fd.getPath)).mkdirs()
     194        }
     195        dir.map { f => createFileOrDirectory(f,fd.filesIsDirectories) }
     196      }
    179197    }
    180     case Right(dir) => {
    181       // Ensure directory
    182       println(s"Directory(${fd.getPath})")
    183       if (!new File(DeployProfile.pathJoin(baseDir,fd.getPath)).exists()) {
    184         new File(DeployProfile.pathJoin(baseDir,fd.getPath)).mkdirs()
    185       }
    186       dir.map { f => createFileOrDirectory(f,fd.filesIsDirectories) }
    187     }
    188   } }
     198  }
    189199
    190200}
Note: See TracChangeset for help on using the changeset viewer.