I found a solution by using the [str] objects in the mrpeach library. Using [str nsplit] and [str to_symbol] I was able to split my path at the point I needed to reach the parent directory.
It goes something like this:
[str nsplit -67] <--- number of characters to throw away
@LandonPD Hi Landon.. thanks for this. I've now looked at which and along with the other objects I've tried I haven't gotten very far.
I was thinking about using OSCroute to get the app path, given the paths are formatted the same as OSC address patterns, however the wildcard character isn't able to track back through the path the way I thought.
I was thinking this:
...or something similar.. but I've either got the syntax wrong or it can't do what I'd hoped. I don't think I can parse out an address pattern this way using OSC routing unless I know the rest of the address pattern.
At least I know that beneath the app the first directory is always /Contents. If I can somehow work up one step from there, or just get rid of everything up to and including this directory from the path then I can point the textfile object to read from there.
Are there any good string formatting/comparison objects I should look into?
Sorry I realise maybe I'm not being clear.
I have a directory, /My_directory, where my app and config file live:
In the app package, the patch lives here:
When getdir goes looking, it looks inside the /app-auto-load/my_patch.pd subdirectory. I'd like to point my patch to look in the parent directory, /My_directory
Hope this clears things up.
Thank you for your reply - I had already searched for path under help and come across the objects you mention.
Unfortunately getdir doesn't help in this situation as it gets the patch directory, not the application directory when the patch is built as an app.
I have looked into the path and classpath objects but it can't see how they will help for my needs. I need to find the parent directory of the application I've built, whereas these objects take paths as input and cycle through subdirectories.
Any other thoughts? I would bundle the config file into the package itself, however it needs to be accessible for editing by a script from within the app directory.
Hi all - I am building a standalone application using PD extended 0.43.4 on OS X, and I'm having trouble locating a file from within the 'app'.
In my patch I read a .txt file to [textfile]. My text file lives in the same directory as the patch.. so I don't need to give a path whilst using PD, but things go wrong when inside the app. I have a config.txt file that needs to be read from within the application directory itself.
I've used [getdir] to pass the patch directory to [textfile], but it turns out this won't do as [getdir] looks at the local directory of the patch that is bundled inside the application package (e.g. My_standalone.app/Contents/Resources/extra/app-auto-load/my_patch.pd), and not the directory where the application itself resides.
Is there a way to get the path of the application itself so I can pass this on to [textfile]?
Many thanks in advance,