I did end up exposing the working directory as an array of strings as planned. However, I found the syntax for exposing that array directly to be ugly and awkward and confusing and cumbersome, so I opted for a pair of methods,
org.icongarden.fileSystem.getWorkingDirectory and
org.icongarden.fileSystem.setWorkingDirectory. If the first array element is empty, it means the array represents an absolute ("full") path; I expect to use this convention elsewhere within this particular extension.
getWorkingDirectory always returns an absolute path, but you can pass a relative path to
setWorkingDirectory and it will figure out the right thing to do. Neither of these functions handles duplicate slashes or "..", since they are unneeded; these conventions result from storing paths as strings (which is wrong, in my view). I'll probably end up having to deal with these cases eventually anyway for the sake of compatibility.
No comments:
Post a Comment