void readString()

in src/main/cpp/launcher/windows/src/ExtractUtils.c [126:161]


void readString(LauncherProperties * props, SizedString * result, DWORD isUnicode) {
    DWORD * status = & props->status;
    HANDLE hFileRead = props->handler;
    SizedString * rest = props->restOfBytes;
    DWORD bufferSize = props->bufsize;
    DWORD read=0;
    char * buf = NULL;
    
    if(*status != ERROR_OK ) return;
    
    if(readStringFromBuf(rest, result, isUnicode)==ERROR_OK) {
        return;
    }
    
    //we need to read file for more data to find \0 character...
    
    buf = newpChar(bufferSize);
    
    while (ReadFile(hFileRead, buf, bufferSize, &read, 0) && read) {
        addProgressPosition(props, read);
        rest->bytes = appendStringN(rest->bytes, rest->length, buf, read);
        rest->length = rest->length + read;
        if(readStringFromBuf(rest, result, isUnicode)==ERROR_OK) {
            //if(result->bytes!=NULL) {
            //we have find \0 character
            break;
        }
        ZERO(buf, sizeof(char) * bufferSize);
        if(read==0) { // we have nothing to read.. smth wrong
            *status = ERROR_INTEGRITY;
            break;
        }
    }
    FREE(buf);
    return;
}