]>
cygwin.com Git - cygwin-apps/setup.git/blob - root.cc
2 * Copyright (c) 2000, Red Hat, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by DJ Delorie <dj@cygnus.com>
16 /* The purpose of this file is to ask the user where they want the
17 root of the installation to be, and to ask whether the user prefers
18 text or binary mounts. */
21 static const char *cvsid
=
39 #include "getopt++/StringOption.h"
43 StringOption
RootOption ("", 'R', "root", "Root installation directory", false);
45 static int rb
[] = { IDC_ROOT_TEXT
, IDC_ROOT_BINARY
, 0 };
46 static int su
[] = { IDC_ROOT_SYSTEM
, IDC_ROOT_USER
, 0 };
49 check_if_enable_next (HWND h
)
51 EnableWindow (GetDlgItem (h
, IDOK
), root_text
&& get_root_dir ().size()
58 rbset (h
, rb
, root_text
);
59 rbset (h
, su
, root_scope
);
60 eset (h
, IDC_ROOT_DIR
, get_root_dir ());
61 check_if_enable_next (h
);
67 root_text
= rbget (h
, rb
);
68 root_scope
= rbget (h
, su
);
69 set_root_dir (egetString (h
, IDC_ROOT_DIR
));
73 browse_cb (HWND h
, UINT msg
, LPARAM lp
, LPARAM data
)
77 case BFFM_INITIALIZED
:
78 if (get_root_dir ().size())
79 SendMessage (h
, BFFM_SETSELECTION
, TRUE
, (LPARAM
) get_root_dir ().cstr_oneuse());
91 memset (&bi
, 0, sizeof (bi
));
93 bi
.pszDisplayName
= name
;
94 bi
.lpszTitle
= "Select an installation root directory";
95 bi
.ulFlags
= BIF_RETURNONLYFSDIRS
;
97 pidl
= SHBrowseForFolder (&bi
);
100 if (SHGetPathFromIDList (pidl
, name
))
101 eset (h
, IDC_ROOT_DIR
, name
);
105 #define isslash(c) ((c) == '\\' || (c) == '/')
108 directory_is_absolute ()
111 const char *r
= get_root_dir ().cstr_oneuse();
112 if (isalpha (r
[0]) && r
[1] == ':' && (r
[2] == '\\' || r
[2] == '/'))
120 directory_is_rootdir ()
123 for (const char *c
= get_root_dir().cstr_oneuse(); *c
; c
++)
124 if (isslash (c
[0]) && c
[1] && !isslash (c
[1]))
130 directory_has_spaces ()
132 if (get_root_dir ().find(' '))
138 dialog_cmd (HWND h
, int id
, HWND hwndctl
, UINT code
)
145 case IDC_ROOT_BINARY
:
146 case IDC_ROOT_SYSTEM
:
149 check_if_enable_next (h
);
152 case IDC_ROOT_BROWSE
:
162 return PropertyPage::Create (NULL
, dialog_cmd
, IDD_ROOT
);
168 if (((string
)RootOption
).size())
169 set_root_dir((string
)RootOption
);
170 if (!get_root_dir ().size())
172 load_dialog (GetHWND ());
176 RootPage::wantsActivation() const
178 return (source
!= IDC_SOURCE_DOWNLOAD
);
188 if (!directory_is_absolute ())
190 note (h
, IDS_ROOT_ABSOLUTE
);
193 else if (directory_is_rootdir () && (IDNO
== yesno (h
, IDS_ROOT_SLASH
)))
195 else if (directory_has_spaces () && (IDNO
== yesno (h
, IDS_ROOT_SPACE
)))
198 log (LOG_PLAIN
, String ("root: ") + get_root_dir () +
199 (root_text
== IDC_ROOT_TEXT
? " text" : " binary") +
200 (root_scope
== IDC_ROOT_USER
? " user" : " system"));
215 RootPage::OnUnattended ()
This page took 0.043212 seconds and 5 git commands to generate.