HISE Logo Forum
    • Categories
    • Register
    • Login

    Minor problem with File API

    Scheduled Pinned Locked Moved Bug Reports
    8 Posts 3 Posters 411 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • LindonL
      Lindon
      last edited by

      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...

      HISE Development for hire.
      www.channelrobot.com

      1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey
        last edited by d.healey

        You don't need to put fileList[0].Filename, you just put the string constant. So in your case it would be Console.print(fileList[0].toString("Filename"));

        LindonL 1 Reply Last reply Reply Quote 0
        • LindonL
          Lindon @d.healey
          last edited by Lindon

          @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
          

          HISE Development for hire.
          www.channelrobot.com

          1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey
            last edited by d.healey

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • d.healeyD
              d.healey
              last edited by d.healey

              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.

              f2e1fb56-c575-4aaf-a9c1-f6eed8c9a15c-image.png

              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 be File.OnlyExtension, and File.Filename is missing.

              1 Reply Last reply Reply Quote 0
              • Casey KolbC
                Casey Kolb
                last edited by

                Yup, use the int. Works for me.

                Casey Kolb
                Founder & CEO of Lunacy Audio
                Composer | Producer | Software Developer

                d.healeyD 1 Reply Last reply Reply Quote 0
                • d.healeyD
                  d.healey @Casey Kolb
                  last edited by

                  Looking in the source it seems this constant has been implemented but it's still not working when used in a script.

                  1 Reply Last reply Reply Quote 0
                  • d.healeyD
                    d.healey
                    last edited by d.healey

                    Ok I've fixed this issue now - turned out to be really simple. I've also added a File.getSize() function and a FileSystem.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?

                    1 Reply Last reply Reply Quote 2
                    • First post
                      Last post

                    17

                    Online

                    1.7k

                    Users

                    11.8k

                    Topics

                    102.6k

                    Posts