The R Project SVN R

Rev

Rev 46445 | Rev 47490 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 46445 Rev 46842
Line 504... Line 504...
504
     *     del     = flag for whether files should be deleted after use
504
     *     del     = flag for whether files should be deleted after use
505
     *     pager   = pager to be used.
505
     *     pager   = pager to be used.
506
     */
506
     */
507
 
507
 
508
 
508
 
509
/* As from R 2.7.0 we assume file[i] and pager are in UTF-8 */
-
 
510
extern FILE *R_wfopen(const wchar_t *filename, const wchar_t *mode);
509
extern FILE *R_wfopen(const wchar_t *filename, const wchar_t *mode);
511
extern size_t Rf_utf8towcs(wchar_t *wc, const char *s, size_t n);
510
extern size_t Rf_utf8towcs(wchar_t *wc, const char *s, size_t n);
512
 
511
 
513
int R_ShowFiles(int nfile, const char **file, const char **headers,
512
int R_ShowFiles(int nfile, const char **file, const char **headers,
514
		const char *wtitle, Rboolean del, const char *pager)
513
		const char *wtitle, Rboolean del, const char *pager)
515
{
514
{
516
    int   i;
515
    int   i;
517
    char  buf[1024];
516
    char  buf[1024];
518
    wchar_t wfn[PATH_MAX+1];
-
 
519
 
517
 
520
    if (nfile > 0) {
518
    if (nfile > 0) {
521
	if (pager == NULL || strlen(pager) == 0)
519
	if (pager == NULL || strlen(pager) == 0)
522
	    pager = "internal";
520
	    pager = "internal";
523
	for (i = 0; i < nfile; i++) {
521
	for (i = 0; i < nfile; i++) {
524
	    if(!access(file[i], R_OK)) {
522
	    if(!access(file[i], R_OK)) {
525
		if (!strcmp(pager, "internal")) {
523
		if (!strcmp(pager, "internal")) {
526
		    newpager(wtitle, file[i], CE_UTF8, headers[i], del);
524
		    newpager(wtitle, file[i], CE_NATIVE, headers[i], del);
527
		} else if (!strcmp(pager, "console")) {
525
		} else if (!strcmp(pager, "console")) {
528
		    size_t len;
526
		    size_t len;
529
		    FILE *f;
527
		    FILE *f;
530
		    Rf_utf8towcs(wfn, file[i], PATH_MAX+1);
-
 
531
		    f = R_wfopen(wfn, L"rt");
528
		    f = R_fopen(file[i], "rt");
532
		    if(f) {
529
		    if(f) {
533
			while((len = fread(buf, 1, 1023, f))) {
530
			while((len = fread(buf, 1, 1023, f))) {
534
			    buf[len] = '\0';
531
			    buf[len] = '\0';
535
			    R_WriteConsole(buf, strlen(buf));
532
			    R_WriteConsole(buf, strlen(buf));
536
			}
533
			}
537
			fclose(f);
534
			fclose(f);
538
			if (del) DeleteFileW(wfn);
535
			if (del) DeleteFile(file[i]);
539
		    }
536
		    }
540
		    else {
537
		    else {
541
			snprintf(buf, 1024,
538
			snprintf(buf, 1024,
542
				 _("cannot open file '%s': %s"),
539
				 _("cannot open file '%s': %s"),
543
				 file[i], strerror(errno));
540
				 file[i], strerror(errno));
Line 602... Line 599...
602
	return 0;
599
	return 0;
603
    }
600
    }
604
    return 1;
601
    return 1;
605
}
602
}
606
 
603
 
-
 
604
#if 0
607
/* Prompt the user for a file name.  Return the length of */
605
/* Prompt the user for a file name.  Return the length of */
608
/* the name typed.  On Gui platforms, this should bring up */
606
/* the name typed.  On Gui platforms, this should bring up */
609
/* a dialog box so a user can choose files that way. */
607
/* a dialog box so a user can choose files that way. */
610
 
608
 
611
extern int DialogSelectFile(char *buf, int len); /* from rui.c */
609
extern int DialogSelectFile(char *buf, int len); /* from rui.c */
612
 
610
 
613
int R_ChooseFile(int new, char *buf, int len)
611
int R_ChooseFile(int new, char *buf, int len)
614
{
612
{
615
    return DialogSelectFile(buf, len);
613
    return DialogSelectFile(buf, len);
616
}
614
}
-
 
615
#endif
617
 
616
 
618
/* code for R_ShowMessage, R_YesNoCancel */
617
/* code for R_ShowMessage, R_YesNoCancel */
619
 
618
 
620
void (*pR_ShowMessage)(const char *s);
619
void (*pR_ShowMessage)(const char *s);
621
void R_ShowMessage(const char *s)
620
void R_ShowMessage(const char *s)