Add File object from absolute path string
-
@d-healey Well, I'm trying for hours...
You can make a user selecting a custom directory for anything you want,
for instance "/Users/greg/Documents/myAwesomeLocation" just for the sake of the exampleThen you can dump it let say in a pref file as an object parameter
Then at the next init when you recall the pref file, it is (at least for me) impossible to recreate the File object from this path string.
Well I say impossible but I found a way, but it's a bit dirty...
I split the path into substrings and recursively get the next childFile. But this means I need to begin somewhere I'm not really sure of. like root disk, and then add Users, then Documents, you get it...
If the user selects another directory that is not on the root disk, I have no proper way to know, and recall isn't possible.Since JUCE already can create File from an absolute path with
File::File (const String & absolutePath)
I'm trying to just implement it but with no success for now... -
Why not
FileSystem.getFolder(FileSystem.Documents).getChildFile(myAwesomeLocation)
?The problem is that absolute paths do not translate well across different operating systems so if you can achieve what you want with relative paths, it should be more robust.
-
@Christoph-Hart Well Documents was just an example, the user can choose whatever he wants and I have no ways to know...
-
Then use the FileSystem.browse method?
-
@Christoph-Hart The fact is that I don't fix the path myself so cross-compatibility isn't an issue here. It is the user who just set his path preferences, he won't copy the pref file to another computer...
-
@Christoph-Hart said in Add File object from absolute path string:
Then use the FileSystem.browse method?
This is what I do to get the path, but in order to dump it in a pref file I need to get the full path with
toString(0)
-
This is what I do for now...
HiseSnippet 1190.3ocuWstaaaCElxIZnVadXEnX+lv+RFMyw1qsaXYAMw2VM1hsQTR6FVGJTjnsIhLo.IURMJx611ixdC1av1g5hkRhSlqGxT9SN2+34bHOGOVv8HRIWfLJexhPBx3yLcVvTy5LykxPC5hLdhYWpf3o3BJQdBQpnron1KBckRhOxvXqePqoQ4sQwe+0Ka6F3x7H4rPnWyodjehNmpx4N9fejFDz20mbBcdAse1AC73rN7.dDfpsLafBc8N2cJYnqVsRlHiOomOEviixUQjHisay8W3LieIKQ+WSkzyBHZhlHGvQIr6yC70HVyE0YFMveb1oWh.uLNOWrURt3IlGQ8oK4mmS9hXA3bKJlOLJcevqYQ30X8gmQA3scB7droimfFpxknw1mZNfoHhItPInHrRzEU5OMM6vAMXp5ycOmzW.DK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yySmJ9J.6q1lVafMe8FXyy1.ad9FXyK1.a9lMvlu8dsQ+aaNLRwmmbMAXLtW7aqFF8XtPWVbGI5e.DUPa+D
-
I get the problem now.
Why not dump it to the appData folder instead of asking the user where they want it? -
@d-healey In fact it is for a customizable VST folder, so the user decides... Thus, the absolute path ;)
-
@ustk
Is that still the way you do it or have you found a nicer solution in the meantime? I'm facing the same problem... :-)