void test_ms_db(void) { #ifdef WIN32 char valid_file[MAX_PATH_STR_LEN] = "data\\video\\bars-mpeg4-aac.m4v"; #else char valid_file[MAX_PATH_STR_LEN] = "data/video/bars-mpeg4-aac.m4v"; #endif MediaScan *s = ms_create(); CU_ASSERT_FATAL(s != NULL); CU_ASSERT(s->npaths == 0); CU_ASSERT(s->on_result == NULL); ms_set_result_callback(s, my_result_callback); CU_ASSERT(s->on_result == my_result_callback); CU_ASSERT(s->on_error == NULL); ms_set_error_callback(s, my_error_callback); CU_ASSERT(s->on_error == my_error_callback); ms_errno = 0; error_called = FALSE; // Okay scan a file result_called = FALSE; ms_scan_file(s, valid_file, TYPE_VIDEO); CU_ASSERT(result_called == TRUE); // now scan the same file again and make sure it is skipped result_called = FALSE; ms_scan_file(s, valid_file, TYPE_VIDEO); CU_ASSERT(result_called == FALSE); // now scan the same file again, this time with a different modification time and make sure it is scanned TouchFile(valid_file); result_called = FALSE; ms_scan_file(s, valid_file, TYPE_VIDEO); CU_ASSERT(result_called == TRUE); ms_destroy(s); } /* test_ms_db() */
static int LoadBinary(size_t length, const unsigned char * binary) { char filename[512]; sprintf(filename, "/tmp/opencl.bin.%lu.%u", (long unsigned int) 1, 0); TouchFile(filename, length); int fd = open(filename, O_RDWR); void * data = mmap((caddr_t)0, length, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0); if(data == MAP_FAILED) { close(fd); return 0; } memcpy(data, (const void *) binary, length); /* the file must have execution priviledges. set execution for use */ int result = chmod(filename, S_IRWXU); if(result != 0) goto UnMapFile; spe_program = spe_image_open(filename); if(spe_program == NULL) { if(errno == EACCES) printf("EACCES\n"); else if(errno == EFAULT) printf("EFAULT\n"); else perror(NULL); goto UnMapFile; } /* we have a good binary */ return 1; UnMapFile: munmap(data, length); close(fd); return 0; }
STATIC RET_T perform( TARGET *targ, DEPEND *dep, DEPEND *impldep, time_t max_time ) /*********************************************************************************/ { CLIST *clist; CLIST *before; RET_T ret; DEPEND *depend; DEPEND *impliedDepend; depend = NULL; impliedDepend = NULL; assert( targ != NULL && dep != NULL ); if( Glob.query ) { ++cListCount; return( RET_WARN ); } if( Glob.touch ) { ++cListCount; ResetExecuted(); if( !targ->attr.symbolic ) { CacheRelease(); if( TouchFile( targ->node.name ) != RET_SUCCESS ) { PrtMsg( ERR | COULD_NOT_TOUCH, targ->node.name ); return( RET_ERROR ); } } targ->touched = true; return( RET_SUCCESS ); } /* means that this is a sufsuf made implicit rule */ if( impldep == NULL ) { clist = dep->clist; depend = dep; impliedDepend = NULL; } else { clist = impldep->clist; depend = targ->depend; impliedDepend = dep; } if( clist == NULL ) { clist = DotCList( DOT_DEFAULT ); if( clist == NULL ) { // No commands in Microsoft and POSIX mode is considered OK // and executed if( Glob.compat_nmake || Glob.compat_posix ) { targ->cmds_done = true; return( RET_SUCCESS ); } if( targ->attr.symbolic != false ) { targ->cmds_done = true; return( RET_SUCCESS ); } if( targ->allow_nocmd ) { /* for UNIX folks: make target symbolic */ targ->attr.symbolic = true; return( RET_SUCCESS ); } PrtMsg( FTL | NO_DEF_CMDS_FOR_MAKE, DotNames[DOT_DEFAULT], targ->node.name ); ExitFatal(); } } if( !Glob.noexec ) { ResetExecuted(); } if( !doneBefore ) { before = DotCList( DOT_BEFORE ); if( before != NULL ) { ++cListCount; if( ExecCList( before ) != RET_SUCCESS ) { PrtMsg( FTL | S_COMMAND_RET_BAD, DotNames[DOT_BEFORE] ); ExitFatal(); } } doneBefore = true; } exPush( targ, depend, impliedDepend ); ret = carryOut( targ, clist, findMaxTime( targ, dep, max_time ) ); exPop(); if( ret == RET_ERROR ) { ExitError(); } return( ret ); }
//this is the thread function which calls the subversion function UINT CCacheDlg::WatchTestThread() { CDirFileEnum direnum(m_sRootPath); m_filelist.RemoveAll(); CString filepath; bool bIsDir = false; while (direnum.NextFile(filepath, &bIsDir)) m_filelist.Add(filepath); CTime starttime = CTime::GetCurrentTime(); GetDlgItem(IDC_STARTTIME)->SetWindowText(starttime.Format(L"%H:%M:%S")); ULONGLONG startticks = GetTickCount64(); CString sNumber; std::random_device rd; std::mt19937 mt(rd()); std::uniform_int_distribution<INT_PTR> dist(0, max(0, m_filelist.GetCount() - 1)); filepath = m_filelist.GetAt(dist(mt)); GetStatusFromRemoteCache(CTGitPath(m_sRootPath), false); for (int i=0; i < 10000; ++i) { filepath = m_filelist.GetAt(dist(mt)); GetDlgItem(IDC_FILEPATH)->SetWindowText(filepath); TouchFile(filepath); CopyRemoveCopy(filepath); sNumber.Format(L"%d", i); GetDlgItem(IDC_DONE)->SetWindowText(sNumber); } // create dummy directories and remove them again several times for (int outer = 0; outer<100; ++outer) { for (int i=0; i<10; ++i) { filepath.Format(L"__MyDummyFolder%d", i); CreateDirectory(m_sRootPath + L'\\' + filepath, nullptr); HANDLE hFile = CreateFile(m_sRootPath + L'\\' + filepath + L"\\file", GENERIC_READ, FILE_SHARE_READ, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); CloseHandle(hFile); SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT, m_sRootPath + L'\\' + filepath + L"\\file", NULL); } Sleep(500); for (int i=0; i<10; ++i) { filepath.Format(L"__MyDummyFolder%d", i); DeleteFile(m_sRootPath + L'\\' + filepath + L"\\file"); RemoveDirectory(m_sRootPath + L'\\' + filepath); } sNumber.Format(L"%d", outer); GetDlgItem(IDC_DONE)->SetWindowText(sNumber); } CTime endtime = CTime::GetCurrentTime(); CString sEnd = endtime.Format(L"%H:%M:%S"); ULONGLONG endticks = GetTickCount64(); CString sEndText; sEndText.Format(L"%s - %I64u ms", (LPCTSTR)sEnd, endticks - startticks); GetDlgItem(IDC_ENDTIME)->SetWindowText(sEndText); return 0; }
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nShowCmd) { MSG msg; HACCEL hAccel; TCHAR arg[MAX_PATH]; TCHAR * pszCmdline; EnableCrashingOnCrashes(); //INITCOMMONCONTROLSEX icx = { sizeof(icx), ICC_ g_hInstance = hInst; // This program requires COM OleInitialize(0); // // Commandline processing // pszCmdline = GetArg(GetCommandLineW(), arg, MAX_PATH); if(pszCmdline && *pszCmdline == '-') { pszCmdline = GetArg(pszCmdline, arg, MAX_PATH); // 'touch' the specified file! if(lstrcmpi(arg, TEXT("-touch")) == 0) { // check to see if it's a quoted filename if(*pszCmdline == '\"') { GetArg(pszCmdline, arg, MAX_PATH); pszCmdline = arg; } if(!TouchFile(pszCmdline)) { HexWinErrorBox(GetLastError(), 0); return 1; } return 0; } else { pszCmdline = GetArg(pszCmdline, arg, MAX_PATH); } } { INITCOMMONCONTROLSEX icex = { sizeof(icex), -1 }; InitCommonControlsEx(&icex); } /*g_Config = OpenConfig(TEXT("mapsize.exe.129082349834.bookmarks")); smeg(g_Config, TEXT("bookmarks.bookmark."), TEXT("mapsize.exe")); SaveConfig(TEXT("oof.config"), g_Config);*/ LoadSettings(); RegisterTabView(); InitMainWnd(); CreateMainWnd(); // open file specified on commmand line? if(pszCmdline && *pszCmdline) { // check to see if it's a quoted filename if(*pszCmdline == '\"') { GetArg(pszCmdline, arg, MAX_PATH); pszCmdline = arg; } if(!HexeditOpenFile(g_hwndMain, pszCmdline, DefaultFileMode()))//HVOF_DEFAULT)) { SendMessage(g_hwndMain, WM_COMMAND, IDM_FILE_NEW, 0); } } // automatically create new document if none specified else { SendMessage(g_hwndMain, WM_COMMAND, IDM_FILE_NEW, 0); } InitDockingBars(g_hwndMain); if(g_fRestoreWinPos) nShowCmd = SW_SHOW; ShowWindow(g_hwndMain, nShowCmd); // force any floating popups (i.e. the DOCKWNDs) to // become visible at the same time //ShowOwnedPopups(g_hwndMain, TRUE); DockWnd_ShowDeferredPopups(g_hwndMain); // // load keyboard accelerator table // hAccel = LoadAccelerators(GetModuleHandle(0)/*g_hResourceModule*/, MAKEINTRESOURCE(IDR_ACCELERATOR1)); // // message-pump // while(GetMessage(&msg, 0, 0, 0) > 0) { if(!TranslateAccelerator(g_hwndMain, hAccel, &msg)) { if( !IsDialogMessage(g_hwndSearch, &msg) && !IsDialogMessage(g_hwndGoto, &msg) && !DockWnd_IsDialogMessage(g_hwndMain, DWID_TYPEVIEW, &msg) && !DockWnd_IsDialogMessage(g_hwndMain, DWID_SEARCHBAR, &msg) && !DockWnd_IsDialogMessage(g_hwndMain, DWID_HIGHLIGHT, &msg) ) { TranslateMessage(&msg); DispatchMessage(&msg); } } } SaveSettings(); // Shutdown COM OleUninitialize(); return 0; }
//this is the thread function which calls the subversion function UINT CCacheDlg::WatchTestThread() { CDirFileEnum direnum(m_sRootPath); m_filelist.RemoveAll(); CString filepath; bool bIsDir = false; while (direnum.NextFile(filepath, &bIsDir)) m_filelist.Add(filepath); CTime starttime = CTime::GetCurrentTime(); GetDlgItem(IDC_STARTTIME)->SetWindowText(starttime.Format(_T("%H:%M:%S"))); int filecounter = 0; DWORD startticks = GetTickCount(); CString sNumber; srand(GetTickCount()); filepath = m_filelist.GetAt(rand() % m_filelist.GetCount()); GetStatusFromRemoteCache(CTGitPath(m_sRootPath), false); for (int i=0; i < 10000; ++i) { filepath = m_filelist.GetAt(rand() % m_filelist.GetCount()); GetDlgItem(IDC_FILEPATH)->SetWindowText(filepath); TouchFile(filepath); CopyRemoveCopy(filepath); sNumber.Format(_T("%d"), i); GetDlgItem(IDC_DONE)->SetWindowText(sNumber); } // create dummy directories and remove them again several times for (int outer = 0; outer<100; ++outer) { for (int i=0; i<10; ++i) { filepath.Format(_T("__MyDummyFolder%d"), i); CreateDirectory(m_sRootPath+_T("\\")+filepath, NULL); HANDLE hFile = CreateFile(m_sRootPath+_T("\\")+filepath+_T("\\file"), GENERIC_READ, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); CloseHandle(hFile); SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT, m_sRootPath+_T("\\")+filepath+_T("\\file"), NULL); } Sleep(500); for (int i=0; i<10; ++i) { filepath.Format(_T("__MyDummyFolder%d"), i); DeleteFile(m_sRootPath+_T("\\")+filepath+_T("\\file")); RemoveDirectory(m_sRootPath+_T("\\")+filepath); } sNumber.Format(_T("%d"), outer); GetDlgItem(IDC_DONE)->SetWindowText(sNumber); } CTime endtime = CTime::GetCurrentTime(); CString sEnd = endtime.Format(_T("%H:%M:%S")); DWORD endticks = GetTickCount(); CString sEndText; sEndText.Format(_T("%s - %d ms"), sEnd, endticks-startticks); GetDlgItem(IDC_ENDTIME)->SetWindowText(sEndText); return 0; }
void Ide::EditorEdit() { AddHistory(); TouchFile(editfile); }