2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 #include <afs/param.h>
16 #include "afs_shl_ext.h"
17 #include "make_symbolic_link_dlg.h"
20 #define MAXSIZE 2048 /* most I'll get back from PIOCTL */
25 static char THIS_FILE[] = __FILE__;
28 /////////////////////////////////////////////////////////////////////////////
29 // CMakeMountPointDlg dialog
32 CMakeSymbolicLinkDlg::CMakeSymbolicLinkDlg(CWnd* pParent /*=NULL*/)
35 InitModalIndirect (TaLocale_GetDialogResource (CMakeSymbolicLinkDlg::IDD), pParent);
37 //{{AFX_DATA_INIT(CMakeSymbolicLinkDlg)
44 void CMakeSymbolicLinkDlg::DoDataExchange(CDataExchange* pDX)
46 CDialog::DoDataExchange(pDX);
47 //{{AFX_DATA_MAP(CMakeSymbolicLinkDlg)
48 DDX_Control(pDX, IDOK, m_OK);
49 DDX_Control(pDX, IDC_NAME, m_Name);
50 DDX_Control(pDX, IDC_DIR, m_Dir);
51 DDX_Text(pDX, IDC_NAME, m_strName);
52 DDV_MaxChars(pDX, m_strName, 63);
53 DDX_Text(pDX, IDC_DIR, m_strDir);
54 DDV_MaxChars(pDX, m_strDir, 63);
59 BEGIN_MESSAGE_MAP(CMakeSymbolicLinkDlg, CDialog)
60 //{{AFX_MSG_MAP(CMakeSymbolicLinkDlg)
64 /////////////////////////////////////////////////////////////////////////////
65 // CMakeSymbolicLinkDlg message handlers
67 void CMakeSymbolicLinkDlg::OnOK()
75 m_Name.GetWindowText(strName);
76 m_Dir.GetWindowText(strDir);
77 if (!IsPathInAfs(m_sBase)) {
78 MessageBeep((UINT)-1);
79 strDir+=" - Path is not in AFS directory";
80 AfxMessageBox(strDir,MB_OK);
83 if (m_sBase.GetLength()>MAX_PATH-2)
85 MessageBeep((UINT)-1);
86 ShowMessageBox(IDS_CURRENT_DIRECTORY_PATH_TOO_LONG,MB_OK,IDS_CURRENT_DIRECTORY_PATH_TOO_LONG);
88 if (!SetCurrentDirectory(m_sBase))
90 MessageBeep((UINT)-1);
91 ShowMessageBox(IDS_UNABLE_TO_SET_CURRENT_DIRECTORY,MB_OK,IDS_UNABLE_TO_SET_CURRENT_DIRECTORY);
94 if ((code=MakeSymbolicLink(strName,strDir))!=0){
95 MessageBeep((UINT)-1);
96 ShowMessageBox(IDS_UNABLE_TO_CREATE_SYMBOLIC_LINK,MB_OK,IDS_UNABLE_TO_CREATE_SYMBOLIC_LINK,code);
102 void CMakeSymbolicLinkDlg::OnChangeName()
105 m_Name.GetWindowText(strName);
106 if (strName.GetLength() > 63) {
107 MessageBeep((UINT)-1);
108 m_Name.SetWindowText(m_strName);
114 void CMakeSymbolicLinkDlg::OnChangeDir()
116 m_Dir.GetWindowText(m_strDir);
117 if (!IsPathInAfs(m_strDir)) {
118 MessageBeep((UINT)-1);
119 m_Dir.SetWindowText(m_strDir);
124 void CMakeSymbolicLinkDlg::CheckEnableOk()
126 BOOL bEnable = FALSE;
128 if ((m_strName.GetLength() > 0) && (m_strDir.GetLength() > 0))
131 m_OK.EnableWindow(bEnable);
134 BOOL CMakeSymbolicLinkDlg::OnInitDialog()
136 CDialog::OnInitDialog();
138 // m_Dir.SetWindowText(m_strDir);
139 // m_Name.SetWindowText(m_strName);
142 return TRUE; // return TRUE unless you set the focus to a control
143 // EXCEPTION: OCX Property Pages should return FALSE