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
=
38 #include "io_stream.h"
43 extern ThreeBarProgressPage Progress
;
48 io_stream::mkpath_p (PATH_TO_DIR
, String ("file://") + local_dir
);
51 if (get_root_dir ().size())
53 f
= io_stream::open ("cygfile:///etc/setup/last-cache", "wb");
54 io_stream::remove ("file://last-cache");
57 f
= io_stream::open ("file://last-cache", "wb");
60 f
->write (local_dir
.cstr_oneuse(), local_dir
.size());
66 check_if_enable_next (HWND h
)
68 EnableWindow (GetDlgItem (h
, IDOK
), local_dir
.size() != 0);
74 eset (h
, IDC_LOCAL_DIR
, local_dir
);
75 check_if_enable_next (h
);
81 local_dir
= egetString (h
, IDC_LOCAL_DIR
);
86 browse_cb (HWND h
, UINT msg
, LPARAM lp
, LPARAM data
)
90 case BFFM_INITIALIZED
:
92 SendMessage (h
, BFFM_SETSELECTION
, TRUE
, (LPARAM
) local_dir
.cstr_oneuse());
104 memset (&bi
, 0, sizeof (bi
));
106 bi
.pszDisplayName
= name
;
107 bi
.lpszTitle
= "Select download directory";
108 bi
.ulFlags
= BIF_RETURNONLYFSDIRS
;
110 pidl
= SHBrowseForFolder (&bi
);
113 if (SHGetPathFromIDList (pidl
, name
))
114 eset (h
, IDC_LOCAL_DIR
, name
);
119 dialog_cmd (HWND h
, int id
, HWND hwndctl
, UINT code
)
126 check_if_enable_next (h
);
129 case IDC_LOCAL_DIR_BROWSE
:
137 LocalDirPage::Create ()
139 return PropertyPage::Create (NULL
, dialog_cmd
, IDD_LOCAL_DIR
);
143 LocalDirPage::OnInit ()
145 static int inited
= 0;
149 io_stream::open ("cygfile:///etc/setup/last-cache", "rt");
151 f
= io_stream::open ("file://last-cache", "rt");
155 char *fg_ret
= f
->gets (localdir
, 1000);
158 local_dir
= String (localdir
);
165 LocalDirPage::OnActivate ()
167 load_dialog (GetHWND ());
171 LocalDirPage::OnNext ()
177 log (LOG_PLAIN
, String ("Selected local directory: ") + local_dir
);
178 if (SetCurrentDirectoryA (local_dir
.cstr_oneuse()))
180 if (source
== IDC_SOURCE_CWD
)
182 do_fromcwd (GetInstance (), GetHWND ());
183 if (next_dialog
== IDD_S_LOAD_INI
)
185 Progress
.SetActivateTask (WM_APP_START_SETUP_INI_DOWNLOAD
);
192 note (h
, IDS_ERR_CHDIR
, local_dir
.cstr_oneuse());
198 LocalDirPage::OnBack ()
200 save_dialog (GetHWND ());
201 if (source
== IDC_SOURCE_DOWNLOAD
)
203 // Downloading only, skip the unix root page