/** * @author Edouard DUPIN * * @copyright 2011, Edouard DUPIN, all right reserved * * @license BSD v3 (see license file) */ #include #include // for the rand ... #include #include #include #include float etk::tool::frand(float a, float b) { return ( rand()/(float)RAND_MAX ) * (b-a) + a; } int32_t etk::tool::irand(int32_t a, int32_t b) { return (int32_t)(( rand()/(float)RAND_MAX ) * ((float)b-(float)a) + (float)a); } void etk::tool::SortList(etk::Vector &m_listDirectory) { etk::Vector tmpList = m_listDirectory; m_listDirectory.Clear(); for(int32_t iii=0; iii *m_listDirectory[jjj]) { findPos = jjj+1; } } //EWOL_DEBUG("position="<= 'A') { in1 = in1 - 'A' + 'a'; } if (in2 <= 'Z' && in2 >= 'A') { in2 = in2 - 'A' + 'a'; } if (in1 != in2) { return false; } } iii++; input1++; input2++; } return true; } etk::UString etk::tool::SimplifyPath(etk::UString input) { int32_t findStartPos = input.FindForward('/') + 1; int32_t findPos = input.FindForward('/', findStartPos); //TK_DEBUG("Siplify : \"" << input << "\""); int32_t preventBadCode = 0; while (findPos!=-1) { //TK_DEBUG(" string=\"" << input << "\""); //TK_DEBUG(" '/' @" << findPos); if (input.Size()5000) { TK_CRITICAL("ERROR when getting the small path ... this is loop prevention..."); break; } } #ifndef __TARGET_OS__Windows // for the target that supported the Realpath system : char buf[MAX_FILE_NAME]; memset(buf, 0, MAX_FILE_NAME); char * ok = realpath(input.c_str(), buf); if (!ok) { TK_ERROR("Error to get the real path"); input = "/"; } else { input = buf; } #endif //TK_DEBUG(" ==> \"" << input << "\""); return input; }