I am writing a dynamic plugin that takes a directory and looks for files in it (to do some stuff with them) - via the System.IO.Directory class.
Now the problem I have is, that the Directory selected via my Directory is given in a relative path, relative to the patch containing my plugin and System.IO.Directory assumes a standard working directory (usually different from my patch location).
So I want to get some info on the containing patch to set the working directory to the containing patch’s location, but I find it impossible to get an entry point to node-related info. Everything in VVVV.PluginInterfaces is - surprise! - interfaces and I can’t get a reference to the current node or the parent node or something.
So how do I instantiate a INode, INodeInfo, … object?
nope, it is kinda related, but has nothing to do with each other. the idea in plugins is that the manual approach you demoed is done automagically for you as so as pluginwriter you always deal with the correct absolut paths.
Defaulting to absolute paths would be kinda bad, because patches using _Directory_s would be virtually immobilized and become unportable.
If you (devvvvs) want a simpler way than GetHostPath() and Directory.SetCurrentDirectory(), imo a standardized way (i.e. method) to correctly access a relative path given from a Directory on a D-Plugin would be the way to go.
@granny: you missunderstood. the idea is that FMyInputi returns already the correct absolut path for you, ie. it does the GetHostPatch()…thing for you.
i’d rather not use Directory.SetCurrentDirectory() as i think it actually sets the current dir process-wide. lets see what tonfilm comes up with.
Okay, I found something:
My Directory pin selection in the patch is
*C:\Users\Public\Music
That (when hovering over the pin) get’s ‘relatived’ to
*…..\Public\Music
(because my patch is on my desktop in my user account)
Now inside the D-Plugin apparently (via ILogger) I get
*C:\Users[myAccount](myAccount)\Public\Music\
So it does convert the relative path (is it really relative or just in the gui?) to an absolute one, but in the wrong way. Either it only takes one dir up (from my desktop to myAccount folder) instead of two, or it just goes from myAccount in any case. Will check that in a minute.
Okay I think I know what goes wrong inside the Directory pin, because I made the same mistake when I wanted to do it by hand:
GetHostPath() gives you the full path including patch filename. Before removing as many folders as the relative path has "…" or "." the patch filename needs to be removed.
When I try to use this (in beta25) as described, I get the following exception:
Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘VVVV.PluginInterfaces.V1.IPluginHost’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{E72C5CF0-4738-4F20-948E-83E96D4E7843}’ failed due to the following error: Interface wordt niet ondersteund (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Same happens if I don’t use the import but I keep a reference to IPluginHost host that is passed as a paramater to the constructor…
hello ft, have you understood, that the string pin does this for you? you dont need to call this, i just posted it to give an insight, what the string pin is doing:
#endregion fields & pins
//called when data for any output pin is requested
public void Evaluate(int SpreadMax)
{
var s = "";
FHost.GetHostPath(out s);
FLogger.Log(LogType.Debug, s);
}
maybe your vvvv installation is somehow corrupted, can you try it with a clean download?