src/setup-bazelisk/src.main.kts [294:320]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - fun Path.getOrTemp(): Path { if (Files.notExists(this)) { try { Files.createDirectories(this) } catch (e: IOException) { return fallbackWithWarning(this, e) } } if (Files.isDirectory(this)) { try { Files.createTempFile(this, "write-test-", ".tmp").let { testFile -> Files.deleteIfExists(testFile) } return this } catch (e: IOException) { return fallbackWithWarning(this, e) } } return fallbackWithWarning(this, IOException("Not a directory")) } fun fallbackWithWarning(path: Path, cause: Exception): Path { val tmpDir = System.getProperty("java.io.tmpdir") ?: throw IllegalStateException("No 'java.io.tmpdir' defined", cause) writeWarning("Installation path '$path' is not writable, using '$tmpDir' (Switch to 'Verbose' log level to see stacktrace)") writeDebug(cause.stackTraceToString()) return Paths.get(tmpDir) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - src/setup-node/src.main.kts [286:312]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - fun Path.getOrTemp(): Path { if (Files.notExists(this)) { try { Files.createDirectories(this) } catch (e: IOException) { return fallbackWithWarning(this, e) } } if (Files.isDirectory(this)) { try { Files.createTempFile(this, "write-test-", ".tmp").let { testFile -> Files.deleteIfExists(testFile) } return this } catch (e: IOException) { return fallbackWithWarning(this, e) } } return fallbackWithWarning(this, IOException("Not a directory")) } fun fallbackWithWarning(path: Path, cause: Exception): Path { val tmpDir = System.getProperty("java.io.tmpdir") ?: throw IllegalStateException("No 'java.io.tmpdir' defined", cause) writeWarning("Installation path '$path' is not writable, using '$tmpDir' (Switch to 'Verbose' log level to see stacktrace)") writeDebug(cause.stackTraceToString()) return Paths.get(tmpDir) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -