~showard314/ubuntu/karmic/r-base/remove_start_comments

« back to all changes in this revision

Viewing changes to src/gnuwin32/front-ends/open.c

  • Committer: Bazaar Package Importer
  • Author(s): Dirk Eddelbuettel
  • Date: 2009-01-19 12:40:24 UTC
  • mfrom: (5.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090119124024-abxsf4e0y7713w9m
Tags: 2.8.1-2
debian/control: Add another Build-Depends: exclusion for the 
'kfreebsd-i386 kfreebsd-amd64 hurd-i386' architecture to openjdk-6-jdk.
Thanks to Petr Salinger for the heads-up.               (Closes: 512324)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  R : A Computer Language for Statistical Data Analysis
 
3
 *  Copyright (C) 2008  R Development Core Team
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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/
 
18
 */
 
19
 
 
20
#include <windows.h>
 
21
#include <stdio.h>
 
22
#include <stdlib.h>             /* for exit */
 
23
 
 
24
 
 
25
int main (int argc, char **argv)
 
26
{
 
27
    int i, status = 0;
 
28
    unsigned int ret;
 
29
 
 
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");
 
34
        exit(0);
 
35
    }
 
36
    for(i = 1; i < argc; i++) {
 
37
        ret = (unsigned int) ShellExecute(NULL, "open", argv[i], NULL, 
 
38
                                          ".", SW_SHOW);
 
39
        if(ret <= 32) { /* an error condition */
 
40
            status = 32 + ret;
 
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)
 
45
                fprintf(stderr, 
 
46
                        "file association for '%s' not available or invalid\n",
 
47
                        argv[i]);
 
48
            else if(ret == SE_ERR_ACCESSDENIED || ret == SE_ERR_SHARE)
 
49
                fprintf(stderr, "access to '%s' denied\n", argv[i]);
 
50
            else
 
51
                fprintf(stderr, "problem in displaying '%s'\n", argv[i]);
 
52
        }
 
53
    }
 
54
    exit(status);
 
55
}