Saving external data in sessions?

We have a plugin we want to move to JUCE, but there is a design issue I am struggling with, and wonder if JUCE can help resolve it somehow.

Our plugin needs to record audio information, which we want to write to external files when saving sessions data. What we’d like to do is write that data as it is recorded, and then when saving the session, simply write the location of that data to the session data, as some kind of relative path from a known user location perhaps.

One problem that I see from this idea is that the data is then not part of the session file that the host produces (and which gets our parameter data and potentially this external file path). That means that users have to know, when copying sessions to other machines or sharing them, that they need to copy that external data as well.

One solution to this is to write the data in the folder in which the session is written. However, we don’t know of a way to reliably determine where that data has been written, or if there is a specific folder for that session that isn’t shared with other sessions. (We could get around the issue of other sessions in that folder by writing to a sub-folder that has a unique ID for this particular session.) Is there a way using JUCE to know where the session is actually written to? I doubt it, given that there isn’t even a guarantee that a call to getStateInformation() is actually writing a session file in the first place!

A second problem comes from the ability for a user to select “Save As…” from their File menu. If they do that, we don’t appear to have any way to know that they have done that, and so what would happen is there would now be the original saved session and this new saved session, both of which would be related to the very same internal session ID and thus to the same external data. That would end up, potentially, with two now disjoint sessions both potentially using the same external data, and possibly modifying it, which would break one or both of the sessions. Is there any way to know that a session is being saved someplace new? Again, I highly doubt it, but I’m not familiar enough with JUCE’s wrappers to know if this issue has ever been addressed.

Do any of you write external data in this manner? How do you address these issues? Thanks for any advice!

I would create a unique file name and notify the users that this file can’t be found and look for it.
AFAIK you cannot find the session location on the HD. Not available in VST or AU (maybe AAX?)
At least it doesn’t fail silently

Have you considered the possibility to embed your audio in the data that your plug-in stores in the session?
I remember that an old thread in this forum discussed exactly the feasibility of that (depending on the size of the audio data, of course)

One of the reasons we don’t want to embed the data in the session chunk is that it is too large (depending upon how much audio they process through our plugin). And we’re looking to add significantly more data than we gather currently.