HISE Logo Forum
    • Categories
    • Register
    • Login

    HISE Unzipping

    Scheduled Pinned Locked Moved Scripting
    26 Posts 3 Posters 1.2k 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.
    • CasmatC
      Casmat
      last edited by Casmat

      Hey!

      Have this:

      FileSystem.browse(FileSystem.Downloads, false, "*", function(result)
      {
      	result.extractZipFile(FileSystem.getFolder(FileSystem.Desktop), true, function(obj)
      	{
      		FileSystem.getFolder(FileSystem.Desktop).getChildFile(obj.CurrentFile).deleteFileOrDirectory();
      	});
      });
      

      but, instead of deleting the file from the zip, this code deletes other random files from the directory... Did do some havoc on my computer :sad_but_relieved_face: Have any ideas to fix? I'm trying to delete the zipped files after unzipping them

      Thanks for helping!

      i make music

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

        @Casmat Read the docs :p I'm out at the moment i'll help more when i'm home

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        CasmatC 2 Replies Last reply Reply Quote 0
        • CasmatC
          Casmat @d.healey
          last edited by

          @d-healey awaiting your reply! cant find anything useful in the docs

          i make music

          1 Reply Last reply Reply Quote 0
          • CasmatC
            Casmat @d.healey
            last edited by

            @d-healey hise is weird, had to do this:

            FileSystem.browse(FileSystem.Downloads, false, "*", function(result)
            {
            	result.extractZipFile(FileSystem.getFolder(FileSystem.Desktop), true, function(obj)
            	{
            		if(obj.Status == 1)
            		{
            			reg name = obj.CurrentFile;
            		}
            		FileSystem.getFolder(FileSystem.Desktop).getChildFile(name).deleteFileOrDirectory();
            	});
            });
            

            i make music

            Christoph HartC 1 Reply Last reply Reply Quote 0
            • Christoph HartC
              Christoph Hart @Casmat
              last edited by

              For the love of god, put that delete instruction into the branch ;)

              CasmatC 1 Reply Last reply Reply Quote 1
              • CasmatC
                Casmat @Christoph Hart
                last edited by

                @Christoph-Hart putting it into the if statement? doesnt work..

                i make music

                Christoph HartC 1 Reply Last reply Reply Quote 0
                • Christoph HartC
                  Christoph Hart @Casmat
                  last edited by

                  @Casmat no inside the brackets, otherwise name will be undefined if obj.Status is not 1 and if the failsafe doesn‘t catch you‘ll end up deleting the parent directory.

                  CasmatC 2 Replies Last reply Reply Quote 0
                  • CasmatC
                    Casmat @Christoph Hart
                    last edited by Casmat

                    @Christoph-Hart im confused, which brackets? 😖

                    like this?

                    FileSystem.browse(FileSystem.Downloads, false, "*", function(result)
                    {
                    	result.extractZipFile(FileSystem.getFolder(FileSystem.Desktop), true, function(obj)
                    	{
                    		if(obj.Status == 1)
                    		{
                    			reg name = obj.CurrentFile;
                    			FileSystem.getFolder(FileSystem.Desktop).getChildFile(name).deleteFileOrDirectory();
                    		}
                    	});
                    });
                    

                    ^ doesnt work...

                    i make music

                    1 Reply Last reply Reply Quote 0
                    • CasmatC
                      Casmat @Christoph Hart
                      last edited by

                      @Christoph-Hart this would suffice, right?

                      FileSystem.browse(FileSystem.Downloads, false, "*", function(result)
                      {
                      	result.extractZipFile(FileSystem.getFolder(FileSystem.Desktop), true, function(obj)
                      	{
                      		if(obj.Status == 1)
                      		{
                      			reg name = obj.CurrentFile;
                      		}
                      		if(!obj.Status == undefined)
                      		{
                      			FileSystem.getFolder(FileSystem.Desktop).getChildFile(name).deleteFileOrDirectory();
                      		}
                      	});
                      });
                      

                      i make music

                      Christoph HartC 1 Reply Last reply Reply Quote 0
                      • Christoph HartC
                        Christoph Hart @Casmat
                        last edited by Christoph Hart

                        @Casmat nope, now you've went full gibberish :)

                        If you want to delete the zip file, pass in result as lambda and delete it when the extraction is finished (obj.Status == 2) according to the docs:

                        FileSystem.browse(FileSystem.Downloads, false, "*", function(result)
                        {
                                var fileToDelete = result; // you can't pass in function parameters as lambda
                        	result.extractZipFile(FileSystem.getFolder(FileSystem.Desktop), true, function [fileToDelete](obj)
                        	{
                        		if(obj.Status == 2)
                        		{
                        			fileToDelete.deleteFileOrDirectory();
                        		}
                        	});
                        });
                        

                        EDIT: forgot that you can't pass in arguments as lambda, now it should work.

                        CasmatC 2 Replies Last reply Reply Quote 2
                        • CasmatC
                          Casmat @Christoph Hart
                          last edited by

                          @Christoph-Hart oooh! That's why you're Christoph Hart and i'm not!

                          i make music

                          Christoph HartC 1 Reply Last reply Reply Quote 0
                          • Christoph HartC
                            Christoph Hart @Casmat
                            last edited by

                            @Casmat oh and check my edit, I made a mistake.

                            CasmatC 1 Reply Last reply Reply Quote 0
                            • CasmatC
                              Casmat @Christoph Hart
                              last edited by

                              @Christoph-Hart got it! Thanks for checking up!:grinning_face_with_smiling_eyes:

                              i make music

                              1 Reply Last reply Reply Quote 0
                              • CasmatC
                                Casmat @Christoph Hart
                                last edited by

                                @Christoph-Hart Oh wait... that deletes the original zip file, I'm trying to delete the extracted file inside the zip...

                                i make music

                                Christoph HartC 1 Reply Last reply Reply Quote 0
                                • Christoph HartC
                                  Christoph Hart @Casmat
                                  last edited by

                                  @Casmat lol why? sounds like a software version of this:

                                  funny.gif

                                  CasmatC 1 Reply Last reply Reply Quote 3
                                  • CasmatC
                                    Casmat @Christoph Hart
                                    last edited by

                                    @Christoph-Hart yeah, context probably helps! I am planning to package hr1 files in an expansion and other thingys for users to import and I was planning to put them all into a zip and send that zip to the user, when unzipping the zip file to access its contents, I’d want to delete the unzipped portion when all the installation is done to clear space. Hence the question of how to delete unzipped files!

                                    i make music

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

                                      @Casmat An hr file is already a compressed archive, there is no reason to zip a zip file.

                                      Send the user multiple zip files

                                      Libre Wave - Freedom respecting instruments and effects
                                      My Patreon - HISE tutorials
                                      YouTube Channel - Public HISE tutorials

                                      CasmatC 1 Reply Last reply Reply Quote 0
                                      • CasmatC
                                        Casmat @d.healey
                                        last edited by Casmat

                                        @d-healey yup, but I’m planning on including other content that could be used for the player plugin that hr1 files wouldn’t be useful in, and creating a single zip file package would make a more seamless installation process for users

                                        i make music

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

                                          @Casmat How big will your zip files be?

                                          Libre Wave - Freedom respecting instruments and effects
                                          My Patreon - HISE tutorials
                                          YouTube Channel - Public HISE tutorials

                                          CasmatC 1 Reply Last reply Reply Quote 0
                                          • CasmatC
                                            Casmat @d.healey
                                            last edited by Casmat

                                            @d-healey have no clue, variable range, from couple mb to couple Gb. I was maybe thinking of creating a temp folder somewhere in the app data, then unzipping there and deleting the temp folder as a whole?

                                            i make music

                                            d.healeyD 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            22

                                            Online

                                            1.8k

                                            Users

                                            12.0k

                                            Topics

                                            104.8k

                                            Posts