bool CreateRepositoryCommand::Execute()
{
	CString folder = this->orgCmdLinePath.GetWinPath();
	if (folder.IsEmpty())
		folder = g_Git.m_CurrentDir;
	if (folder.IsEmpty())
	{
		GetCurrentDirectory(MAX_PATH, folder.GetBuffer(MAX_PATH));
		folder.ReleaseBuffer();
	}
	if (CheckSpecialFolder(folder))
	{
		CString message;
		message.Format(IDS_WARN_GITINIT_SPECIALFOLDER, folder);
		if (CMessageBox::Show(hwndExplorer, message, _T("TortoiseGit"), 1, IDI_ERROR, CString(MAKEINTRESOURCE(IDS_ABORTBUTTON)), CString(MAKEINTRESOURCE(IDS_PROCEEDBUTTON))) == 1)
			return false;
	}

	CCreateRepoDlg dlg;
	dlg.m_folder = folder;
	if(dlg.DoModal() == IDOK)
	{
		CString message;
		message.Format(IDS_WARN_GITINIT_FOLDERNOTEMPTY, folder);
		if (dlg.m_bBare && PathIsDirectory(folder) && !PathIsDirectoryEmpty(folder) && CMessageBox::Show(hwndExplorer, message, _T("TortoiseGit"), 1, IDI_ERROR, CString(MAKEINTRESOURCE(IDS_ABORTBUTTON)), CString(MAKEINTRESOURCE(IDS_PROCEEDBUTTON))) == 1)
		{
			return false;
		}

		git_repository *repo;
		git_repository_init_options options = GIT_REPOSITORY_INIT_OPTIONS_INIT;
		options.flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE;
		options.flags |= dlg.m_bBare ? GIT_REPOSITORY_INIT_BARE : 0;
		CStringA path(CUnicodeUtils::GetMulti(folder, CP_UTF8));
		if (git_repository_init_ext(&repo, path, &options))
		{
			CMessageBox::Show(hwndExplorer, CGit::GetLibGit2LastErr(_T("Could not initialize a new repository.")), _T("TortoiseGit"), MB_OK | MB_ICONERROR);
			return false;
		}
		git_repository_free(repo);

		if (!dlg.m_bBare)
			CShellUpdater::Instance().AddPathForUpdate(orgCmdLinePath);
		CString str;
		str.Format(IDS_PROC_REPOCREATED, folder);
		CMessageBox::Show(hwndExplorer, str, _T("TortoiseGit"), MB_OK | MB_ICONINFORMATION);
		return true;
	}
	return false;
}
Beispiel #2
0
BOOL CExportDlg::OnInitDialog()
{
	CHorizontalResizableStandAloneDialog::OnInitDialog();
	CAppUtils::MarkWindowAsUnpinnable(m_hWnd);

	m_sExportDirOrig = m_strExportDirectory;
	m_bAutoCreateTargetName = !PathIsDirectoryEmpty(m_sExportDirOrig);

	AddAnchor(IDC_REPOGROUP, TOP_LEFT, TOP_RIGHT);
	AddAnchor(IDC_EXPORT_CHECKOUTDIR, TOP_LEFT);
	AddAnchor(IDC_CHECKOUTDIRECTORY_BROWSE, TOP_RIGHT);
	AddAnchor(IDC_CHECKOUTDIRECTORY, TOP_LEFT, TOP_RIGHT);

	AddAnchor(IDOK, BOTTOM_RIGHT);
	AddAnchor(IDCANCEL, BOTTOM_RIGHT);
	AddAnchor(IDHELP, BOTTOM_RIGHT);

	CString sWindowTitle;
	GetWindowText(sWindowTitle);
	CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle);

	CHOOSE_VERSION_ADDANCHOR;
	this->AddOthersToAnchor();
	Init();
	if(this->m_Revision.IsEmpty())
	{
		SetDefaultChoose(IDC_RADIO_HEAD);
	}
	else
	{
		SetDefaultChoose(IDC_RADIO_VERSION);
		this->GetDlgItem(IDC_COMBOBOXEX_VERSION)->SetWindowTextW(m_Revision);
	}

	m_tooltips.Create(this);
	m_tooltips.AddTool(IDC_CHECKOUTDIRECTORY, IDS_CHECKOUT_TT_DIR);

	SHAutoComplete(GetDlgItem(IDC_CHECKOUTDIRECTORY)->m_hWnd, SHACF_FILESYSTEM);

	if ((m_pParentWnd==NULL)&&(hWndExplorer))
		CenterWindow(CWnd::FromHandle(hWndExplorer));
	EnableSaveRestore(_T("ExportDlg"));
	return TRUE;
}
bool CreateRepositoryCommand::Execute()
{
	CString folder = this->orgCmdLinePath.GetWinPath();
	CCreateRepoDlg dlg;
	dlg.m_folder = folder;
	if(dlg.DoModal() == IDOK)
	{
		CString message;
		message.Format(IDS_WARN_GITINIT_FOLDERNOTEMPTY, folder);
		if (!PathIsDirectoryEmpty(folder) && CMessageBox::Show(hwndExplorer, message, _T("TortoiseGit"), 1, IDI_ERROR, CString(MAKEINTRESOURCE(IDS_ABORTBUTTON)), CString(MAKEINTRESOURCE(IDS_PROCEEDBUTTON))) == 1)
		{
			return false;
		}

		CGit git;
		git.m_CurrentDir = this->orgCmdLinePath.GetWinPath();
		CString output;
		int ret;

		if (dlg.m_bBare)
			ret = git.Run(_T("git.exe init-db --bare"), &output, CP_UTF8);
		else
			ret = git.Run(_T("git.exe init-db"), &output, CP_UTF8);

		if (output.IsEmpty()) output = _T("git.Run() had no output");

		if (ret)
		{
			CMessageBox::Show(hwndExplorer, output, _T("TortoiseGit"), MB_ICONERROR);
			return false;
		}
		else
		{
			if (!dlg.m_bBare)
				CShellUpdater::Instance().AddPathForUpdate(orgCmdLinePath);
			CMessageBox::Show(hwndExplorer, output, _T("TortoiseGit"), MB_OK | MB_ICONINFORMATION);
		}
		return true;
	}
	return false;
}
Beispiel #4
0
void CExportDlg::OnBnClickedCheckoutdirectoryBrowse()
{
    m_tooltips.Pop();   // hide the tooltips
    //
    // Create a folder browser dialog. If the user selects OK, we should update
    // the local data members with values from the controls, copy the checkout
    // directory from the browse folder, then restore the local values into the
    // dialog controls.
    //
    CBrowseFolder browseFolder;
    browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
    CString strCheckoutDirectory = m_strExportDirectory;
    if (browseFolder.Show(GetSafeHwnd(), strCheckoutDirectory) == CBrowseFolder::OK)
    {
        UpdateData(TRUE);
        m_strExportDirectory = strCheckoutDirectory;
        m_sExportDirOrig = m_strExportDirectory;
        m_bAutoCreateTargetName = !(PathIsDirectoryEmpty(m_sExportDirOrig) || !PathFileExists(m_sExportDirOrig));
        UpdateData(FALSE);
        DialogEnableWindow(IDOK, !m_strExportDirectory.IsEmpty());
    }
}
Beispiel #5
0
bool PlayData::LoadMusicData( const wchar_t* const pFilePath )
{
	WIN32_FIND_DATA FindFileData;
	HANDLE hFind = INVALID_HANDLE_VALUE;

	// ──────────────────────────────
	//  Exception
	// ──────────────────────────────
	// Directory does not exist?
	if (( hFind = FindFirstFile( pFilePath, &FindFileData )) == INVALID_HANDLE_VALUE )
	{ 
		WARN( L"폴더가 존재하지 않습니다. ( %s )", pFilePath );
		return false;
	}

	// Directory is empty?
	if ( PathIsDirectoryEmpty( L"Notes\\" ))
	{
		WARN( L"노트 데이터 폴더가 비어있습니다. ( %s )", pFilePath );
		return false;
	}

	// ──────────────────────────────
	//  Load data
	// ──────────────────────────────
	const wchar_t* const pTag[] =
	{
		L"\\info.txt",
		L"\\enemy.png",
		L"\\background.png",
		L"\\cover.png",
		L"\\music.wav",
		L"\\note.txt",
	};

	int tagCount = _countof( pTag );

	hFind = FindFirstFile( pFilePath, &FindFileData );
	FindNextFile( hFind, &FindFileData );

	// Save all of path data or info data to repository.
	while ( FindNextFile( hFind, &FindFileData ) != 0 )
	{
		CMusicData musicData;
		
		for ( int i = 0; i <tagCount; i++ )
		{
			musicData.tagPath[i] = pFilePath;
			musicData.tagPath[i].pop_back( );

			musicData.tagPath[i] += FindFileData.cFileName;
			musicData.tagPath[i] += pTag[i];
		}

		LoadMusicInfo( &musicData );
		g_mdRepository.push_back( std::move( musicData ));
	}

	FindClose( hFind );
	return true;
}
Beispiel #6
0
BOOL CExportDlg::OnInitDialog()
{
    CResizableStandAloneDialog::OnInitDialog();
    CAppUtils::MarkWindowAsUnpinnable(m_hWnd);

    ExtendFrameIntoClientArea(IDC_REVISIONGROUP);
    m_aeroControls.SubclassOkCancelHelp(this);

    m_sExportDirOrig = m_strExportDirectory;
    m_bAutoCreateTargetName = !(PathIsDirectoryEmpty(m_sExportDirOrig) || !PathFileExists(m_sExportDirOrig));

    AdjustControlSize(IDC_NOEXTERNALS);
    AdjustControlSize(IDC_IGNOREKEYWORDS);
    AdjustControlSize(IDC_REVISION_HEAD);
    AdjustControlSize(IDC_REVISION_N);

    AddAnchor(IDC_REPOGROUP, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_REPOLABEL, TOP_LEFT);
    AddAnchor(IDC_URLCOMBO, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_BROWSE, TOP_RIGHT);
    AddAnchor(IDC_EXPORT_CHECKOUTDIR, TOP_LEFT);
    AddAnchor(IDC_CHECKOUTDIRECTORY, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_CHECKOUTDIRECTORY_BROWSE, TOP_RIGHT);
    AddAnchor(IDC_DEPTH, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_NOEXTERNALS, TOP_LEFT);
    AddAnchor(IDC_IGNOREKEYWORDS, TOP_LEFT);
    AddAnchor(IDC_EOLLABEL, TOP_LEFT);
    AddAnchor(IDC_EOLCOMBO, TOP_LEFT);

    AddAnchor(IDC_REVISIONGROUP, TOP_LEFT, BOTTOM_RIGHT);
    AddAnchor(IDC_REVISION_HEAD, TOP_LEFT);
    AddAnchor(IDC_REVISION_N, TOP_LEFT);
    AddAnchor(IDC_REVISION_NUM, TOP_LEFT);
    AddAnchor(IDC_SHOW_LOG, TOP_LEFT);

    AddAnchor(IDOK, BOTTOM_RIGHT);
    AddAnchor(IDCANCEL, BOTTOM_RIGHT);
    AddAnchor(IDHELP, BOTTOM_RIGHT);

    // save the provided url since the url combo
    // will change that below
    CString origurl = m_URL;
    m_URLCombo.SetURLHistory(true, true);
    m_URLCombo.LoadHistory(L"Software\\TortoiseSVN\\History\\repoURLS", L"url");
    m_URLCombo.SetCurSel(0);

    m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_INFINITE)));
    m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_IMMEDIATE)));
    m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_FILES)));
    m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_EMPTY)));
    m_depthCombo.SetCurSel(0);

    // set radio buttons according to the revision
    SetRevision(Revision);

    m_editRevision.SetWindowText(L"");

    if (!origurl.IsEmpty())
        m_URLCombo.SetWindowText(origurl);
    else
    {
        // if there is an url on the clipboard, use that url as the default.
        CAppUtils::AddClipboardUrlToWindow(m_URLCombo.GetSafeHwnd());
    }
    GetDlgItem(IDC_BROWSE)->EnableWindow(!m_URLCombo.GetString().IsEmpty());

    m_tooltips.AddTool(IDC_CHECKOUTDIRECTORY, IDS_CHECKOUT_TT_DIR);
    m_tooltips.AddTool(IDC_EOLCOMBO, IDS_EXPORT_TT_EOL);

    SHAutoComplete(GetDlgItem(IDC_CHECKOUTDIRECTORY)->m_hWnd, SHACF_FILESYSTEM);

    // fill the combobox with the choices of eol styles
    m_eolCombo.AddString(L"default");
    m_eolCombo.AddString(L"CRLF");
    m_eolCombo.AddString(L"LF");
    m_eolCombo.AddString(L"CR");
    m_eolCombo.SelectString(0, L"default");

    if (!Revision.IsHead())
    {
        // if the revision is not HEAD, change the radio button and
        // fill in the revision in the edit box
        CString temp;
        temp.Format(L"%ld", (LONG)Revision);
        m_editRevision.SetWindowText(temp);
        CheckRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N, IDC_REVISION_N);
    }

    DialogEnableWindow(IDOK, !m_strExportDirectory.IsEmpty());

    if ((m_pParentWnd==NULL)&&(GetExplorerHWND()))
        CenterWindow(CWnd::FromHandle(GetExplorerHWND()));
    EnableSaveRestore(L"ExportDlg");
    return TRUE;
}
Beispiel #7
0
void CExportDlg::OnOK()
{
    if (!UpdateData(TRUE))
        return; // don't dismiss dialog (error message already shown by MFC framework)

    if (::IsWindow(m_pLogDlg->GetSafeHwnd())&&(m_pLogDlg->IsWindowVisible()))
    {
        m_pLogDlg->SendMessage(WM_CLOSE);
        return;
    }

    // check it the export path is a valid windows path
    CTSVNPath ExportDirectory;
    if (::PathIsRelative(m_strExportDirectory))
    {
        ExportDirectory = CTSVNPath(sOrigCWD);
        ExportDirectory.AppendPathString(L"\\" + m_strExportDirectory);
        m_strExportDirectory = ExportDirectory.GetWinPathString();
    }
    else
        ExportDirectory = CTSVNPath(m_strExportDirectory);
    if (!ExportDirectory.IsValidOnWindows())
    {
        ShowEditBalloon(IDC_CHECKOUTDIRECTORY, IDS_ERR_NOVALIDPATH, IDS_ERR_ERROR, TTI_ERROR);
        return;
    }

    // check if the specified revision is valid
    if (GetCheckedRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N) == IDC_REVISION_HEAD)
    {
        Revision = SVNRev(L"HEAD");
    }
    else
        Revision = SVNRev(m_sRevision);
    if (!Revision.IsValid())
    {
        ShowEditBalloon(IDC_REVISION_NUM, IDS_ERR_INVALIDREV, IDS_ERR_ERROR, TTI_ERROR);
        return;
    }
    bool bAutoCreateTargetName = m_bAutoCreateTargetName;
    m_bAutoCreateTargetName = false;

    m_URLCombo.SaveHistory();
    m_URL = m_URLCombo.GetString();

    // we need an url to export from - local paths won't work
    if (!SVN::PathIsURL(CTSVNPath(m_URL)))
    {
        m_tooltips.ShowBalloon(IDC_URLCOMBO, IDS_ERR_MUSTBEURL, IDS_ERR_ERROR, TTI_ERROR);
        m_bAutoCreateTargetName = bAutoCreateTargetName;
        return;
    }

    if (m_strExportDirectory.IsEmpty())
    {
        m_bAutoCreateTargetName = bAutoCreateTargetName;
        return;
    }

    // if the export directory does not exist, where should we export to?
    // We ask if the directory should be created...
    if (!PathFileExists(m_strExportDirectory))
    {
        CPathUtils::MakeSureDirectoryPathExists(m_strExportDirectory);
    }

    // if the directory we should export to is not empty, show a warning:
    // maybe the user doesn't want to overwrite the existing files.
    if (!PathIsDirectoryEmpty(m_strExportDirectory))
    {
        CString message;
        message.Format(CString(MAKEINTRESOURCE(IDS_WARN_FOLDERNOTEMPTY)),(LPCTSTR)m_strExportDirectory);
        CTaskDialog taskdlg(message,
                            CString(MAKEINTRESOURCE(IDS_WARN_FOLDERNOTEMPTY_TASK2)),
                            L"TortoiseSVN",
                            0,
                            TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT);
        taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_WARN_FOLDERNOTEMPTY_TASK3_1)));
        taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_WARN_FOLDERNOTEMPTY_TASK4)));
        taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON);
        taskdlg.SetDefaultCommandControl(2);
        taskdlg.SetMainIcon(TD_WARNING_ICON);
        bool doIt = (taskdlg.DoModal(GetExplorerHWND()) == 1);

        if (!doIt)
        {
            m_bAutoCreateTargetName = bAutoCreateTargetName;
            return;     //don't dismiss the dialog
        }
    }
    m_eolCombo.GetWindowText(m_eolStyle);
    if (m_eolStyle.Compare(L"default")==0)
        m_eolStyle.Empty();

    switch (m_depthCombo.GetCurSel())
    {
    case 0:
        m_depth = svn_depth_infinity;
        break;
    case 1:
        m_depth = svn_depth_immediates;
        break;
    case 2:
        m_depth = svn_depth_files;
        break;
    case 3:
        m_depth = svn_depth_empty;
        break;
    default:
        m_depth = svn_depth_empty;
        break;
    }

    UpdateData(FALSE);

    CRegDWORD regNoExt(L"Software\\TortoiseSVN\\noext");
    regNoExt = m_bNoExternals;

    CResizableStandAloneDialog::OnOK();
}