Fossil SCM
win32: files with invalid chars were not deleted sometimes with "fossil update"
Commit
d9aa512e203bd53a049c83876fa511c2f0a1c8c4
Parent
b293b744db4fc5c…
1 file changed
+18
-14
+18
-14
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -64,23 +64,24 @@ | ||
| 64 | 64 | ** Fill stat buf with information received from stat() or lstat(). |
| 65 | 65 | ** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on. |
| 66 | 66 | ** |
| 67 | 67 | */ |
| 68 | 68 | static int fossil_stat(const char *zFilename, struct stat *buf, int isWd){ |
| 69 | + int rc; | |
| 69 | 70 | #if !defined(_WIN32) |
| 71 | + char *zMbcs = fossil_utf8_to_filename(zFilename); | |
| 70 | 72 | if( isWd && g.allowSymlinks ){ |
| 71 | - return lstat(zFilename, buf); | |
| 73 | + rc = lstat(zMbcs, buf); | |
| 72 | 74 | }else{ |
| 73 | - return stat(zFilename, buf); | |
| 75 | + rc = stat(zMbcs, buf); | |
| 74 | 76 | } |
| 75 | 77 | #else |
| 76 | - int rc = 0; | |
| 77 | 78 | wchar_t *zMbcs = fossil_utf8_to_filename(zFilename); |
| 78 | 79 | rc = _wstati64(zMbcs, buf); |
| 80 | +#endif | |
| 79 | 81 | fossil_filename_free(zMbcs); |
| 80 | 82 | return rc; |
| 81 | -#endif | |
| 82 | 83 | } |
| 83 | 84 | |
| 84 | 85 | /* |
| 85 | 86 | ** Fill in the fileStat variable for the file named zFilename. |
| 86 | 87 | ** If zFilename==0, then use the previous value of fileStat if |
| @@ -305,14 +306,15 @@ | ||
| 305 | 306 | */ |
| 306 | 307 | int file_access(const char *zFilename, int flags){ |
| 307 | 308 | #ifdef _WIN32 |
| 308 | 309 | wchar_t *zMbcs = fossil_utf8_to_filename(zFilename); |
| 309 | 310 | int rc = _waccess(zMbcs, flags); |
| 310 | - fossil_filename_free(zMbcs); | |
| 311 | 311 | #else |
| 312 | - int rc = access(zFilename, flags); | |
| 312 | + char *zMbcs = fossil_utf8_to_filename(zFilename); | |
| 313 | + int rc = access(zMbcs, flags); | |
| 313 | 314 | #endif |
| 315 | + fossil_filename_free(zMbcs); | |
| 314 | 316 | return rc; |
| 315 | 317 | } |
| 316 | 318 | |
| 317 | 319 | /* |
| 318 | 320 | ** Find an unused filename similar to zBase with zSuffix appended. |
| @@ -402,19 +404,20 @@ | ||
| 402 | 404 | #if !defined(_WIN32) |
| 403 | 405 | struct timeval tv[2]; |
| 404 | 406 | memset(tv, 0, sizeof(tv[0])*2); |
| 405 | 407 | tv[0].tv_sec = newMTime; |
| 406 | 408 | tv[1].tv_sec = newMTime; |
| 407 | - utimes(zFilename, tv); | |
| 409 | + char *zMbcs = fossil_utf8_to_filename(zFilename); | |
| 410 | + utimes(zMbcs, tv); | |
| 408 | 411 | #else |
| 409 | 412 | struct _utimbuf tb; |
| 410 | 413 | wchar_t *zMbcs = fossil_utf8_to_filename(zFilename); |
| 411 | 414 | tb.actime = newMTime; |
| 412 | 415 | tb.modtime = newMTime; |
| 413 | 416 | _wutime(zMbcs, &tb); |
| 414 | - fossil_filename_free(zMbcs); | |
| 415 | 417 | #endif |
| 418 | + fossil_filename_free(zMbcs); | |
| 416 | 419 | } |
| 417 | 420 | |
| 418 | 421 | /* |
| 419 | 422 | ** COMMAND: test-set-mtime |
| 420 | 423 | ** |
| @@ -441,16 +444,17 @@ | ||
| 441 | 444 | /* |
| 442 | 445 | ** Delete a file. |
| 443 | 446 | */ |
| 444 | 447 | void file_delete(const char *zFilename){ |
| 445 | 448 | #ifdef _WIN32 |
| 446 | - wchar_t *z = fossil_utf8_to_unicode(zFilename); | |
| 449 | + wchar_t *z = fossil_utf8_to_filename(zFilename); | |
| 447 | 450 | _wunlink(z); |
| 448 | - fossil_unicode_free(z); | |
| 449 | 451 | #else |
| 452 | + char *z = fossil_utf8_to_filename(zFilename); | |
| 450 | 453 | unlink(zFilename); |
| 451 | 454 | #endif |
| 455 | + fossil_filename_free(z); | |
| 452 | 456 | } |
| 453 | 457 | |
| 454 | 458 | /* |
| 455 | 459 | ** Create the directory named in the argument, if it does not already |
| 456 | 460 | ** exist. If forceFlag is 1, delete any prior non-directory object |
| @@ -464,18 +468,18 @@ | ||
| 464 | 468 | if( !forceFlag ) return 1; |
| 465 | 469 | file_delete(zName); |
| 466 | 470 | } |
| 467 | 471 | if( rc!=1 ){ |
| 468 | 472 | #if defined(_WIN32) |
| 469 | - int rc; | |
| 470 | 473 | wchar_t *zMbcs = fossil_utf8_to_filename(zName); |
| 471 | 474 | rc = _wmkdir(zMbcs); |
| 475 | +#else | |
| 476 | + char *zMbcs = fossil_utf8_to_filename(zName); | |
| 477 | + rc = mkdir(zName, 0755); | |
| 478 | +#endif | |
| 472 | 479 | fossil_filename_free(zMbcs); |
| 473 | 480 | return rc; |
| 474 | -#else | |
| 475 | - return mkdir(zName, 0755); | |
| 476 | -#endif | |
| 477 | 481 | } |
| 478 | 482 | return 0; |
| 479 | 483 | } |
| 480 | 484 | |
| 481 | 485 | /* |
| 482 | 486 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -64,23 +64,24 @@ | |
| 64 | ** Fill stat buf with information received from stat() or lstat(). |
| 65 | ** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on. |
| 66 | ** |
| 67 | */ |
| 68 | static int fossil_stat(const char *zFilename, struct stat *buf, int isWd){ |
| 69 | #if !defined(_WIN32) |
| 70 | if( isWd && g.allowSymlinks ){ |
| 71 | return lstat(zFilename, buf); |
| 72 | }else{ |
| 73 | return stat(zFilename, buf); |
| 74 | } |
| 75 | #else |
| 76 | int rc = 0; |
| 77 | wchar_t *zMbcs = fossil_utf8_to_filename(zFilename); |
| 78 | rc = _wstati64(zMbcs, buf); |
| 79 | fossil_filename_free(zMbcs); |
| 80 | return rc; |
| 81 | #endif |
| 82 | } |
| 83 | |
| 84 | /* |
| 85 | ** Fill in the fileStat variable for the file named zFilename. |
| 86 | ** If zFilename==0, then use the previous value of fileStat if |
| @@ -305,14 +306,15 @@ | |
| 305 | */ |
| 306 | int file_access(const char *zFilename, int flags){ |
| 307 | #ifdef _WIN32 |
| 308 | wchar_t *zMbcs = fossil_utf8_to_filename(zFilename); |
| 309 | int rc = _waccess(zMbcs, flags); |
| 310 | fossil_filename_free(zMbcs); |
| 311 | #else |
| 312 | int rc = access(zFilename, flags); |
| 313 | #endif |
| 314 | return rc; |
| 315 | } |
| 316 | |
| 317 | /* |
| 318 | ** Find an unused filename similar to zBase with zSuffix appended. |
| @@ -402,19 +404,20 @@ | |
| 402 | #if !defined(_WIN32) |
| 403 | struct timeval tv[2]; |
| 404 | memset(tv, 0, sizeof(tv[0])*2); |
| 405 | tv[0].tv_sec = newMTime; |
| 406 | tv[1].tv_sec = newMTime; |
| 407 | utimes(zFilename, tv); |
| 408 | #else |
| 409 | struct _utimbuf tb; |
| 410 | wchar_t *zMbcs = fossil_utf8_to_filename(zFilename); |
| 411 | tb.actime = newMTime; |
| 412 | tb.modtime = newMTime; |
| 413 | _wutime(zMbcs, &tb); |
| 414 | fossil_filename_free(zMbcs); |
| 415 | #endif |
| 416 | } |
| 417 | |
| 418 | /* |
| 419 | ** COMMAND: test-set-mtime |
| 420 | ** |
| @@ -441,16 +444,17 @@ | |
| 441 | /* |
| 442 | ** Delete a file. |
| 443 | */ |
| 444 | void file_delete(const char *zFilename){ |
| 445 | #ifdef _WIN32 |
| 446 | wchar_t *z = fossil_utf8_to_unicode(zFilename); |
| 447 | _wunlink(z); |
| 448 | fossil_unicode_free(z); |
| 449 | #else |
| 450 | unlink(zFilename); |
| 451 | #endif |
| 452 | } |
| 453 | |
| 454 | /* |
| 455 | ** Create the directory named in the argument, if it does not already |
| 456 | ** exist. If forceFlag is 1, delete any prior non-directory object |
| @@ -464,18 +468,18 @@ | |
| 464 | if( !forceFlag ) return 1; |
| 465 | file_delete(zName); |
| 466 | } |
| 467 | if( rc!=1 ){ |
| 468 | #if defined(_WIN32) |
| 469 | int rc; |
| 470 | wchar_t *zMbcs = fossil_utf8_to_filename(zName); |
| 471 | rc = _wmkdir(zMbcs); |
| 472 | fossil_filename_free(zMbcs); |
| 473 | return rc; |
| 474 | #else |
| 475 | return mkdir(zName, 0755); |
| 476 | #endif |
| 477 | } |
| 478 | return 0; |
| 479 | } |
| 480 | |
| 481 | /* |
| 482 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -64,23 +64,24 @@ | |
| 64 | ** Fill stat buf with information received from stat() or lstat(). |
| 65 | ** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on. |
| 66 | ** |
| 67 | */ |
| 68 | static int fossil_stat(const char *zFilename, struct stat *buf, int isWd){ |
| 69 | int rc; |
| 70 | #if !defined(_WIN32) |
| 71 | char *zMbcs = fossil_utf8_to_filename(zFilename); |
| 72 | if( isWd && g.allowSymlinks ){ |
| 73 | rc = lstat(zMbcs, buf); |
| 74 | }else{ |
| 75 | rc = stat(zMbcs, buf); |
| 76 | } |
| 77 | #else |
| 78 | wchar_t *zMbcs = fossil_utf8_to_filename(zFilename); |
| 79 | rc = _wstati64(zMbcs, buf); |
| 80 | #endif |
| 81 | fossil_filename_free(zMbcs); |
| 82 | return rc; |
| 83 | } |
| 84 | |
| 85 | /* |
| 86 | ** Fill in the fileStat variable for the file named zFilename. |
| 87 | ** If zFilename==0, then use the previous value of fileStat if |
| @@ -305,14 +306,15 @@ | |
| 306 | */ |
| 307 | int file_access(const char *zFilename, int flags){ |
| 308 | #ifdef _WIN32 |
| 309 | wchar_t *zMbcs = fossil_utf8_to_filename(zFilename); |
| 310 | int rc = _waccess(zMbcs, flags); |
| 311 | #else |
| 312 | char *zMbcs = fossil_utf8_to_filename(zFilename); |
| 313 | int rc = access(zMbcs, flags); |
| 314 | #endif |
| 315 | fossil_filename_free(zMbcs); |
| 316 | return rc; |
| 317 | } |
| 318 | |
| 319 | /* |
| 320 | ** Find an unused filename similar to zBase with zSuffix appended. |
| @@ -402,19 +404,20 @@ | |
| 404 | #if !defined(_WIN32) |
| 405 | struct timeval tv[2]; |
| 406 | memset(tv, 0, sizeof(tv[0])*2); |
| 407 | tv[0].tv_sec = newMTime; |
| 408 | tv[1].tv_sec = newMTime; |
| 409 | char *zMbcs = fossil_utf8_to_filename(zFilename); |
| 410 | utimes(zMbcs, tv); |
| 411 | #else |
| 412 | struct _utimbuf tb; |
| 413 | wchar_t *zMbcs = fossil_utf8_to_filename(zFilename); |
| 414 | tb.actime = newMTime; |
| 415 | tb.modtime = newMTime; |
| 416 | _wutime(zMbcs, &tb); |
| 417 | #endif |
| 418 | fossil_filename_free(zMbcs); |
| 419 | } |
| 420 | |
| 421 | /* |
| 422 | ** COMMAND: test-set-mtime |
| 423 | ** |
| @@ -441,16 +444,17 @@ | |
| 444 | /* |
| 445 | ** Delete a file. |
| 446 | */ |
| 447 | void file_delete(const char *zFilename){ |
| 448 | #ifdef _WIN32 |
| 449 | wchar_t *z = fossil_utf8_to_filename(zFilename); |
| 450 | _wunlink(z); |
| 451 | #else |
| 452 | char *z = fossil_utf8_to_filename(zFilename); |
| 453 | unlink(zFilename); |
| 454 | #endif |
| 455 | fossil_filename_free(z); |
| 456 | } |
| 457 | |
| 458 | /* |
| 459 | ** Create the directory named in the argument, if it does not already |
| 460 | ** exist. If forceFlag is 1, delete any prior non-directory object |
| @@ -464,18 +468,18 @@ | |
| 468 | if( !forceFlag ) return 1; |
| 469 | file_delete(zName); |
| 470 | } |
| 471 | if( rc!=1 ){ |
| 472 | #if defined(_WIN32) |
| 473 | wchar_t *zMbcs = fossil_utf8_to_filename(zName); |
| 474 | rc = _wmkdir(zMbcs); |
| 475 | #else |
| 476 | char *zMbcs = fossil_utf8_to_filename(zName); |
| 477 | rc = mkdir(zName, 0755); |
| 478 | #endif |
| 479 | fossil_filename_free(zMbcs); |
| 480 | return rc; |
| 481 | } |
| 482 | return 0; |
| 483 | } |
| 484 | |
| 485 | /* |
| 486 |