From 9fe8b7636e205aea2dbd710df805d387956dcedb Mon Sep 17 00:00:00 2001 From: Claudine Date: Thu, 28 Nov 2024 22:51:41 +0000 Subject: [PATCH] fix: add support for older os version sketchbook location --- build.gradle.kts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 79eafb3..2b7a0f3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -50,15 +50,28 @@ version = "1.0.0" // Depending on your OS, the code below should set the correct location, if you are using a Mac, // Windows, or Linux machine. // If you run the Gradle task deployToProcessingSketchbook, and you do not see your library -// in the contributions manager, then one possible cause could be the sketchbook location +// listed as a contributed library, then one possible cause could be the sketchbook location // is wrong. You can check the sketchbook location in your Processing application preferences. var sketchbookLocation = "" val userHome = System.getProperty("user.home") val currentOS = OperatingSystem.current() if(currentOS.isMacOsX) { - sketchbookLocation = "$userHome/Documents/Processing/sketchbook" + sketchbookLocation = if (File("$userHome/Documents/Processing/sketchbook").isDirectory) { + "$userHome/Documents/Processing/sketchbook" + } else { + "$userHome/Documents/Processing" + } } else if(currentOS.isWindows) { - sketchbookLocation = "$userHome/My Documents/Processing/sketchbook" + val docsFolder = if (File("$userHome/My Documents").isDirectory) { + "$userHome/My Documents" + } else { + "$userHome/Documents" + } + sketchbookLocation = if (File(docsFolder,"Processing/sketchbook").isDirectory) { + "$docsFolder/Processing/sketchbook" + } else { + "$docsFolder/Processing" + } } else { sketchbookLocation = "$userHome/sketchbook" }