< Back to IRCAM Forum

get the pathname of the using om patch

Dear friends,

I would like to know, with which function or global variable could I get the pathname of the using om-patch within this patch?
In lisp-editor it is the global variable " load-pathname ", but it will return nil, if I put it into a function located in OpenMusic patch.

Thank you for the help in advance!

Best regards,
Jialin

Hi Jialin.

I don’t know of any ready method which returns the pathname of the current patch.
But you can call mypathname on the 'obj slot of the current window (om-front-window):

(defun this-patch-pathname ()  
    (mypathname (obj (om-front-window))))

-anders

This will give you the pathname of the front-most patch window, but not necessarily of the patch that is being executed…

I don’t see a way to get the pathname without significant hacking of the patch eval/compilation methods.

Just curiosity: what do you need it for ?

Hello Anders,

Thanks a lot for the great solution! I have tried and it can do the job very well in my case.
I will check and learn the code for window later.

All the best,
Jialin

Hello Jean,

Thank you for the reply and the information. In my libraries or patches, I usually generate a database with a huge amount of tiny files, and work with them later. Every time when I change my directories, or render files with another computer, or send it to another friend, I need to find and choose the directories again, it takes time to find the correct folders and let it run correctly.
So I would like to generate the database directly near the patch folder (or somehow related to the patch folder) and later, read and write the files directly from and into the folder.

Another thing is that when we import some of library tutorials, or several patches and files together, which are related to each other, there could be many files or pictures, which can not be loaded, and we need to find and load it manually.

I don’t know if there is way to avoid this situation, do you have some suggestion or idea?

Thank you again for the help!

All the best,
Jialin

In principle the patch file contains in its header the list of all ressources in it (sounds, pictures etc.) along with corresponding relative pathnames.
This should help retrieving these ressource files using relative location on the disk, but it is not much used at the moment with OM’s workspace-based document management: ressources are more supposed to be stored in the in-file/out-file and other subfolders of the workspace.
So I guess Anders’ solution is your way to go for the moment :slight_smile:
Good luck !

Yes! Many thanks for the information about retrieving the resource, it is very helpful!
I am now also considering generating the files directly into a sub-directory of the in-file folder.

Bests,
Jialin Liu