New API: Server and FileSystem
-
Never mind, I've fixed it, so you can just pull.
-
@Christoph-Hart thanks! :) And how to exctract name or path from object? I don't see any method in API to do this :)
Using trace gives me empty Interface log. -
-
@Christoph-Hart thanks a lot. I also used Filename but the result is the same as with FullPath.
Using this
for (f in files) { var p = f.toString(Filename); audioArr.push(p); }
gives me links like this
"/Users/armin/Library/Application Support/My Company/test/filez/pluck5.wav",
-
This post is deleted! -
@Christoph-Hart can you add option to set own headers in Server API?
-
There already is
Server.setHttpHeader
:https://docs.hise.audio/scripting/scripting-api/server/index.html#sethttpheader
-
Is there a way to set the FileSystem.browse() startFolder to be a sub-folder?
I'm looking to use a button to browse to the UserPresets folder of an Expansion.FileSystem.Expansions
gets me to the root..
I've tried:
FileSystem.Expansions.UserPresets FileSystem.Expansions/UserPresets
no go.
-
@dustbro
I think you just need to do something like this:
var folder = FileSystem.getFolder(FileSystem.Expansions).getChildFile("UserPresets"); FileSystem.browse(folder, false, "", function() {});
-
Is there anything special I have to do while using getParentDirectory?
I'm trying to get the directory of a file, but it's returning the full file path with file name.
e.g. C://Folder/audio.wavSame as if I call FullFilePath
-
@dustbro Example please
-
@d-healey Trying to get a label to display the parent directory of some audio files.
const var DirectoryLabel = Content.getComponent("DirectoryLabel"); const var Browse = Content.getComponent("Browse"); const var FullPath = []; const var ParentDirectory = []; inline function onBrowseControl(component, value) { if(value) //if button clicked { //open file broswer FileSystem.browseForDirectory("", function(directory) { local files = FileSystem.findFiles(directory, "*.wav", false); for(f in files) { FullPath.push(f.toString(File.FullPath)); //push full path ParentDirectory.push(f.toString(File.getParentDirectory)); //push parent directory } }); } }; Content.getComponent("Browse").setControlCallback(onBrowseControl);
HiseSnippet 1096.3ocsV01aaaCDlxwpH1cdnEXec.B9SxCY9kt1tADTTu3DODrlTi3rhALLzRKQESDJRAR5jYTDf8Sa+j1+fsihRVx1JYsFX7a26O2wi2wIRQ.QoDRjSiKWlPPNeg6zkb87QywTN5ziMLRvRBWeIQoQGsLAqTjPjiyd+j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3+a7l8mkVtmDEA2pEfst63ecW+fxmATtPrPCyfOCCihgNI2yWDOE91V.APBmSXJSGSMySNKceCsoxLkvCSI9G3jIbfg1IS3fbgnXbfT79.6CUyuh1OkCfId5GBa3dlg1aP9CTW29c6ihgOq89f.So3aArWsMOaGr461Aad9NXyK1Aad4NXy2uC17COnMl+I+iKzhX6yDfwjSRGT53bB2L2HsiD8uvBkWeC
-
The
toString()
function takes a single number as a parameter, for example File.FullPath is a built in constant that returns 0 - you can test this withConsole.print(File.FullPath);
. Docs - https://docs.hise.audio/scripting/scripting-api/file/index.html#tostringFile.getParentDirectory()
returns afile
object. Passing this to thetoString()
function which expects an integer is going to give the same result as passing the number0
orundefined
totoString()
because it doesn't know what to do with a file object.What you probably want is
ParentDirectory.push(f.getParentDirectory().toString(File.FullPath));
-
@d-healey said in New API: Server and FileSystem:
What you probably want is ParentDirectory.push(f.getParentDirectory().toString(File.FullPath));
:clinking_beer_mugs: