SKyZz
27 February 2021 12:27
1
Hello everyone:
For any plugin, there is a path to the presets folder (Win):
string presetPath = "\\Any1\\Any2\\Presets\\" + start + ".preset";
char presetPath[MAX_PATH];
HRESULT hr = SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, (LPWSTR)presetPath );
strcat(anyPath, presetPath.c_str());
ifstream file1(presetPath);
C:\Users\test\Documents\Any1\Any2\Presets\start.preset
On Mac (doesn’t work):
string preset_file = "/Users/" + (string)getenv("USER") + "/Any1/Any2/Presets/" + start + ".preset"
ifstream filepr(preset_file);
if (!filepr.is_open())
{
}
else {
}
Users/test/Documents/Any1/Any2/Presets/start.preset
How to get the “User” folder on mac?? I will be glad to hear any arguments or examples.
you can use UserHomePath () or SandboxSafeAppSupportPath() in IPlugPaths.h
stw
27 February 2021 16:32
3
Can’t try Olis suggestion right now so maybe it’s obsolete. Anyway…
I save my data in a subfolder of the Application Support folder and get that by:
FSRef ref;
OSType folderType = kApplicationSupportFolderType;
char appdata[MAX_PATH];
FSFindFolder( kLocalDomain, folderType, kCreateFolder, &ref );
FSRefMakePath( &ref, (UInt8*)&appdata, MAX_PATH );
I didn’t try myself but guess you can get the User folder with ‘kCurrentUserFolderLocation’
SKyZz
27 February 2021 16:55
4
I made a stupid but working version:
char presets_file_path[PATH_MAX];
strcpy(presets_file_path, "/Users/");
strcat(presets_file_path, getenv("USER"));
strcat(presets_file_path, "/Documents/AAA/BBB/Presets/start.preset");
presets_file_path:
/Users/user/Documents/AAA/BBB/Presets/start.preset
This will break in audiounits on apple silicon in sandboxed hosts like Logic and Garageband. Most devs are going for ~/Music ~/Documents may also work, not sure
SKyZz
27 February 2021 17:05
6
I’m not sure if it’s appropriate to ask here, but the question is about the paths, for example, I open my VST plugin in the Reaper, how do I find out the path to the VST plugin and not the path to the executable file that my plugin opens, i.e. the Reaper. This is already what I need for debag so as not to break the new Apple Silicon((
That is, the moment is specified, whether there is a common function for both operating systems?
PluginPath(), but I am not sure it is reliable
1 Like
SKyZz
27 February 2021 17:13
8
olilarkin:
PluginPath()
At the moment, this is what it looks like for me (win):
char plugin_path[1024];
uint32_t size = sizeof(plugin_path);
_NSGetExecutablePath(plugin_path, &size);
so I have to test all the options
SKyZz
28 February 2021 12:06
9
@olilarkin
For reference, maybe it will help someone.
About: Get the self path (not executable app)
This Function for mac is equivalent to WIN32 Api function .
This code gets an executable app path
char plugin_path[1024];
uint32_t size = sizeof(plugin_path);
_NSGetExecutablePath(plugin_path, &size);
This is way late, but if you’re looking for the home directory and find that it doesn’t get sandboxed, you can use getenv(“HOME”) - that should be valid on any *nix OS.
For Windows it should be getenv(“USERPROFILE”)
Scott