Skip to content

Commit

Permalink
(1) Fix absolute path resource loading on Windows (this also takes ca…
Browse files Browse the repository at this point in the history
…re of 'Beginner Challenges' not loading on Windows).

(2) Improve handling of included file names without a kojo extension.
  • Loading branch information
litan committed Oct 2, 2019
1 parent d48878d commit e0298d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/net/kogics/kojo/lite/Versions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package net.kogics.kojo.lite
object Versions {
val KojoMajorVersion = "2.7"
val KojoVersion = "2.7.07"
val KojoRevision = "r7"
val KojoBuildDate = "17 September 2019"
val KojoRevision = "r8"
val KojoBuildDate = "02 October 2019"
val JavaVersion = {
val jrv = System.getProperty("java.runtime.version")
val arch = System.getProperty("os.arch")
Expand Down
11 changes: 6 additions & 5 deletions src/main/scala/net/kogics/kojo/util/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -716,19 +716,20 @@ object Utils {
def countLines(s: String) = s.count(_ == '\n')
val includes = """//\s*#include.*""".r.findAllIn(code)
def getFileName(s: String) = """//\s*#include""".r.replaceFirstIn(s, "").trim
def expand(fileName: String) = {
val suffix = if (!fileName.contains(".")) ".kojo" else ""
absolutePath(fileName + suffix)
def addKojoExtension(fileName: String) = {
val justFileName = new File(fileName).getName
if (!justFileName.contains(".")) fileName + ".kojo" else fileName
}
def load(fileName0: String): String = {
val fileName = expand(fileName0)
val fileNameDotKojo = addKojoExtension(fileName0)
val fileName = absolutePath(fileNameDotKojo)
def readFileContent = {
val file = new File(fileName)
if (file.exists) {
stripCR(file.readAsString)
}
else {
val res = loadResource(fileName)
val res = loadResource(fileNameDotKojo)
if (res == null) {
file.readAsString // trigger exception
}
Expand Down

0 comments on commit e0298d7

Please sign in to comment.