supercollider / supercollider

An audio server, programming language, and IDE for sound synthesis and algorithmic composition.
http://supercollider.github.io
GNU General Public License v3.0
5.49k stars 747 forks source link

Quarks: failure to recognize valid absolute path (Windows v3.9.0-beta1) #3327

Closed totalgee closed 6 years ago

totalgee commented 6 years ago

I was trying to register a local Quark via code. (Works fine on Mac.) The Quark is defined in a subdirectory of the currently-executing file. The code does this:

Quarks.install("myQuark".resolveRelative);

(obviously, it should also work with just Quarks.install("myQuark") if "myQuark" is not a registered Quark name, but in the end it performs the equivalent of resolveRelative to try to locate the Quark -- so you get the same failure in both cases)

This produces an error, because String.resolveRelative produces, on Windows, a path with forward slashes -- which should be fine... (Indeed "myQuark".resolveRelative.openOS correctly opens a File Explorer with the sub-directory path.)

An example... Assuming the running SC file is in C:\Users\me\Documents\project, then "myQuark".resolveRelative from there returns: C:/Users/me/Documents/project\myQuark.

If we call Quarks.asAbsolutePath("myQuark".resolveRelative) on that result (which is what Quarks.install("myQuark") does), there are no regex matches, so instead it concatenates the current path with the passed path (which already is absolute), and it returns this mess:

C:/Users/me/Documents/project\C:/Users/me/Documents/project\myQuark

And of course it can't install the Quark from that path!

totalgee commented 6 years ago

There is a simple solution to this (I think); just fix the regex used by Quarks.findAbsolutePath. The Windows case for Quarks.regex.isAbsolutePath should be changed from

isAbsolutePath: "^[A-Za-z]:\\\\" to isAbsolutePath: "^[A-Za-z]:(?:\\\\|/)"

i.e. Allow back- or forward-slashes at the start of an absolute path, after the drive letter.

totalgee commented 6 years ago

Workaround for now:

Quarks.install("myQuark".resolveRelative.tr($/, Platform.pathSeparator))

mossheim commented 6 years ago

Fixed in #3328. Thanks again!