mirror of
https://github.com/fadden/ciderpress.git
synced 2024-11-23 11:33:58 +00:00
759f0d820f
This updates the various dialogs to use the new functions. The help system should be fully functional now.
69 lines
2.5 KiB
C++
69 lines
2.5 KiB
C++
/*
|
|
* CiderPress
|
|
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
|
|
* See the file LICENSE for distribution terms.
|
|
*/
|
|
#include "stdafx.h"
|
|
#include "NewFolderDialog.h"
|
|
|
|
BEGIN_MESSAGE_MAP(NewFolderDialog, CDialog)
|
|
ON_WM_HELPINFO()
|
|
END_MESSAGE_MAP()
|
|
|
|
void NewFolderDialog::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
/*
|
|
* It is very important to keep '\\' out of the folder path, because it allows
|
|
* for all sorts of behavior (like "..\foo" or "D:\ack") that the caller
|
|
* might not be expecting. For example, if it's displaying a tree, it
|
|
* might assume that the folder goes under the currently selected node.
|
|
*
|
|
* Under WinNT, '/' is regarded as equivalent to '\', so we have to block
|
|
* that as well.
|
|
*
|
|
* Other characters (':') are also dangerous, but so long as we start with
|
|
* a valid path, Windows will prevent them from being used where they are
|
|
* inappropriate.
|
|
*/
|
|
|
|
if (!pDX->m_bSaveAndValidate)
|
|
DDX_Text(pDX, IDC_NEWFOLDER_CURDIR, fCurrentFolder);
|
|
|
|
DDX_Text(pDX, IDC_NEWFOLDER_NAME, fNewFolder);
|
|
|
|
/* validate the new folder by creating it */
|
|
if (pDX->m_bSaveAndValidate) {
|
|
if (fNewFolder.IsEmpty()) {
|
|
MessageBox(L"No name entered, not creating new folder.",
|
|
L"CiderPress", MB_OK);
|
|
// fall out of DoModal with fFolderCreated==false
|
|
} else if (fNewFolder.Find('\\') >= 0 ||
|
|
fNewFolder.Find('/') >= 0)
|
|
{
|
|
MessageBox(L"Folder names may not contain '/' or '\\'.",
|
|
L"CiderPress", MB_OK);
|
|
pDX->Fail();
|
|
} else {
|
|
fNewFullPath = fCurrentFolder;
|
|
if (fNewFullPath.Right(1) != "\\")
|
|
fNewFullPath += "\\";
|
|
fNewFullPath += fNewFolder;
|
|
LOGI("CREATING '%ls'", (LPCWSTR) fNewFullPath);
|
|
if (!::CreateDirectory(fNewFullPath, NULL)) {
|
|
/* show the sometimes-bizarre Windows error string */
|
|
CString msg, errStr, failed;
|
|
DWORD dwerr = ::GetLastError();
|
|
GetWin32ErrorString(dwerr, &errStr);
|
|
msg.Format(L"Unable to create folder '%ls': %ls",
|
|
(LPCWSTR) fNewFolder, (LPCWSTR) errStr);
|
|
failed.LoadString(IDS_FAILED);
|
|
MessageBox(msg, failed, MB_OK | MB_ICONERROR);
|
|
pDX->Fail();
|
|
} else {
|
|
/* success! */
|
|
fFolderCreated = true;
|
|
}
|
|
}
|
|
}
|
|
}
|