Mercurial > dwindows
changeset 170:ee6858b7d1c3
Set DefaultWorkingDir before trying to start the web browser.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 30 Nov 2002 14:43:57 +0000 |
parents | b2211123274e |
children | b8e93557b2c7 |
files | os2/dw.c |
diffstat | 1 files changed, 33 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/os2/dw.c Sat Nov 30 13:15:43 2002 +0000 +++ b/os2/dw.c Sat Nov 30 14:43:57 2002 +0000 @@ -22,6 +22,7 @@ #include <ctype.h> #include <process.h> #include <time.h> +#include <direct.h> #include "dw.h" #define QWP_USER 0 @@ -7249,6 +7250,20 @@ return NULL; } +/* Internal function to set drive and directory */ +int _SetPath(char *path) +{ + if(strlen(path) > 2) + { + if(path[1] == ':') + { + char drive = toupper(path[0]); + _chdrive((drive - 'A')+1); + } + } + return chdir(path); +} + /* * Execute and external program in a seperate session. * Parameters: @@ -7271,8 +7286,16 @@ int dw_browse(char *url) { /* Is there a way to find the webbrowser in Unix? */ - char *execargs[3], browser[1024], *newurl = NULL; - int len; + char *execargs[3], browser[1024], *olddir, *newurl = NULL; + int len, ret; + + olddir = _getcwd(NULL, 1024); + + PrfQueryProfileString(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS", + "DefaultWorkingDir", NULL, browser, 1024); + + if(browser[0]) + _SetPath(browser); PrfQueryProfileString(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS", "DefaultBrowserExe", NULL, browser, 1024); @@ -7305,7 +7328,14 @@ } } - return dw_exec(browser, DW_EXEC_GUI, execargs); + ret = dw_exec(browser, DW_EXEC_GUI, execargs); + + if(olddir) + { + _SetPath(olddir); + free(olddir); + } + return ret; } /*