TobbeSweden
26th June 2008 21:06 UTC
nsDialogs patch
I've written a small patch for nsDialogs that enables one to specify the initial folder that will be used in a SelectFileDialog dialog.
The second parameter used to be a variable that would get the path to the file. Now this variable can also be used to specify the initial folder by setting it to the folder to use before calling SelectFileDialog. This is very similar to how Windows does it with its Open/Save dialogs.
Just place the following lines of code somewhere in the beginning of the SelectFileDialog function in browse.c after the calls to popstring. (I placed them on rows 114-118).
if (path[lstrlen(path) - 1] == '\\\')
{
lstrcpy(initialDir, path);
path[0] = '\0';
}
You also need "ofn.lpstrInitialDir = initialDir;" and "char initialDir[1024];" in suitable places.
TobbeSweden
26th June 2008 21:14 UTC
Here's a proper patch: http://paste2.org/p/42721
Anders
27th June 2008 07:42 UTC
you probably want to put "ofn.lpstrInitialDir = initialDir;" inside the if block as well (initialDir could be filled with garbage) Not sure if there is a overflow problem here as well for large string builds, so use lstrcpyn(...,1024) or change char initialDir[1024] to use the nsis string size
TobbeSweden
27th June 2008 08:27 UTC
Originally posted by Anders
you probably want to put "ofn.lpstrInitialDir = initialDir;" inside the if block as well (initialDir could be filled with garbage)
Yeah, you're right. Or it could always be initialized to '\0'.
Originally posted by Anders
Not sure if there is a overflow problem here as well for large string builds, so use lstrcpyn(...,1024) or change char initialDir[1024] to use the nsis string size
Isn't path guaranteed to be at most 1024 character long after the call to popstring(path, sizeof(path));?
Anders
27th June 2008 11:13 UTC
Originally posted by TobbeSweden
Isn't path guaranteed to be at most 1024 character long after the call to popstring(path, sizeof(path));?
yeah, my bad, nsDialogs has it own version of popstring, forgot about that
TobbeSweden
30th June 2008 21:49 UTC
Updated patch (only sets ofn.lpstrInitialDir if I'm also setting initialDir)
http://paste2.org/p/43756
Anything else I can do to get this patch accepted?
kichik
11th July 2008 11:09 UTC
Please submit as a patch on the SourceForge project page.
TobbeSweden
11th July 2008 13:54 UTC
Done