Archive: nsDialogs patch


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.

Here's a proper patch: http://paste2.org/p/42721


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


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));?

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

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?


Please submit as a patch on the SourceForge project page.


Done