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 Andrej Borsenkow <Andrej.Borsenkow@mow.siemens.ru>
13 * based on work and suggestions of DJ Delorie
17 /* The purpose of this file is to ask the user where they want the
18 * locally downloaded package files to be cached
22 static const char *cvsid
=
39 #include "io_stream.h"
44 extern ThreeBarProgressPage Progress
;
45 extern LogFile theLog
;
49 io_stream::mkpath_p (PATH_TO_DIR
, String ("file://") + local_dir
);
52 if (get_root_dir ().size())
54 f
= io_stream::open ("cygfile:///etc/setup/last-cache", "wb");
55 io_stream::remove ("file://last-cache");
58 f
= io_stream::open ("file://last-cache", "wb");
61 f
->write (local_dir
.cstr_oneuse(), local_dir
.size());
64 if (source
== IDC_SOURCE_DOWNLOAD
|| !get_root_dir ().size())
67 theLog
.setFile (LOG_BABBLE
, local_dir
+ "/setup.log.full", false);
68 theLog
.setFile (0, local_dir
+ "/setup.log", true);
73 theLog
.setFile (LOG_BABBLE
, cygpath ("/var/log/setup.log.full"), false);
74 theLog
.setFile (0, cygpath ("/var/log/setup.log"), true);
79 check_if_enable_next (HWND h
)
81 EnableWindow (GetDlgItem (h
, IDOK
), local_dir
.size() != 0);
87 eset (h
, IDC_LOCAL_DIR
, local_dir
);
88 check_if_enable_next (h
);
94 local_dir
= egetString (h
, IDC_LOCAL_DIR
);
99 browse_cb (HWND h
, UINT msg
, LPARAM lp
, LPARAM data
)
103 case BFFM_INITIALIZED
:
104 if (local_dir
.size())
105 SendMessage (h
, BFFM_SETSELECTION
, TRUE
, (LPARAM
) local_dir
.cstr_oneuse());
117 memset (&bi
, 0, sizeof (bi
));
119 bi
.pszDisplayName
= name
;
120 bi
.lpszTitle
= "Select download directory";
121 bi
.ulFlags
= BIF_RETURNONLYFSDIRS
;
123 pidl
= SHBrowseForFolder (&bi
);
126 if (SHGetPathFromIDList (pidl
, name
))
127 eset (h
, IDC_LOCAL_DIR
, name
);
132 dialog_cmd (HWND h
, int id
, HWND hwndctl
, UINT code
)
139 check_if_enable_next (h
);
142 case IDC_LOCAL_DIR_BROWSE
:
150 LocalDirPage::Create ()
152 return PropertyPage::Create (NULL
, dialog_cmd
, IDD_LOCAL_DIR
);
156 LocalDirPage::OnInit ()
158 static int inited
= 0;
162 io_stream::open ("cygfile:///etc/setup/last-cache", "rt");
164 f
= io_stream::open ("file://last-cache", "rt");
168 char *fg_ret
= f
->gets (localdir
, 1000);
171 local_dir
= String (localdir
);
178 LocalDirPage::OnActivate ()
180 load_dialog (GetHWND ());
184 LocalDirPage::OnNext ()
190 log (LOG_PLAIN
, String ("Selected local directory: ") + local_dir
);
191 if (SetCurrentDirectoryA (local_dir
.cstr_oneuse()))
193 if (source
== IDC_SOURCE_CWD
)
195 do_fromcwd (GetInstance (), GetHWND ());
196 if (next_dialog
== IDD_S_LOAD_INI
)
198 Progress
.SetActivateTask (WM_APP_START_SETUP_INI_DOWNLOAD
);
205 note (h
, IDS_ERR_CHDIR
, local_dir
.cstr_oneuse());
211 LocalDirPage::OnBack ()
213 save_dialog (GetHWND ());
214 if (source
== IDC_SOURCE_DOWNLOAD
)
216 // Downloading only, skip the unix root page