Beispiel #1
0
TEST(TiglCommonFunctions, isFileReadable)
{
    ASSERT_TRUE(IsFileReadable("TestData/nacelle.stp"));
    ASSERT_FALSE(IsFileReadable("invalidfile.txt"));
}
Beispiel #2
0
//Replay movie dialog
INT_PTR CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	OPENFILENAME ofn;
	char szChoice[MAX_PATH]={0};
	char filename[MAX_PATH] = "";

	switch(uMsg)
	{
	case WM_INITDIALOG:
	{
		SendDlgItemMessage(hwndDlg, IDC_CHECK_READONLY, BM_SETCHECK, replayreadonly?BST_CHECKED:BST_UNCHECKED, 0);			
		
		//Clear fields
		SetWindowText(GetDlgItem(hwndDlg, IDC_MLENGTH), "");
		SetWindowText(GetDlgItem(hwndDlg, IDC_MFRAMES), "");
		SetWindowText(GetDlgItem(hwndDlg, IDC_MRERECORDCOUNT), "");
		SetWindowText(GetDlgItem(hwndDlg, IDC_MROM), "");

		extern char curMovieFilename[512];
		strncpy(playfilename, curMovieFilename, MAX_PATH);
		playfilename[MAX_PATH-1] = '\0';

		SetWindowText(GetDlgItem(hwndDlg, PM_FILENAME), playfilename);
		SetFocus(GetDlgItem(hwndDlg, PM_FILENAME));
		SendMessage(GetDlgItem(hwndDlg, PM_FILENAME), EM_SETSEL, 0, -1); // select all

	}	return FALSE;

	case WM_COMMAND:	
		int wID = LOWORD(wParam);
		switch(wID)
		{
			case ID_BROWSE:

				ZeroMemory(&ofn, sizeof(ofn));
				ofn.lStructSize = sizeof(ofn);
				ofn.hwndOwner = hwndDlg;
				ofn.lpstrFilter = "Desmume Movie File (*.dsm)\0*.dsm\0All files(*.*)\0*.*\0\0";
				ofn.nFilterIndex = 1;
				ofn.lpstrFile =  filename;
				ofn.lpstrTitle = "Replay Movie from File";
				ofn.nMaxFile = MAX_PATH;
				ofn.lpstrDefExt = "dsm";
				ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
				if(GetOpenFileName(&ofn))
					SetDlgItemText(hwndDlg, PM_FILENAME, filename);
				return true;
		
			case IDC_CHECK_READONLY:
				replayreadonly = IsDlgButtonChecked(hwndDlg, IDC_CHECK_READONLY) != 0;
				return true;

			case IDOK:	
				FCEUI_LoadMovie(playfilename, replayreadonly, false, 80000);
				ZeroMemory(&playfilename, sizeof(playfilename));
				EndDialog(hwndDlg, 0);
				return true;

			case IDCANCEL:
				ZeroMemory(&playfilename, sizeof(playfilename));
				EndDialog(hwndDlg, 0);
				return true;

			case PM_FILENAME:
				switch(HIWORD(wParam))
				{
					case EN_CHANGE:
					{
						FixRelativeMovieFilename(hwndDlg, PM_FILENAME);

						// disable the OK button if we can't read the file
						char filename [MAX_PATH];
						GetDlgItemText(hwndDlg,PM_FILENAME,filename,MAX_PATH);
						EnableWindow(GetDlgItem(hwndDlg, IDOK), IsFileReadable(filename));
						strcpy(playfilename, filename);
						Describe(hwndDlg);

						// force read-only to be checked if we can't write the file
						if(!IsFileWritable(filename))
						{
							CheckDlgButton(hwndDlg, IDC_CHECK_READONLY, BST_CHECKED);
							EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_READONLY), FALSE);
						}
						else
						{
							EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_READONLY), TRUE);
						}
					}
					break;
				}
				break;

		}
	}

	return false;
}