void extractFileToDir()

in src/main/cpp/launcher/windows/src/ExtractUtils.c [393:441]


void extractFileToDir(LauncherProperties * props, WCHAR ** resultFile) {
    WCHAR * fileName = NULL;
    int64t * fileLength = NULL;
    DWORD crc = 0;
    writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Extracting file ...", 1);
    readStringWithDebugW( props, & fileName, "file name");
    
    fileLength = newint64_t(0, 0);
    readBigNumberWithDebug( props, fileLength, "file length ");
    
    readNumberWithDebug( props, &crc, "CRC32");
    
    if(!isOK(props)) return;
    
    if(fileName!=NULL) {
        DWORD i=0;
        WCHAR * dir;
        resolveString(props, &fileName);
        
        for(i=0;i<getLengthW(fileName);i++) {
            if(fileName[i]==L'/') {
                fileName[i]=L'\\';
            }
        }
        
        dir = getParentDirectory(fileName);
        writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "   ... extract to directory = ", 0);
        writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0,  dir, 1);
        
        checkFreeSpace(props, dir, fileLength);
        FREE(dir);
        if(isOK(props)) {
            writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "   ... starting data extraction", 1);
            writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "   ... output file is ", 0);
            writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, fileName, 1);
            extractDataToFile(props, fileName, fileLength, crc);
            writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "   ... extraction finished", 1);
            *resultFile = fileName;
        } else {
            writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "   ... data extraction canceled", 1);
        }
    } else {
        writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0,  "Error! File name can`t be null. Seems to be integrity error!", 1);
        *resultFile = NULL;
        props -> status = ERROR_INTEGRITY;
    }
    FREE(fileLength);
    return;
}