The R Project SVN R

Rev

Rev 36938 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 36938 Rev 37592
Line 21... Line 21...
21
   WITHOUT ANY WARRANTY.
21
   WITHOUT ANY WARRANTY.
22
 
22
 
23
   See the file COPYLIB.TXT for details.
23
   See the file COPYLIB.TXT for details.
24
*/
24
*/
25
 
25
 
26
/* Copyright (C) 2004 	The R Foundation
26
/* Copyright (C) 2004--2006 	The R Foundation
27
 
27
 
28
   Additions for R, Chris Jackson
28
   Additions for R, Chris Jackson
29
   Find and replace dialog boxes and dialog handlers */
29
   Find and replace dialog boxes and dialog handlers */
30
 
30
 
31
#define ENABLE_NLS 1
31
#define ENABLE_NLS 1
Line 159... Line 159...
159
}
159
}
160
 
160
 
161
char *askfilename(char *title, char *default_name)
161
char *askfilename(char *title, char *default_name)
162
{
162
{
163
	if (*askfilenames(title, default_name, 0, userfilter?userfilter:filter[0], 0,
163
	if (*askfilenames(title, default_name, 0, userfilter?userfilter:filter[0], 0,
-
 
164
				          strbuf, BUFSIZE, NULL)) return strbuf;
-
 
165
	else return NULL;
-
 
166
}
-
 
167
 
-
 
168
char *askfilenamewithdir(char *title, char *default_name, char *dir)
-
 
169
{
-
 
170
	if (*askfilenames(title, default_name, 0, userfilter?userfilter:filter[0], 0,
164
				          strbuf, BUFSIZE)) return strbuf;
171
				          strbuf, BUFSIZE, dir)) return strbuf;
165
	else return NULL;
172
	else return NULL;
166
}
173
}
167
 
174
 
168
char *askfilenames(char *title, char *default_name, int multi,
175
char *askfilenames(char *title, char *default_name, int multi,
169
			       char *filters, int filterindex, char *strbuf, int bufsize)
176
			       char *filters, int filterindex, char *strbuf, int bufsize,
-
 
177
			       char *dir)
170
{
178
{
171
	int i;
179
	int i;
172
	OPENFILENAME ofn;
180
	OPENFILENAME ofn;
173
        char cwd[MAX_PATH]="";
181
        char cwd[MAX_PATH]="";
174
	if (! default_name)
182
	if (! default_name)
175
		default_name = "";
183
		default_name = "";
176
	strcpy(strbuf, default_name);
184
	strcpy(strbuf, default_name);
177
        GetCurrentDirectory(MAX_PATH,cwd);
185
        GetCurrentDirectory(MAX_PATH,cwd);
-
 
186
        if (!strcmp(cod,"")) {
178
        if (!strcmp(cod,"")) strcpy(cod,cwd);
187
            if (!dir) strcpy(cod,cwd);
-
 
188
            else strcpy(cod,dir);
-
 
189
        }
179
 
190
 
180
	ofn.lStructSize     = sizeof(OPENFILENAME);
191
	ofn.lStructSize     = sizeof(OPENFILENAME);
181
	ofn.hwndOwner       = current_window ?
192
	ofn.hwndOwner       = current_window ?
182
				current_window->handle : 0;
193
				current_window->handle : 0;
183
	ofn.hInstance       = 0;
194
	ofn.hInstance       = 0;
184
    ofn.lpstrFilter     = filters;
195
	ofn.lpstrFilter     = filters;
185
	ofn.lpstrCustomFilter = NULL;
196
	ofn.lpstrCustomFilter = NULL;
186
	ofn.nMaxCustFilter  = 0;
197
	ofn.nMaxCustFilter  = 0;
187
	ofn.nFilterIndex    = filterindex;
198
	ofn.nFilterIndex    = filterindex;
188
	ofn.lpstrFile       = strbuf;
199
	ofn.lpstrFile       = strbuf;
189
	ofn.nMaxFile        = bufsize;
200
	ofn.nMaxFile        = bufsize;