GF_EXPORT FILE *gf_temp_file_new(char ** const fileName) { FILE *res = NULL; #if defined(_WIN32_WCE) TCHAR pPath[MAX_PATH+1]; TCHAR pTemp[MAX_PATH+1]; if (!GetTempPath(MAX_PATH, pPath)) { pPath[0] = '.'; pPath[1] = '.'; } if (GetTempFileName(pPath, TEXT("git"), 0, pTemp)) res = _wfopen(pTemp, TEXT("w+b")); #elif defined(WIN32) res = tmpfile(); if (!res) { wchar_t tmp[MAX_PATH]; GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("[Win32] system failure for tmpfile(): 0x%08x\n", GetLastError())); /*tmpfile() may fail under vista ...*/ if (GetEnvironmentVariableW(L"TEMP", tmp, MAX_PATH)) { wchar_t tmp2[MAX_PATH], *t_file; char* mbs_t_file; gf_rand_init(GF_FALSE); swprintf(tmp2, MAX_PATH, L"gpac_%d_%08x_", _getpid(), gf_rand()); t_file = _wtempnam(tmp, tmp2); mbs_t_file = wcs_to_utf8(t_file); if (!mbs_t_file) return 0; res = gf_fopen(mbs_t_file, "w+b"); if (res) { gpac_file_handles--; if (fileName) { *fileName = gf_strdup(mbs_t_file); } else { GF_LOG(GF_LOG_WARNING, GF_LOG_CORE, ("[Win32] temporary file %s won't be deleted - contact the GPAC team\n", mbs_t_file)); } } gf_free(mbs_t_file); free(t_file); } } #else res = tmpfile(); #endif if (res) { gpac_file_handles++; } return res; }
// le corps est déjà défini // retourne un polynôme unitaire de degré t irreductible dans le corps poly_t poly_randgen_irred(int t, int (*u8rnd)()) { int i; poly_t g; g = poly_alloc(t); poly_set_deg(g, t); poly_set_coeff(g, t, gf_unit()); i = 0; do for (i = 0; i < t; ++i) poly_set_coeff(g, i, gf_rand(u8rnd)); while (poly_degppf(g) < t); return g; }
void Playlist::OnRandomize() { GF_List *new_entries = gf_list_new(); gf_rand_init(GF_FALSE); while (gf_list_count(m_entries)>1) { u32 pos = gf_rand() % (gf_list_count(m_entries)-1); PLEntry *ple = (PLEntry *)gf_list_get(m_entries, pos); gf_list_rem(m_entries, pos); gf_list_add(new_entries, ple); } PLEntry *ple = (PLEntry *)gf_list_get(m_entries, 0); gf_list_rem(m_entries, 0); gf_list_add(new_entries, ple); gf_list_del(m_entries); m_entries = new_entries; m_cur_entry = -1; RefreshList(); }
void wxPlaylist::OnRandomize(wxCommandEvent &WXUNUSED(event) ) { GF_List *new_entries = gf_list_new(); gf_rand_init(0); while (gf_list_count(m_entries)>1) { u32 pos = gf_rand() % (gf_list_count(m_entries)-1); PLEntry *ple = (PLEntry *)gf_list_get(m_entries, pos); gf_list_rem(m_entries, pos); gf_list_add(new_entries, ple); } PLEntry *ple = (PLEntry *)gf_list_get(m_entries, 0); gf_list_rem(m_entries, 0); gf_list_add(new_entries, ple); gf_list_del(m_entries); m_entries = new_entries; m_cur_entry = -1; RefreshList(); }
GF_EXPORT FILE *gf_temp_file_new() { FILE *res=NULL; #if defined(_WIN32_WCE) TCHAR pPath[MAX_PATH+1]; TCHAR pTemp[MAX_PATH+1]; if (!GetTempPath(MAX_PATH, pPath)) { pPath[0] = '.'; pPath[1] = '.'; } if (GetTempFileName(pPath, TEXT("git"), 0, pTemp)) res = _wfopen(pTemp, TEXT("w+b")); #elif defined(WIN32) char tmp[MAX_PATH]; res = tmpfile(); if (!res) { GF_LOG(GF_LOG_WARNING, GF_LOG_CORE, ("[Win32] system failure for tmpfile(): 0x%08x\n", GetLastError())); /*tmpfile() may fail under vista ...*/ if (GetEnvironmentVariable("TEMP",tmp,MAX_PATH)) { char tmp2[MAX_PATH], *t_file; gf_rand_init(GF_FALSE); sprintf(tmp2, "gpac_%08x_", gf_rand()); t_file = tempnam(tmp, tmp2); res = gf_fopen(t_file, "w+b"); free(t_file); } } #else res = tmpfile(); #endif if (res) { gpac_file_handles++; } return res; }