HISE Unzipping
-
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!
-
@Casmat Read the docs :p I'm out at the moment i'll help more when i'm home
-
@d-healey awaiting your reply! cant find anything useful in the docs
-
@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(); }); });
-
For the love of god, put that delete instruction into the branch ;)
-
@Christoph-Hart putting it into the if statement? doesnt work..
-
@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.
-
@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...
-
@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(); } }); });
-
@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.
-
@Christoph-Hart oooh! That's why you're Christoph Hart and i'm not!
-
@Casmat oh and check my edit, I made a mistake.
-
@Christoph-Hart got it! Thanks for checking up!:grinning_face_with_smiling_eyes:
-
@Christoph-Hart Oh wait... that deletes the original zip file, I'm trying to delete the extracted file inside the zip...
-
@Casmat lol why? sounds like a software version of this:
-
@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!
-
@Casmat An hr file is already a compressed archive, there is no reason to zip a zip file.
Send the user multiple zip files
-
@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
-
@Casmat How big will your zip files be?
-
@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?