Minor problem with File API
-
const var appDataFolder = FileSystem.getFolder(FileSystem.Samples); const var presetsFolder = appDataFolder.getChildFile("ExpansionMetaData"); const var fileList = FileSystem.findFiles(presetsFolder, "*_expansion.json", true); Console.print(fileList[0].toString(fileList[0].Filename));
doesnt seem to work - it returns the full path every time.
this does work however:
const var appDataFolder = FileSystem.getFolder(FileSystem.Samples); const var presetsFolder = appDataFolder.getChildFile("ExpansionMetaData"); const var fileList = FileSystem.findFiles(presetsFolder, "*_expansion.json", true); Console.print(fileList[0].toString(fileList[0].NoExtension));
OnlyExtension also doesnt work...
-
You don't need to put
fileList[0].Filename
, you just put the string constant. So in your case it would beConsole.print(fileList[0].toString("Filename"));
-
@d-healey said in Minor problem with File API:
Console.print(fileList[0].toString("Filename"));
sure I can do that and it works(or more correctly - breaks) in exactly the same way:
it prints out this:
H:\Audio\Channel Robot\Hise_Work\Substrate\Samples\ExpansionMetaData\Substrate_expansion.json
when it should print out this:
Substrate_expansion.json
-
This post is deleted! -
Ok I figured it out, your method was right Lindon. The constant is a member of the file object but Filename has not been implemented.
You can cheat it though since it's just an integer, use
3
.
Console.print(fileList[0].toString(3));
@Christoph-Hart Little fixes required: According to docs
File.Extension
should beFile.OnlyExtension
, andFile.Filename
is missing. -
Yup, use the int. Works for me.
-
Looking in the source it seems this constant has been implemented but it's still not working when used in a script.
-
Ok I've fixed this issue now - turned out to be really simple. I've also added a
File.getSize()
function and aFileSystem.descriptionOfSizeInBytes()
(Maybe this function should be part of the File class but I couldn't get it to work unless it was called on a file object which shouldn't be necessary). These are wrappers for the JUCE functions of the same name.I've also added a wrapper function to generate a SHA256 has from a file, might be useful for verifying the integrity of downloaded files.
I noticed that the autocomplete popup doesn't seem to work for
File.
in the latest version, anyone else having this issue?