ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/convertobj.c
(Generate patch)

Comparing ray/src/common/convertobj.c (file contents):
Revision 2.1 by greg, Mon Mar 30 18:28:35 2020 UTC vs.
Revision 2.3 by greg, Thu Apr 23 22:35:27 2020 UTC

# Line 9 | Line 9 | static const char RCSid[] = "$Id$";
9   *  Created by Greg Ward on Thu Apr 22 2004.
10   */
11  
12 < #include <stdio.h>
12 > #include "paths.h"
13   #include "rterror.h"
14   #include "objutil.h"
15  
# Line 47 | Line 47 | toRadiance(Scene *sc, FILE *fp, int flreq, int flexc)
47                                                  /* write faces */
48          n = foreachFace(sc, radface, flreq, flexc, (void *)fp);
49          if (fflush(fp) < 0) {
50 <                error(SYSTEM, "Error flushing Radiance scene data");
50 >                error(SYSTEM, "Error writing Radiance scene data");
51                  return(-1);
52          }
53          return(n);
# Line 68 | Line 68 | writeRadiance(Scene *sc, const char *fspec, int flreq,
68                  if ((fp = popen(fspec+1, "w")) == NULL) {
69                          sprintf(errmsg, "%s: cannot execute", fspec);
70                          error(SYSTEM, errmsg);
71 <                        return(0);
71 >                        return(-1);
72                  }
73          } else
74   #endif
75          if ((fp = fopen(fspec, "w")) == NULL) {
76                  sprintf(errmsg, "%s: cannot open for writing", fspec);
77                  error(SYSTEM, errmsg);
78 <                return(0);
78 >                return(-1);
79          }
80                                                  /* start off header */
81          fprintf(fp, "# Radiance scene file converted from .OBJ by %s\n#\n",
82                                                  progname);
83          n = toRadiance(sc, fp, flreq, flexc);   /* write file */
84   #if POPEN_SUPPORT
85 <        if (fspec[0] == '!')
86 <                pclose(fp);
87 <        else
85 >        if (fspec[0] == '!') {
86 >                if (pclose(fp)) {
87 >                        sprintf(errmsg, "%s: error writing to command\n", fspec);
88 >                        error(SYSTEM, errmsg);
89 >                        return(-1);
90 >                }
91 >        } else
92   #endif
93 <        fclose(fp);                             /* close file */
93 >        fclose(fp);                             /* close it (already flushed) */
94          return(n);
95   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines