[Solved]Binary app file which added by projucer or ZipFile can't run after release/rebuild/unzip it


#1

This issue only on macOS (.app file).

Normal on Windows (.exe file). Haven’t tested on Linux.


#2

Could this be due to internal symlinks or something like that? I don’t think Juce’s ZipFile class will preserve symlinks for example (which would be a problem for apps signed with PACE for example).

Of course an .app file is really a directory so are you adding the zipped .app to the Projucer or all the individual files?


#3

Oh, yes! I forgot this! Perhaps this is the core of why I failed to do it…


#4

If you unzip on OS X using 3rd party software like Keka the executable flag is stripped which leads to this behavior. The same might happen when using JUCE for unzipping.


#5

Yes, the same. I use JUCE ZipFile class to zip and unzip the .app file. However, use the default unzip of macOS’s finder have no this problem…


#6

The juce ZipFile stuff doesn’t attempt to set any file permissions, it just creates the files and copies their content. It won’t attempt to guess file types and look for executables or anything like that.


#7

So, if I want to embed an app file’s data in my software and release/rebuild it when user first launch the software, is there an easy way to solve my problem, Jules?

For example: lame.app/lame.exe…


#8

Just use File::setExecutePermission() before you run it


#9

Before run my software or users run the embeded app file which released on their local?


#10

I’ve no idea what you’re doing, but I guess you probably just want to set that flag after you unzip it.


#11

Ha, it works!
This method is exactly what I need! I love you, Jules :slight_smile:

Here is my code, you’ll find out what I’m doing:)

URL url;

#if JUCE_WINDOWS
    lameEncoder = File::getSpecialLocation (File::userDocumentsDirectory).getChildFile ("lame.exe");
    url = URL::createWithoutParsing ("https:/xxxx.xxx/lame-win.zip");

#elif JUCE_MAC
    lameEncoder = File::getSpecialLocation (File::userDocumentsDirectory).getChildFile ("lame.app");
    url = URL::createWithoutParsing ("https://xxxx.xxx/lame-osx.zip");
#endif

    if (!lameEncoder.existsAsFile())
    {
        MemoryBlock mb;
        
        // put it in userDocumentsDirectory
        if (url.readEntireBinaryStream (mb))
        {
            MemoryInputStream inputSteam (mb, false);
            ZipFile zip (inputSteam);
            zip.uncompressEntry (0, File::getSpecialLocation (File::userDocumentsDirectory));

            lameEncoder.setExecutePermission (true);
        }
    }