COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :

Go Back   Cockos Incorporated Forums > Other Software Discussion > WDL users forum

Reply
 
Thread Tools Display Modes
Old 10-01-2017, 01:19 PM   #1
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 341
Default Finding location for config files in both Windows and OSX

So I got my initial experiments working - as a test I'd been writing my .ini file to the root folder of the C: drive, forgetting that this wouldn't be allowed by the OS! Now I have the file location set with this line:

Code:
myPlugPrefs.SetFilePath("C:\\Programming\\test.ini");
However this doesn't feel like the right way to approach it. Should I be testing to find the location of the plugin DLL file or is it more usual to have another folder somewhere for the settings to be used across all versions of the plugin? Also, what should I be doing for the OSX .ini file? Most things I've seen use the com.<companyname>.<productname> format in the Library/Caches folder, but that looks to be a different way of doing things than this method.
Bobflip is offline   Reply With Quote
Old 10-01-2017, 06:37 PM   #2
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 654
Default

I was using My Documents to store GUI resize scale, but I will switch to pGraphics->AppSupportPath(). This should be available to non admin users too...
__________________
Website | Facebook Page | IPlug-Youlean
Youlean is offline   Reply With Quote
Old 10-01-2017, 07:28 PM   #3
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 341
Default

Ah, I didn't know about that AppSupportPath, I'll experiment further. Thanks!
Bobflip is offline   Reply With Quote
Old 10-02-2017, 03:07 PM   #4
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 341
Default

Ok, yeah, that's worked great! Only issue is I think due to the public/private parameters bug. Writing to the file works perfectly in both OSX and Windows. I've used forward slashes as those worked on both OSes. The .ini file is shared across AU, App and VST versions, but if I open a DAW project file with the plugin saved in a channel strip, the project instance's preferences overwrite those saved in the config file.

Code:
  WDL_String prefsPath;
  prefsPath.Set("");
  
  pGraphics->AppSupportPath(& prefsPath, false);
  prefsPath.Append("/IPlugEffect/IPlugEffect.cfg");
  
  myPlugPrefs.SetFilePath(prefsPath.Get());
  myPlugPrefs.WriteValue("defaultgroup", “Master Gain“, 75.0, "");
  myPlugPrefs.WriteFile();
And to get the data out I’ve used this:

Code:
      // Get path to the Preferences file
      prefsPath.Set("");
      PG->AppSupportPath(&prefsPath, false);
      prefsPath.Append(“/IPlugEffect/IPlugEffect.ini");
      
      myPlugPrefs.SetFilePath(prefsPath.Get());
      myPlugPrefs.ReadFile();

      double gainDefault = myPlugPrefs.ReadValue("defaultgroup", “Master Gain“, 50.0); // 50.0 is the default value if the parameter wasn’t found in the .ini file

	IBitmap* knob = pGraphics->LoadPointerToBitmap(KNOB_ID, KNOB_FN, kKnobFrames);
      GetParam(kGain)->InitDouble(“Gain”, gainDefault, 0.0, 100.0, 0.1 “%”);
      mGain = PG->AttachControl(pGain = new IKnobMultiControl(this, kGainX, kGainY, kGain, knob));

	pGraphics->AttachControl(new IKnobMultiControl(this, kGainX, kGainY, kGain, knob));

Last edited by Bobflip; 11-08-2017 at 11:36 AM.
Bobflip is offline   Reply With Quote
Old 10-03-2017, 05:03 AM   #5
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 654
Default

I will fix private/ public parameters ASAP.
Also, I have changed a config script and I will upload that tommorow.
__________________
Website | Facebook Page | IPlug-Youlean
Youlean is offline   Reply With Quote
Old 10-03-2017, 05:29 AM   #6
Andi!
Human being with feelings
 
Andi!'s Avatar
 
Join Date: Nov 2015
Location: Germany
Posts: 82
Default

For my presets I write to sub folders of

1.Windows:

Code:
csidlType = CSIDL_APPDATA;
char path[MAX_PATH + 256];
SHGetSpecialFolderPath(0, (LPSTR)path, csidlType, FALSE);
2. Mac

Code:
NSArray *paths; 
NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSString *applicationSupportDirectory = [paths objectAtIndex:0];
return [applicationSupportDirectory UTF8String];
Andi! is offline   Reply With Quote
Old 10-03-2017, 05:52 AM   #7
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 341
Default

Quote:
Originally Posted by Youlean View Post
I will fix private/ public parameters ASAP.
Also, I have changed a config script and I will upload that tommorow.
Cool, cheers!
Bobflip is offline   Reply With Quote
Old 11-06-2017, 05:47 PM   #8
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 356
Default

Just a quick follow up on this.
On Mac, I was using /[user]/Music/[manufacturer]/file.name to store my settings and registration information. Just this week, I had two users report issues with the registration process. It makes me think that maybe Apple is no longer having read/write access to this location.

Does anyone know if there are changes coming regarding user file locations? I might need to switch to a new location, but I don't know where. Not to rehash the topic, but are there any new options for read/write access locations?
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 11-07-2017, 01:51 AM   #9
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 654
Default

Why not store in app data folder? I am sure that you can store settings in documents, but this might not be desired.
__________________
Website | Facebook Page | IPlug-Youlean
Youlean is offline   Reply With Quote
Old 11-07-2017, 02:56 PM   #10
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 356
Default

Would that be ~/Library/Preferences on a Mac?
I am using AppData on Windows, and that has been working well (so far).
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 11-08-2017, 02:19 AM   #11
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 654
Default

Quote:
Originally Posted by random_id View Post
Would that be ~/Library/Preferences on a Mac?
I am using AppData on Windows, and that has been working well (so far).
No. I don't know what exactly is without looking but you can use method in IGraphics to get the correct address...
__________________
Website | Facebook Page | IPlug-Youlean
Youlean is offline   Reply With Quote
Old 11-08-2017, 09:08 AM   #12
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 341
Default

Mine are getting stored in Users/<USER>/Library/Application Support/<PLUGIN NAME>

Also, don't forget Library is a hidden folder!
Bobflip is offline   Reply With Quote
Old 11-08-2017, 09:13 AM   #13
Andi!
Human being with feelings
 
Andi!'s Avatar
 
Join Date: Nov 2015
Location: Germany
Posts: 82
Default

Look at the coding I have posted, it should be the programatic way to find the directories on both systems.
Andi! is offline   Reply With Quote
Old 11-08-2017, 11:30 AM   #14
stw
Human being with feelings
 
stw's Avatar
 
Join Date: Apr 2012
Posts: 279
Default

Quote:
Originally Posted by Andi! View Post
2. Mac

Code:
NSArray *paths; 
NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSString *applicationSupportDirectory = [paths objectAtIndex:0];
return [applicationSupportDirectory UTF8String];
What do i have to include to make that work? I either get unknown NSArray or a bunch of errors in NSObjCRuntime.h if i include any header that makes NSArray known.

BTW I use that code to get the Application Support Folder on OSX:
Code:
	FSRef ref;
	OSType folderType = kApplicationSupportFolderType;
	char appdata[MAX_PATH];
	FSFindFolder( kLocalDomain, folderType, kCreateFolder, &ref );
	FSRefMakePath( &ref, (UInt8*)&appdata, MAX_PATH );
stw is offline   Reply With Quote
Old 11-08-2017, 11:40 AM   #15
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 341
Default

The following code got the prefs path for me without any hitches. I posted a fuller version up at post 4, if it's a solution that'll work for you?

Code:
WDL_String prefsPath;
prefsPath.Set("");
  
pGraphics->AppSupportPath(&prefsPath, false);
prefsPath.Append("/IPlugEffect/IPlugEffect.cfg");
Bobflip is offline   Reply With Quote
Old 11-08-2017, 12:28 PM   #16
Andi!
Human being with feelings
 
Andi!'s Avatar
 
Join Date: Nov 2015
Location: Germany
Posts: 82
Default

Quote:
Originally Posted by Bobflip View Post
The following code got the prefs path for me without any hitches. I posted a fuller version up at post 4, if it's a solution that'll work for you?

Code:
WDL_String prefsPath;
prefsPath.Set("");
  
pGraphics->AppSupportPath(&prefsPath, false);
prefsPath.Append("/IPlugEffect/IPlugEffect.cfg");
Yes, this will result in the very same function calls. I don't know why this is located in IGraphics and not IPlug (I had moved it to my own coding a long time ago). Maybe because it's one of the few objective *.mm sources, maybe the reason why you, stw, have problems to compile it, please have a look at IGraphicsMac.mm.
Andi! is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:20 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.