resource_t usedResources; rlimit limitVar; enum {LIMIT_NONE, LIMIT_TIME, LIMIT_MEM, LIMIT_SLEEP}; int limitExceded; int graceCount; // logJN remove("logJN.txt"); ofstream clogJN("logJN.txt", fstream::app); // logJE remove("logJE.txt"); ofstream clogJE("logJE.txt", fstream::app); //Se inicializa el reporte Reporte reporte(removeExtension(getFileName(outputFile.c_str())),problem,judgeType,testCases); clog << "Iniciando evaluación..." << endl; clog << "El problema es: " << problem << endl; clog << "El tipo de juez es: " << judgeType << endl; if(judgeNeedsExe(judgeType)) clog << "El ejecutable del juez es: " << judgeExe << endl; clog << "Evaluación estricta: " << (strictEval?"sí":"no") << endl; clog << "Comparar espacios: " << (compareWhite?"sí":"no") << endl; clog << "Resultados se guardarán en: " << outputFile << ".xxx" << endl; clog << endl; //Ciclo para cada programa de alumno. (Fuentes con su ruta relativa) for (list<string>::iterator itSF = sourceFiles.begin(); itSF != sourceFiles.end(); itSF++) { if(showProgress) cout << "* " << flush;
bool TextureClass::Init(ID3D11Device* pDevice, vector<wstring> fileName, WCHAR* blendMapName) { HRESULT hr; if (blendMapName) { mUseBlendMap = true; hr = DirectX::CreateWICTextureFromFile(pDevice, blendMapName, 0, &mBlendMapSRV, NULL); if (FAILED(hr)) { MessageBox(0, L"Failed to load blendMap.", blendMapName, MB_OK); return false; } } else mUseBlendMap = false; mTextureCount = fileName.size(); mSRV = new ID3D11ShaderResourceView*[mTextureCount]; if (!mSRV) return false; for (int i = 0; i < mTextureCount; i++) { mSRV[i] = 0; } mTexture = new ID3D11Texture2D*[mTextureCount]; if (!mTexture) return false; for (int i = 0; i < mTextureCount; i++) { mTexture[i] = 0; } for (int i = 0; i < mTextureCount; i++) { if (fileName[i].c_str()[0] == '.') fileName[i].erase(0, 1); if (fileName[i].c_str()[0] == '/') fileName[i].erase(0, 1); if (fileName[i].c_str()[0] == '/') fileName[i].erase(0, 1); if (GetExtension(fileName[i]) == wstring(L"tga")) { fileName[i] = removeExtension(fileName[i]) + L".jpg"; } fileName[i] = L"data/resources/" + fileName[i]; hr = DirectX::CreateWICTextureFromFileEx(pDevice, (WCHAR*)fileName[i].c_str(), NULL, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, false, (ID3D11Resource**)&mTexture[i], NULL);//DirectX::CreateWICTextureFromFile(pDevice, (WCHAR*)fileName[i].c_str(), (ID3D11Resource**)&mTexture[i], NULL, NULL); if (FAILED(hr)) { MessageBox(0, L"Failed to load texture.", fileName[i].c_str(), MB_OK); return false; } D3D11_TEXTURE2D_DESC tDesc; ZeroMemory(&tDesc, sizeof(tDesc)); mTexture[i]->GetDesc(&tDesc); D3D11_SHADER_RESOURCE_VIEW_DESC srvd; ZeroMemory(&srvd, sizeof(srvd)); srvd.Format = tDesc.Format; srvd.Texture2D.MipLevels = tDesc.MipLevels; srvd.Texture2D.MostDetailedMip = 0; srvd.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; hr = pDevice->CreateShaderResourceView(mTexture[i], &srvd, &mSRV[i]); if (FAILED(hr)) { MessageBox(0, L"Failed to create SRV.", fileName[i].c_str(), MB_OK); return false; } } /*D3D11_TEXTURE2D_DESC tDesc; ZeroMemory(&tDesc, sizeof(tDesc)); tDesc.Width = BTH_IMAGE_WIDTH; tDesc.Height = BTH_IMAGE_HEIGHT; tDesc.ArraySize = 1; tDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; tDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; tDesc.MipLevels = 1; tDesc.Usage = D3D11_USAGE_DEFAULT; tDesc.SampleDesc.Count = 1; tDesc.SampleDesc.Quality = 0; tDesc.CPUAccessFlags = 0; tDesc.MiscFlags = 0; D3D11_SUBRESOURCE_DATA tbsd; ZeroMemory(&tbsd, sizeof(tbsd)); tbsd.pSysMem = (void*)BTH_IMAGE_DATA; tbsd.SysMemPitch = BTH_IMAGE_WIDTH * 4 * sizeof(char); ID3D11Texture2D * texture; hr = pDevice->CreateTexture2D(&tDesc, &tbsd, &texture); if (FAILED(hr)) { MessageBox(0, L"Failed to create texture2D.", fileName, MB_OK); return false; } D3D11_SHADER_RESOURCE_VIEW_DESC srvd; ZeroMemory(&srvd, sizeof(srvd)); srvd.Format = tDesc.Format; srvd.Texture2D.MipLevels = 1; srvd.Texture2D.MostDetailedMip = 0; srvd.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; pDevice->CreateShaderResourceView(texture, &srvd, &mSRV); texture->Release();*/ return true; }
int main(int argc, char **argv) { int ii; int size; int ind; int curlevel; int in; int out; char *FileName; char *FileNameOut; FILE *FileInput; FILE *FileOutput; FILE *FileOutputLoss; // default FileName = ""; FileNameOut = ""; // parse parmeters for (ii = 1; ii < argc; ii++) { if (!FileName[0]) FileName = argv[ii]; else if (!FileNameOut[0]) FileNameOut = argv[ii]; } FileInput = fopen(FileName, "rb"); if (!FileInput) { printf("Couldn't open input file %s\n", FileName); return 1; } if (!FileNameOut[0]) { FileNameOut = FileName; // remove extension removeExtension(FileNameOut); // set raw output strcat(FileNameOut, ".raw"); } FileOutput = fopen(FileNameOut, "wb"); if (!FileOutput) { fclose(FileInput); printf("Couldn't open output file %s\n", FileNameOut); return 1; } FileOutputLoss = fopen("loss", "wb"); ii = 0; curlevel = 0; fseek(FileInput, 0, SEEK_END); size = ftell(FileInput); fseek(FileInput, 0, SEEK_SET); while (ii < size) { // input is 8 bits signed in = (char) fgetc(FileInput); ind = GetBestDeltaIndex(in, curlevel); curlevel += delta_tab[ind]; fputc(curlevel, FileOutputLoss); out = ind; // input is 8 bits signed in = (char) fgetc(FileInput); ind = GetBestDeltaIndex(in, curlevel); curlevel += delta_tab[ind]; fputc(curlevel, FileOutputLoss); out |= (ind << 4); fputc(out, FileOutput); ii += 2; } fclose(FileOutputLoss); fclose(FileOutput); fclose(FileInput); return 0; }
int main ( int argc, const char* argv[] ) { if(argc <= 2) { std::cerr << "You need to specify at least the output file and one input file." << std::endl << "Example: " << argv[0] << " output_file input_file" << std::endl; return 1; } try { std::string headername (argv[1]); std::vector<std::string> input_files; for(int i = 2; i < argc; i++) { input_files.push_back(std::string(argv[i])); } /* Process */ std::ofstream output ( headername, std::ios::out | std::ios::trunc| std::ios::binary ); /* Use buffer */ char outbuffer[BUFFER_SIZE]; output.rdbuf()->pubsetbuf ( outbuffer, BUFFER_SIZE ); if ( !output ) throw std::runtime_error ( "Failed to create output file!" ); /* Show status */ std::cout << "Build : file '" << headername << "'..." << std::endl; /* Get base name of file */ headername = GetFileBasename ( headername ); /* Data string stream */ std::ostringstream data; /* Write header start when wanted */ defineheader_start ( data, headername, /*use macro*/ true, /* const */ true ); /* Write macros */ definemacros ( data ); /* Common input buffer */ char inbuffer[BUFFER_SIZE]; for ( auto iter = input_files.begin(); iter != input_files.end(); iter++ ) { std::string &file = *iter; //std::string fileext = GetFileExtension ( file ); std::ifstream input ( file, std::ios::in | std::ios::binary | std::ios::ate ); input.rdbuf()->pubsetbuf ( inbuffer, BUFFER_SIZE ); if ( input.is_open() ) { /* Show status */ std::cout << "Process: file '" << file << "'..." << std::endl; /* Remove extension */ file = removeExtension(file); std::transform(file.begin(), file.end(), file.begin(), ::tolower); std::transform(file.begin(), file.end(), file.begin(), toUnderscores); /* Process file */ definefile ( data, input, file, true ); } else { /* Only show warning, other files need to be processed */ std::cout << "Warning: input file '" << file << "' failed to open." << std::endl; } } /* Write header end when wanted */ defineheader_end ( data, headername ); /* Write data to output file */ output.seekp ( 0, std::ios::beg ); output << data.str(); } catch ( std::exception& e ) { std::cerr << "Error: " << e.what() << std::endl; } catch ( ... ) { std::cerr << "Error: Exception of unknown type!" << std::endl; } return 0; }
bool HardcodedGraphicsItem::GetHDCByName(std::string text, HDC* colorHDC, HDC* maskHDC) { // 1. PARSE TEXT // If it has an ending, then remove it: if (text.find(".")) text = removeExtension(text); // First extract the name: if (text.find("hardcoded-") != 0) return false; // Possible outcome: // hardcoded-1-3.png --> // hardcoded-1-3 // --> [0] = hardcoded // --> [1] = 1 // --> [2] = 3 // hardcoded-1.png // --> [0] = hardcoded // --> [1] = 1 std::vector<std::string> textPattern = split(text, '-'); if (textPattern.size() != 2 && textPattern.size() != 3) // Size must be 2 or three (see above) return false; if (!is_number(textPattern[1])) // 2. value must be a number return false; if (textPattern.size() == 3) // If size is 3, then 3. value must be a number if (!is_number(textPattern[2])) return false; // Now convert them to numbers int index = atoi(textPattern[1].c_str()); int arrayIndex = -1; if (textPattern.size() == 3) arrayIndex = atoi(textPattern[2].c_str()); // 2. GET HARDCODED OBJECT AND VALIDATE // Check if index is in bounds if (index > (int)HardcodedGraphics.size() || index < 1) return false; // Get the item info: HardcodedGraphicsItem& hItemInfo = HardcodedGraphicsItem::Get(index); HardcodedGraphicsItem* hItemInfoMask = hItemInfo.getMaskObj(); if (hItemInfo.state == HardcodedGraphicsItem::HITEMSTATE_INVALID) // We cannot access invalid items return false; // If it is not an array, but the item info tells it is an array, then it is invalid! if (arrayIndex == -1 && hItemInfo.isArray()) return false; // If it is an array, but the item info tells it is NOT an array, then it is invalid! if (arrayIndex != -1 && !hItemInfo.isArray()) return false; // If it is an array, then do validation further: // TODO: Mask Validation return hItemInfo.getHDC(arrayIndex, colorHDC, maskHDC); }
void Albany::SimOutput::setFileName(const std::string& fname) { filename = removeExtension(fname); }