Changeset 417

Show
Ignore:
Timestamp:
Wed Feb 6 14:10:04 2008
Author:
giovannibajo
Message:

Cleanup several error paths during unpacking.

1) If the temporary directory cannot be created (es: permissions),
error out properly with a fatal error saying "cannot create temporary directory";
before the error was silently ignored (!!!!), causing random behaviour.

2) If there's an error writing a file while unpacking (eg: permissions),
error out with a messagebox saying that there was an error, instead of
ignoring it (!!!).

3) If a file already exists during unpacking (eg: was packaged twice)
display a proper error message, but keeps on going.

Right now, the booloader errors out even if the directory already exists (eg: since
the direcotry name is pid-based, it might match a left-behind temporary directory).
This is much better than before, though, as the error is finally clear.

Files:

Legend:

Unmodified
Added
Removed
Modified
  • branches/startup_crash/source/common/launch.c

    r415 r417  
    171 171 #endif /* _CONSOLE */  
    172 172  
    173    
    174 173 int testTempPath(char *buff)  
    175 174 {  
     
    194 193 }  
    195 194  
    196   void getTempPath(char *buff)  
      195 int getTempPath(char *buff)  
    196 195 {  
    197 196 #ifdef WIN32  
    198 197         GetTempPath(MAX_PATH, buff);  
    199           testTempPath(buff);  
      198         if (testTempPath(buff))  
      199         return 1;  
    200 200 #else  
    201 201         static const char *envname[] = {  
     
    213 213                         strcpy(buff, p);  
    214 214                         if (testTempPath(buff))  
    215                                   return;  
      215                                 return 1;  
    215 215                 }  
    216 216         }  
     
    219 219                 strcpy(buff, dirname[i]);  
    220 220                 if (testTempPath(buff))  
    221                           return;  
      221                         return 1;  
    221 221         }  
    222           buff[0] = '\0';  
    223 222 #endif  
      223         buff[0] = '\0';  
      224         return 0;  
    224 225 }  
    225 226 /*  
     
    804 805         strcpy(fnm, path);  
    805 806         strcat(fnm, name);  
    806           if (stat(fnm, &sbuf) == -1) {  
    807                   VS("%s\n", fnm);  
    808                   return fopen(fnm, "wb");  
    809           }  
    810           return NULL;  
      807         if (stat(fnm, &sbuf) == 0) {  
      808                 OTHERERROR("WARNING: file already exists but should not: %s\n", fnm);  
      809     }  
      810         return fopen(fnm, "wb");  
    811 811 }  
    812 812 /*  
     
    824 824  
    825 825         if (!f_workpath) {  
    826                   getTempPath(f_temppath);  
      826                 if (!getTempPath(f_temppath))  
      827                 {  
      828             FATALERROR("INTERNAL ERROR: cannot create temporary directory!\n");  
      829             return -1;  
      830                 }  
    827 831 #ifdef WIN32  
    828 832                 strcpy(f_temppathraw, f_temppath);  
     
    833 837                 f_workpath = f_temppath;  
    834 838         }  
      839          
    835 840         out = openTarget(f_workpath, ptoc->name);  
    836 841  
    837 842         if (out == NULL)  {  
    838 843                 FATALERROR("%s could not be extracted!\n", ptoc->name);  
      844                 return -1;  
    839 845         }  
    840 846         else {