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

Comparing ray/src/rt/rpict.c (file contents):
Revision 2.26 by greg, Fri Jul 30 10:31:09 1993 UTC vs.
Revision 2.27 by greg, Mon Aug 2 21:48:37 1993 UTC

# Line 94 | Line 94 | extern char  *mktemp();
94  
95   double  pixvalue();
96  
97 + #ifdef NIX
98 + #define  file_exists(f) (access(f,F_OK)==0)
99 + #else
100 + #include  <sys/types.h>
101 + #include  <sys/stat.h>
102 + int
103 + file_exists(fname)                              /* ordinary file exists? */
104 + char  *fname;
105 + {
106 +        struct stat  sbuf;
107 +        if (stat(fname, &sbuf) < 0) return(0);
108 +        return((sbuf.st_mode & S_IFREG) != 0);
109 + }
110 + #endif
111  
112 +
113   quit(code)                      /* quit program */
114   int  code;
115   {
# Line 205 | Line 220 | char  *pout, *zout, *prvr;
220                  pctdone = 0.0;
221                  if (pout != NULL) {
222                          sprintf(fbuf, pout, seq);
223 <                        if (prvr == NULL && access(fbuf, F_OK) == 0)
223 >                        if (file_exists(fbuf)) {
224 >                                if (prvr != NULL || !strcmp(fbuf, pout)) {
225 >                                        sprintf(errmsg,
226 >                                                "output file \"%s\" exists",
227 >                                                fbuf);
228 >                                        error(USER, errmsg);
229 >                                }
230                                  continue;               /* don't clobber */
231 +                        }
232                          if (freopen(fbuf, "w", stdout) == NULL) {
233                                  sprintf(errmsg,
234                                          "cannot open output file \"%s\"", fbuf);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines