Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / client_exp / make_symbolic_link_dlg.cpp
blobacf65982ba1cd8d7426e19f7447c8cb6648e9f42
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
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
8 */
10 #include "stdafx.h"
11 #include <winsock2.h>
12 #include <ws2tcpip.h>
14 extern "C" {
15 #include <afs/param.h>
16 #include <afs/stds.h>
19 #include "afs_shl_ext.h"
20 #include "make_symbolic_link_dlg.h"
21 #include "gui2fs.h"
22 #include "msgs.h"
24 #ifdef _DEBUG
25 #define new DEBUG_NEW
26 #undef THIS_FILE
27 static char THIS_FILE[] = __FILE__;
28 #endif
30 /////////////////////////////////////////////////////////////////////////////
31 // CMakeMountPointDlg dialog
34 CMakeSymbolicLinkDlg::CMakeSymbolicLinkDlg(CWnd* pParent /*=NULL*/)
35 : CDialog()
37 InitModalIndirect (TaLocale_GetDialogResource (CMakeSymbolicLinkDlg::IDD), pParent);
39 //{{AFX_DATA_INIT(CMakeSymbolicLinkDlg)
40 m_strName = _T("");
41 m_strDir = _T("");
42 //}}AFX_DATA_INIT
46 void CMakeSymbolicLinkDlg::DoDataExchange(CDataExchange* pDX)
48 CDialog::DoDataExchange(pDX);
49 //{{AFX_DATA_MAP(CMakeSymbolicLinkDlg)
50 DDX_Control(pDX, IDOK, m_OK);
51 DDX_Control(pDX, IDC_NAME, m_Name);
52 DDX_Control(pDX, IDC_DIR, m_Dir);
53 DDX_Text(pDX, IDC_NAME, m_strName);
54 DDV_MaxChars(pDX, m_strName, 63);
55 DDX_Text(pDX, IDC_DIR, m_strDir);
56 DDV_MaxChars(pDX, m_strDir, 255);
57 //}}AFX_DATA_MAP
61 BEGIN_MESSAGE_MAP(CMakeSymbolicLinkDlg, CDialog)
62 //{{AFX_MSG_MAP(CMakeSymbolicLinkDlg)
63 //}}AFX_MSG_MAP
64 END_MESSAGE_MAP()
66 /////////////////////////////////////////////////////////////////////////////
67 // CMakeSymbolicLinkDlg message handlers
69 void CMakeSymbolicLinkDlg::OnOK()
71 UINT code;
72 UpdateData(TRUE);
73 CString strName;
74 CString strTarget;
75 m_Name.GetWindowText(strName);
76 m_Dir.GetWindowText(strTarget);
77 if (!IsPathInAfs(m_sBase)) {
78 MessageBeep((UINT)-1);
79 strTarget+=" - Path is not in AFS directory";
80 AfxMessageBox(strTarget,MB_ICONERROR);
81 return;
83 if (m_sBase.GetLength()>MAX_PATH-2)
85 MessageBeep((UINT)-1);
86 ShowMessageBox(IDS_CURRENT_DIRECTORY_PATH_TOO_LONG,MB_ICONERROR,IDS_CURRENT_DIRECTORY_PATH_TOO_LONG);
88 if (!SetCurrentDirectory(m_sBase))
90 MessageBeep((UINT)-1);
91 ShowMessageBox(IDS_UNABLE_TO_SET_CURRENT_DIRECTORY,MB_ICONERROR,IDS_UNABLE_TO_SET_CURRENT_DIRECTORY);
92 return;
94 if ((code=MakeSymbolicLink(strName,strTarget))!=0){
95 MessageBeep((UINT)-1);
96 ShowMessageBox(IDS_UNABLE_TO_CREATE_SYMBOLIC_LINK,MB_ICONERROR,IDS_UNABLE_TO_CREATE_SYMBOLIC_LINK,GetAfsError(code, strName));
97 return;
99 CDialog::OnOK();
102 void CMakeSymbolicLinkDlg::OnChangeName()
104 CString strName;
105 m_Name.GetWindowText(strName);
106 if (strName.GetLength() > 63) {
107 MessageBeep((UINT)-1);
108 m_Name.SetWindowText(m_strName);
109 } else
110 m_strName = strName;
111 CheckEnableOk();
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);
121 CheckEnableOk();
124 void CMakeSymbolicLinkDlg::CheckEnableOk()
126 BOOL bEnable = FALSE;
128 if ((m_strName.GetLength() > 0) && (m_strDir.GetLength() > 0))
129 bEnable = TRUE;
131 m_OK.EnableWindow(bEnable);
134 BOOL CMakeSymbolicLinkDlg::OnInitDialog()
136 CDialog::OnInitDialog();
138 // m_Dir.SetWindowText(m_strDir);
139 // m_Name.SetWindowText(m_strName);
140 UpdateData(FALSE);
142 return TRUE; // return TRUE unless you set the focus to a control
143 // EXCEPTION: OCX Property Pages should return FALSE