void resolveTestJVM()

in src/main/cpp/launcher/windows/src/Launcher.c [286:328]


void resolveTestJVM(LauncherProperties * props) {
    WCHAR * testJVMFile = NULL;
    WCHAR * testJVMClassPath = NULL;
    
    writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Resolving testJVM classpath...", 1);
    writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... first step : ", 0);
    writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, props->testJVMFile->path, 1);
    resolvePath(props, props->testJVMFile);
    testJVMFile = props->testJVMFile->resolved;
    
    writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... second     : ", 0);
    writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, props->testJVMFile->resolved, 1);
    
    
    if(isDirectory(testJVMFile)) { // the directory of the class file is set
        writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... testJVM is : directory ", 1);
        testJVMClassPath = appendStringW(NULL, testJVMFile);
    } else { // testJVMFile is either .class file or .jar/.zip file with the neccessary class file
        WCHAR * dir = getParentDirectory(testJVMFile);
        WCHAR * ptr = testJVMFile;
        do {
            ptr = searchW(ptr, CLASS_SUFFIX); // check if ptr contains .class
            if(ptr==NULL) { // .jar or .zip file
                writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... testJVM is : ZIP/JAR file", 1);
                testJVMClassPath = appendStringW(NULL, testJVMFile);
                break;
            }
            ptr += getLengthW(CLASS_SUFFIX); // shift to the right after the ".class"
            
            if(ptr==NULL || getLengthW(ptr)==0) { // .class was at the end of the ptr
                writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... testJVM is : .class file ", 1);
                testJVMClassPath = appendStringW(NULL, dir);
                break;
            }
        } while(1);
        FREE(dir);
    }
    
    FREE(props->testJVMFile->resolved);
    props->testJVMFile->resolved = testJVMClassPath;
    writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... resolved   : ", 0);
    writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, props->testJVMFile->resolved, 1);
}