2
* R : A Computer Language for Statistical Data Analysis
3
* Copyright (C) 2008 R Development Core Team
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, a copy is available at
17
* http://www.r-project.org/Licenses/
22
#include <stdlib.h> /* for exit */
25
int main (int argc, char **argv)
30
if (argc < 2 || strcmp(argv[1], "--help") == 0) {
31
fprintf(stderr, "Usage: Rcmd open file [file ...]\n\n");
32
fprintf(stderr, " opens each file with the application given by\n");
33
fprintf(stderr, " the Windows file association (if any)\n");
36
for(i = 1; i < argc; i++) {
37
ret = (unsigned int) ShellExecute(NULL, "open", argv[i], NULL,
39
if(ret <= 32) { /* an error condition */
41
if(ret == ERROR_FILE_NOT_FOUND || ret == ERROR_PATH_NOT_FOUND
42
|| ret == SE_ERR_FNF || ret == SE_ERR_PNF)
43
fprintf(stderr, "'%s' not found", argv[i]);
44
else if(ret == SE_ERR_ASSOCINCOMPLETE || ret == SE_ERR_NOASSOC)
46
"file association for '%s' not available or invalid\n",
48
else if(ret == SE_ERR_ACCESSDENIED || ret == SE_ERR_SHARE)
49
fprintf(stderr, "access to '%s' denied\n", argv[i]);
51
fprintf(stderr, "problem in displaying '%s'\n", argv[i]);