| | @@ -386,11 +386,11 @@ |
| 386 | 386 | FILE *in, *out; |
| 387 | 387 | int got; |
| 388 | 388 | char zBuf[8192]; |
| 389 | 389 | in = fossil_fopen(zFrom, "rb"); |
| 390 | 390 | if( in==0 ) fossil_fatal("cannot open \"%s\" for reading", zFrom); |
| 391 | | - file_mkfolder(zTo, 0); |
| 391 | + file_mkfolder(zTo, 0, 0); |
| 392 | 392 | out = fossil_fopen(zTo, "wb"); |
| 393 | 393 | if( out==0 ) fossil_fatal("cannot open \"%s\" for writing", zTo); |
| 394 | 394 | while( (got=fread(zBuf, 1, sizeof(zBuf), in))>0 ){ |
| 395 | 395 | fwrite(zBuf, 1, got, out); |
| 396 | 396 | } |
| | @@ -530,13 +530,16 @@ |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | /* |
| 533 | 533 | ** Create the tree of directories in which zFilename belongs, if that sequence |
| 534 | 534 | ** of directories does not already exist. |
| 535 | +** |
| 536 | +** On success, return zero. On error, return errorReturn if positive, otherwise |
| 537 | +** print an error message and abort. |
| 535 | 538 | */ |
| 536 | | -void file_mkfolder(const char *zFilename, int forceFlag){ |
| 537 | | - int i, nName; |
| 539 | +int file_mkfolder(const char *zFilename, int forceFlag, int errorReturn){ |
| 540 | + int i, nName, rc = 0; |
| 538 | 541 | char *zName; |
| 539 | 542 | |
| 540 | 543 | nName = strlen(zFilename); |
| 541 | 544 | zName = mprintf("%s", zFilename); |
| 542 | 545 | nName = file_simplify_name(zName, nName, 0); |
| | @@ -550,20 +553,24 @@ |
| 550 | 553 | ** C: in this example. |
| 551 | 554 | */ |
| 552 | 555 | if( !(i==2 && zName[1]==':') ){ |
| 553 | 556 | #endif |
| 554 | 557 | if( file_mkdir(zName, forceFlag) && file_isdir(zName)!=1 ){ |
| 555 | | - fossil_fatal_recursive("unable to create directory %s", zName); |
| 556 | | - return; |
| 558 | + if (errorReturn <= 0) { |
| 559 | + fossil_fatal_recursive("unable to create directory %s", zName); |
| 560 | + } |
| 561 | + rc = errorReturn; |
| 562 | + break; |
| 557 | 563 | } |
| 558 | 564 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 559 | 565 | } |
| 560 | 566 | #endif |
| 561 | 567 | zName[i] = '/'; |
| 562 | 568 | } |
| 563 | 569 | } |
| 564 | 570 | free(zName); |
| 571 | + return rc; |
| 565 | 572 | } |
| 566 | 573 | |
| 567 | 574 | /* |
| 568 | 575 | ** Removes the directory named in the argument, if it exists. The directory |
| 569 | 576 | ** must be empty and cannot be the current directory or the root directory. |
| 570 | 577 | |