[PD] Best way to make file paths relative to the parent patch ?
Fede Camara Halac
camarafede at gmail.com
Sun Oct 8 04:55:10 CEST 2017
+1 on the need for vanilla path management (https://github.com/pure-data/pure-data/pull/150)
Like Seb, I also made similar objects, [mainpath] and [root], as part of my personal library https://github.com/fdch/fd_lib.
[mainpath] gives the canvas full path and handles path names relative to it. It also fetches all files in a given directory (using dirent.h)
[root] gives out the root canvas name, which is useful both for regular pd messages and tcl related messages.
> On Oct 7, 2017, at 7:00 PM, Seb Shader via Pd-list <pd-list at lists.iem.at> wrote:
> I've made a [rootinfo] object in my library that gives the path, name, and relative level of the root canvas.
> I also have a [makerpath] object that is supposed to take paths relative to the root canvas and transform them into absolute paths but it doesn't seem to work
> correctly... I will update it tonight though.
> available here https://github.com/sebshader/shadylib
> might be in deken for linux and OS X.. not sure (thought the updated abstraction will only be on Github)
> -----Original Message-----
> From: Jérôme Abel <abel.jerome at free.fr>
> To: pd-list <pd-list at iem.at>
> Sent: Sat, Oct 7, 2017 7:35 am
> Subject: [PD] Best way to make file paths relative to the parent patch ?
> To explain myself, i have to describe a practical example (http://reso-nance.org/public/pd-malinette/test-paths.png) :
> - you write an [audio-sampler] abstraction in "abs" directory, which load soundfiles
> - you write a "main.pd" patch where you put this abstraction in the project directory
> - you want to load the "data/snare.wav" sound file with a message connected to the abstraction
> Result : the context of the abstraction is in "abs" directory, so it can't find "data/snare.wav" (there is no "abs/data/snare.wav" file), instead we have to write "../data/snare.wav" relative to the abstraction and not the parent patch.
> A common solution to deal with that is to add [ggee/getdir 1] inside the abstraction, to get the absolute path of the file starting from the upper level (parent patch). But if the abstraction is inside another abstraction, it has to be [ggee/getdir 2] and so on ... But how find the right depths of the abstraction ? The abstraction doesn't know his context of use.
> I think I will put a [ggee/getdir 10] or greater to be sure to get the parent patch level, but maybe someone has another solution, a vanilla solution ?
> Related PR :
> _______________________________________________ Pd-list at lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
> Pd-list at lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pd-list