void createTempDirectory()

in src/main/cpp/launcher/windows/src/FileUtils.c [360:412]


void createTempDirectory(LauncherProperties * props, WCHAR * argTempDir, DWORD createRndSubDir) {
    WCHAR * t = (argTempDir!=NULL) ? appendStringW(NULL, argTempDir) : getSystemTemporaryDirectory();
    
    WCHAR * nbiTmp = normalizePath(t);
    FREE(t);
    if(createRndSubDir) {
        WCHAR * randString = newpWCHAR(6);
        DWORD i=0;
        DWORD initValue = GetTickCount() & 0x7FFFFFFF;
        long value = (long) initValue;
        nbiTmp = appendStringW(nbiTmp, L"\\NBI");        
        
        for(i=0;i<5;i++) {
            value = nextRandDigit(value);
            randString[i] = '0' + (WCHAR) (value% 10);
        }
        nbiTmp = appendStringW(appendStringW(nbiTmp, randString), L".tmp");
        FREE(randString);
    }
    
    writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Using temp directory for extracting data : ", 0);
    writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, nbiTmp, 1);
    
    if(fileExists(nbiTmp) ) {
        if(!isDirectory(nbiTmp)) {
            props->status = ERROR_INPUTOUPUT;
            writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, ".. exists but not a directory", 1);
        } else {
            writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Output directory already exist so don`t create it", 1);
        }
    }
    else {
        writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "creating directory...", 1);
        createDirectory(props, nbiTmp);
        if(isOK(props)) {
            props->tmpDirCreated = 1;
            writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Directory created : ", 0);
            writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, nbiTmp, 1);
            // set hidden attribute
            if(createRndSubDir) {
                writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "Setting hidden attributes to ", 0);
                writeMessageW(props, OUTPUT_LEVEL_DEBUG, 1, nbiTmp, 1);
                
                SetFileAttributesW(nbiTmp, GetFileAttributesW(nbiTmp) | FILE_ATTRIBUTE_HIDDEN);
            }
        } else {
            writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "Error! Can`t create nbi temp directory : ", 0);
            writeMessageW(props, OUTPUT_LEVEL_DEBUG, 1, nbiTmp, 1);
        }
    }
    props->tmpDir = nbiTmp;
    return;
}