ossia / libossia

A modern C++, cross-environment distributed object model for creative coding and interaction scoring
https://ossia.io
GNU Lesser General Public License v3.0
204 stars 33 forks source link

[ossia-max] trouble writing and reading cue files with ossia.cue #823

Open evanmtp opened 1 year ago

evanmtp commented 1 year ago

Currently the most pressing issue I'm facing is that it seems to not be possible to read files into ossia.cue. In the attached patch, sending the "read" message opens a dialog box that prompts you to save a file rather than opening one. This can be tested using the attached cue file (cues.json) which was generated via a write message to ossia.cue.

Yesterday while testing, I was able to read a json file that I had written via a write message to ossia.cue. I got an error complaining about malformed JSON. Unfortunately I'm not able to reproduce it at the moment.

Also worth mentioning - currently it seems like the "write path/to/file.txt" message doesn't work with relative paths, e.g. "write ~/Desktop/cues.json".

ossia.cue_write_read_bug.zip

jcelerier commented 1 year ago

Also worth mentioning - currently it seems like the "write path/to/file.txt" message doesn't work with relative paths, e.g. "write ~/Desktop/cues.json".

this should be fixed, but note that " ~/Desktop/cues.json" is actually an absolute path, equivalent to "/Users/foo/Desktop/cues.json" - the reason it didn't work is because converting "~" in "/Users/foo" is done by the shell (bash, zsh etc), from actual programming languages this has to be implemented by hand (which i did).

evanmtp commented 1 year ago

Just tested on macOS 10.14.6, using ossia version 331f9b4d4 (the build you sent via WeTransfer last night. When sending a write message, the dialog box now correctly shows Open rather than Save. Opening .txt files works fine, and presets are recalled correctly.

One ongoing issue is that the Open dialog box doesn't allow you to select files with the extension .json or .cue (though it does allow selection of .txt and .xml). This seems a bit weird because when you send the write message, the default filename in the Save dialog box is cues.cue.

Screen Shot 2023-02-09 at 1 28 00 PM
evanmtp commented 1 year ago

this should be fixed, but note that " /Desktop/cues.json" is actually an absolute path, equivalent to "/Users/foo/Desktop/cues.json" - the reason it didn't work is because converting "" in "/Users/foo" is done by the shell (bash, zsh etc), from actual programming languages this has to be implemented by hand (which i did).

Got it, thanks. I verified just now that paths using ~, i.e. read ~/Desktop/cues.txt, work. Paths using . and .. (i.e. read ./cues.txt, read ../cues.txt) seem to not, however. This isn't a priority for anything I'm doing at the moment, but seems like a nice-to-have.

jcelerier commented 1 year ago

ah yes, those are also shell things... let me implement it. It shold work with "plain" relative paths though, e.g. read path/to/cues.txt and use the path to the patcher as root reference

For allowing any custom filenames I don't know how to do it... the max api seems to only allow "text" files? i'll investigate