Encode filepaths to be safe on Windows

This changes the file paths to use characters that are safe for Windows.

Channges the output of the following:
* Package cache directory
* Generated pkl-doc files
* Kotlin generated code

Unsafe characters are encoded as (<hex>).
For example, the colon character `:` is encoded as `(3a)`.

Additionally, this changes the cache directory prefix (package-1 to
package-2).

Follows the design of https://github.com/apple/pkl-evolution/pull/3
This commit is contained in:
Dan Chao authored and Daniel Chao committed 2024-05-13 14:06:28 -07:00
1 parent 110dc89e86
commit a5c13e325a
36 files changed
+185 -106

No files matched your search

@@ -51,7 +51,14 @@ class PackageServer : AutoCloseable {
const val FRUIT_1_1_SHA = "8d982761d182f2185e4180c82190791d9a60c721cb3393bb2e946fab90131e8c"
fun populateCacheDir(cacheDir: Path) {
val basePath = cacheDir.resolve("package-1/localhost:$PORT")
doPopulateCacheDir(cacheDir.resolve("package-2/localhost(3a)$PORT"))
}
fun populateLegacyCacheDir(cacheDir: Path) {
doPopulateCacheDir(cacheDir.resolve("package-1/localhost:$PORT"))
}
private fun doPopulateCacheDir(basePath: Path) {
basePath.deleteRecursively()
Files.walk(packagesDir).use { stream ->
stream.forEach { source ->