void setClasspathElements()

in src/main/cpp/launcher/windows/src/Launcher.c [497:549]


void setClasspathElements(LauncherProperties * props) {
    if(isOK(props)) {
        WCHAR * preCP = NULL;
        WCHAR * appCP = NULL;
        WCHAR *tmp = NULL;
        DWORD i = 0 ;
        
        writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Modifying classpath ...", 1);
        // add some libraries to the beginning of the classpath
        while((preCP = getArgumentValue(props, classPathPrepend, 1, 1))!=NULL) {
            writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... adding entry to the beginning of classpath : ", 0);
            writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, preCP, 1);
            if (props->classpath != NULL) {
                preCP = appendStringW(preCP, CLASSPATH_SEPARATOR);
            }
            //WCHAR *last = props->classpath;
            resolveString(props, &preCP);
            tmp = appendStringW(preCP, props->classpath);
            FREE(props->classpath);
            props->classpath = tmp;
        }
        
        
        for(i=0;i<props->jars->size;i++) {
            WCHAR * resolvedCpEntry = NULL;
            resolvePath(props, props->jars->items[i]);
            resolvedCpEntry = props->jars->items[i]->resolved;
            if(!fileExists(resolvedCpEntry)) {
                props->status = EXTERNAL_RESOURCE_MISSING;
                showErrorW(props, EXTERNAL_RESOURE_LACK_PROP, 1, resolvedCpEntry);
                return;
            }
            if (props->classpath != NULL) {
                props->classpath = appendStringW(props->classpath, CLASSPATH_SEPARATOR);
            }
            props->classpath = appendStringW(props->classpath, resolvedCpEntry);
        }
        
        // add some libraries to the end of the classpath
        while((appCP = getArgumentValue(props, classPathAppend, 1, 1))!=NULL) {
            writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... adding entry to the end of classpath : ", 0);
            writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, appCP, 1);
            if (props->classpath != NULL) {
                props->classpath = appendStringW(props->classpath, CLASSPATH_SEPARATOR);
            }
            resolveString(props, &appCP);
            props->classpath = appendStringW(props->classpath, appCP);
            FREE(appCP);
        }
        
        writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... finished", 1);
    }
}