FileSystem Question - Make a directory that doesn't exist
-
Hey all,
I'm running into an issue where if I want to save a file (like a user preset) into a new folder, there's no way to do it unless the folder already exists on the computer. Am I missing something? Here's a simple example:
var file = FileSystem.getFolder(FileSystem.UserPresets).getChildFile("Factory/Utility/test.preset"); Engine.saveUserPreset(file);
If
Factory/Utility
doesn't exist, the function won't do anything. -
It looks like we just need some additional JUCE File Class functions in the Scripting API.
createDirectory()
would be really useful! -
@Lunacy-Audio I'd love to be able to do this too, at the moment my plan is to either do a post install script to create the folders (which I've yet to learn), or have the user save those presets into the top level of User Presets, which will get messy!
-
The installer is a good temporary solution and isn't too hard.
I just added
createDirectory()
to the Scripting API. It's a pretty simple call, but I'm not sure if it's the cleanest solution, so I'll need to check with Christoph before I pull request. Looks something like this:var newFolder = FileSystem.getFolder(FileSystem.UserPresets).createDirectory("NewFolder");
-
@Lunacy-Audio said in FileSystem Question - Make a directory that doesn't exist:
The installer is a good temporary solution and isn't too hard.
I just added
createDirectory()
to the Scripting API. It's a pretty simple call, but I'm not sure if it's the cleanest solution, so I'll need to check with Christoph before I pull request. Looks something like this:var newFolder = FileSystem.getFolder(FileSystem.UserPresets).createDirectory("NewFolder");
Did you make a pull request for this? What about a createFile function? (thinking for text/json files).
-
No need for createFile() - it‘s automatically created if you write a string or object
-
@d-healey said in FileSystem Question - Make a directory that doesn't exist:
Did you make a pull request for this? What about a createFile function? (thinking for text/json files).
and this:
https://forum.hise.audio/topic/3833/filesystem-wheres-createfile/
-
@d-healey Just pull requested
createDirectory
! -
@Christoph-Hart said in FileSystem Question - Make a directory that doesn't exist:
No need for createFile() - it‘s automatically created if you write a string or object
I found a use case. When downloading a file, for an image cache for example, it's desirable to put these in a sub-folder.
@Lunacy-Audio said in FileSystem Question - Make a directory that doesn't exist:
@d-healey Just pull requested
createDirectory
!And I just figured out how to merge your changes into my fork :D
-
@d-healey said in FileSystem Question - Make a directory that doesn't exist:
And I just figured out how to merge your changes into my fork
Please share your experience. I'll need to merge with my fork soon.
-
@dustbro Add Lunacy Audio's fork as a remote repo, then pull in and merge his scriptnode-tweaks branch.
Actually this looks like a better way to just pull the pull request directly - https://stackoverflow.com/questions/54033842/how-to-pull-a-pull-request-from-upstream-in-github
-
@d-healey @dustbro Forgive me, my Git fork is an absolute mess :face_screaming_in_fear: