This is the mail archive of the
cygwin-apps@cygwin.com
mailing list for the Cygwin project.
[Patch] Improved error message when selecting directory fails
- From: Frank Richter <frichter at gmx dot li>
- To: Cygwin Apps <cygwin-apps at cygwin dot com>
- Date: Fri, 31 Oct 2003 13:36:27 +0100
- Subject: [Patch] Improved error message when selecting directory fails
Now, the last error code is evaluated and an appropriate message is
displayed. There's also a choice to 'Retry', 'Ignore' the error or
'Abort' the directory change. The idea is that under circumstances the
user may be able to fix the cause of the problem (e.g. by connecting to
a remote share) and then can just go on with the setup.
-f.r.
2003-10-31 Frank Richter <frichter@gmx.li>
* localdir.cc (OnNext): When SelectDirectoryA() fails, display a
message with the error returned from the system instead of just
'could not change dir'. Also, offer the user to 'Retry', 'Ignore' the
error or 'Abort' the directory change.
Index: localdir.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/localdir.cc,v
retrieving revision 2.18
diff -r2.18 localdir.cc
39a40
> #include "cistring.h"
187c188,190
< if (SetCurrentDirectoryA (local_dir.cstr_oneuse()))
---
>
> bool trySetCurDir = true;
> while (trySetCurDir)
189c192,193
< if (source == IDC_SOURCE_CWD)
---
> trySetCurDir = false;
> if (SetCurrentDirectoryA (local_dir.cstr_oneuse()))
191c195
< if (do_fromcwd (GetInstance (), GetHWND ()))
---
> if (source == IDC_SOURCE_CWD)
193,194c197,202
< Progress.SetActivateTask (WM_APP_START_SETUP_INI_DOWNLOAD);
< return IDD_INSTATUS;
---
> if (do_fromcwd (GetInstance (), GetHWND ()))
> {
> Progress.SetActivateTask (WM_APP_START_SETUP_INI_DOWNLOAD);
> return IDD_INSTATUS;
> }
> return IDD_CHOOSE;
196c204,229
< return IDD_CHOOSE;
---
> }
> else
> {
> DWORD err = GetLastError ();
> char msgText[1000];
> LoadString (hinstance, IDS_ERR_CHDIR, msgText, sizeof (msgText));
> char* buf;
> char msg[1000];
> if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM |
> FORMAT_MESSAGE_ALLOCATE_BUFFER, 0, err, LANG_NEUTRAL,
> (LPSTR)&buf, 0, 0) != 0)
> {
> snprintf (msg, sizeof (msg), msgText, local_dir.cstr_oneuse(),
> buf, err);
> }
> else
> snprintf (msg, sizeof (msg), msgText, local_dir.cstr_oneuse(),
> "(unknown error)", err);
> log (LOG_PLAIN, msg);
> int ret = MessageBox (h, msg, 0, MB_ICONEXCLAMATION |
> MB_ABORTRETRYIGNORE);
>
> if ((ret == IDABORT) || (ret == IDCANCEL))
> return -1;
> else
> trySetCurDir = (ret == IDRETRY);
199,200d231
< else
< note (h, IDS_ERR_CHDIR, local_dir.cstr_oneuse());
Index: res.rc
===================================================================
RCS file: /cvs/cygwin-apps/setup/res.rc,v
retrieving revision 2.53
diff -r2.53 res.rc
487c487
< IDS_ERR_CHDIR "Could not change dir to %s"
---
> IDS_ERR_CHDIR "Could not change dir to %s: %s [%.8x]"