Command line arguments for JUCEApplicationBase::anotherInstanceStarted

Like said in this discussion Command line arguments, the anotherInstanceStarted callback receives all arguments as a single string. However, on mac os at least, files are provided as an array. Cf this code in the mac version of the message manager:

static BOOL application_openFile (id /*self*/, SEL, NSApplication*, NSString* filename)
        {
            if (auto* app = JUCEApplicationBase::getInstance())
            {
                app->anotherInstanceStarted (quotedIfContainsSpaces (filename));
                return YES;
            }

            return NO;
        }

        static void application_openFiles (id /*self*/, SEL, NSApplication*, NSArray* filenames)
        {
            if (auto* app = JUCEApplicationBase::getInstance())
            {
                StringArray files;

                for (NSString* f in filenames)
                    files.add (quotedIfContainsSpaces (f));

                if (files.size() > 0)
                    app->anotherInstanceStarted (files.joinIntoString (" "));
            }
        }

This is called when double-clicking on files, or doping them on the application icon. concatenating all arguments in one string looses some information on the way, making it impossible to open files with quotes in their names. For example if I try to open the file ‘test with spaces and" quotes’, the string passed to the anotherInstanceStarted is ‘“test with spaces and” quotes"’, which is impossible to parse.

Solution:
Either find a way of letting us access the original string array, or properly escape quotes with a backslash. (First solution would be better as it would require less work for users). I guess anotherInstanceStarted can have a second override with a stringArray on mac.

Cheers

Thanks :slight_smile: