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
15 #include <afs/param.h>
19 #include "afs_shl_ext.h"
20 #include "make_symbolic_link_dlg.h"
23 #define MAXSIZE 2048 /* most I'll get back from PIOCTL */
28 static char THIS_FILE[] = __FILE__;
31 /////////////////////////////////////////////////////////////////////////////
32 // CMakeMountPointDlg dialog
35 CMakeSymbolicLinkDlg::CMakeSymbolicLinkDlg(CWnd* pParent /*=NULL*/)
38 InitModalIndirect (TaLocale_GetDialogResource (CMakeSymbolicLinkDlg::IDD), pParent);
40 //{{AFX_DATA_INIT(CMakeSymbolicLinkDlg)
47 void CMakeSymbolicLinkDlg::DoDataExchange(CDataExchange* pDX)
49 CDialog::DoDataExchange(pDX);
50 //{{AFX_DATA_MAP(CMakeSymbolicLinkDlg)
51 DDX_Control(pDX, IDOK, m_OK);
52 DDX_Control(pDX, IDC_NAME, m_Name);
53 DDX_Control(pDX, IDC_DIR, m_Dir);
54 DDX_Text(pDX, IDC_NAME, m_strName);
55 DDV_MaxChars(pDX, m_strName, 63);
56 DDX_Text(pDX, IDC_DIR, m_strDir);
57 DDV_MaxChars(pDX, m_strDir, 255);
62 BEGIN_MESSAGE_MAP(CMakeSymbolicLinkDlg, CDialog)
63 //{{AFX_MSG_MAP(CMakeSymbolicLinkDlg)
67 /////////////////////////////////////////////////////////////////////////////
68 // CMakeSymbolicLinkDlg message handlers
70 void CMakeSymbolicLinkDlg::OnOK()
78 m_Name.GetWindowText(strName);
79 m_Dir.GetWindowText(strTarget);
80 if (!IsPathInAfs(m_sBase)) {
81 MessageBeep((UINT)-1);
82 strTarget+=" - Path is not in AFS directory";
83 AfxMessageBox(strTarget,MB_OK);
86 if (m_sBase.GetLength()>MAX_PATH-2)
88 MessageBeep((UINT)-1);
89 ShowMessageBox(IDS_CURRENT_DIRECTORY_PATH_TOO_LONG,MB_OK,IDS_CURRENT_DIRECTORY_PATH_TOO_LONG);
91 if (!SetCurrentDirectory(m_sBase))
93 MessageBeep((UINT)-1);
94 ShowMessageBox(IDS_UNABLE_TO_SET_CURRENT_DIRECTORY,MB_OK,IDS_UNABLE_TO_SET_CURRENT_DIRECTORY);
97 if ((code=MakeSymbolicLink(strName,strTarget))!=0){
98 MessageBeep((UINT)-1);
99 ShowMessageBox(IDS_UNABLE_TO_CREATE_SYMBOLIC_LINK,MB_OK,IDS_UNABLE_TO_CREATE_SYMBOLIC_LINK,code);
105 void CMakeSymbolicLinkDlg::OnChangeName()
108 m_Name.GetWindowText(strName);
109 if (strName.GetLength() > 63) {
110 MessageBeep((UINT)-1);
111 m_Name.SetWindowText(m_strName);
117 void CMakeSymbolicLinkDlg::OnChangeDir()
119 m_Dir.GetWindowText(m_strDir);
120 if (!IsPathInAfs(m_strDir)) {
121 MessageBeep((UINT)-1);
122 m_Dir.SetWindowText(m_strDir);
127 void CMakeSymbolicLinkDlg::CheckEnableOk()
129 BOOL bEnable = FALSE;
131 if ((m_strName.GetLength() > 0) && (m_strDir.GetLength() > 0))
134 m_OK.EnableWindow(bEnable);
137 BOOL CMakeSymbolicLinkDlg::OnInitDialog()
139 CDialog::OnInitDialog();
141 // m_Dir.SetWindowText(m_strDir);
142 // m_Name.SetWindowText(m_strName);
145 return TRUE; // return TRUE unless you set the focus to a control
146 // EXCEPTION: OCX Property Pages should return FALSE