Fossil SCM

win32: files with invalid chars were not deleted sometimes with "fossil update"

jan.nijtmans 2013-01-28 13:09 UTC ticket-d17d6e5b17
Commit d9aa512e203bd53a049c83876fa511c2f0a1c8c4
1 file changed +18 -14
+18 -14
--- src/file.c
+++ src/file.c
@@ -64,23 +64,24 @@
6464
** Fill stat buf with information received from stat() or lstat().
6565
** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on.
6666
**
6767
*/
6868
static int fossil_stat(const char *zFilename, struct stat *buf, int isWd){
69
+ int rc;
6970
#if !defined(_WIN32)
71
+ char *zMbcs = fossil_utf8_to_filename(zFilename);
7072
if( isWd && g.allowSymlinks ){
71
- return lstat(zFilename, buf);
73
+ rc = lstat(zMbcs, buf);
7274
}else{
73
- return stat(zFilename, buf);
75
+ rc = stat(zMbcs, buf);
7476
}
7577
#else
76
- int rc = 0;
7778
wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
7879
rc = _wstati64(zMbcs, buf);
80
+#endif
7981
fossil_filename_free(zMbcs);
8082
return rc;
81
-#endif
8283
}
8384
8485
/*
8586
** Fill in the fileStat variable for the file named zFilename.
8687
** If zFilename==0, then use the previous value of fileStat if
@@ -305,14 +306,15 @@
305306
*/
306307
int file_access(const char *zFilename, int flags){
307308
#ifdef _WIN32
308309
wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
309310
int rc = _waccess(zMbcs, flags);
310
- fossil_filename_free(zMbcs);
311311
#else
312
- int rc = access(zFilename, flags);
312
+ char *zMbcs = fossil_utf8_to_filename(zFilename);
313
+ int rc = access(zMbcs, flags);
313314
#endif
315
+ fossil_filename_free(zMbcs);
314316
return rc;
315317
}
316318
317319
/*
318320
** Find an unused filename similar to zBase with zSuffix appended.
@@ -402,19 +404,20 @@
402404
#if !defined(_WIN32)
403405
struct timeval tv[2];
404406
memset(tv, 0, sizeof(tv[0])*2);
405407
tv[0].tv_sec = newMTime;
406408
tv[1].tv_sec = newMTime;
407
- utimes(zFilename, tv);
409
+ char *zMbcs = fossil_utf8_to_filename(zFilename);
410
+ utimes(zMbcs, tv);
408411
#else
409412
struct _utimbuf tb;
410413
wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
411414
tb.actime = newMTime;
412415
tb.modtime = newMTime;
413416
_wutime(zMbcs, &tb);
414
- fossil_filename_free(zMbcs);
415417
#endif
418
+ fossil_filename_free(zMbcs);
416419
}
417420
418421
/*
419422
** COMMAND: test-set-mtime
420423
**
@@ -441,16 +444,17 @@
441444
/*
442445
** Delete a file.
443446
*/
444447
void file_delete(const char *zFilename){
445448
#ifdef _WIN32
446
- wchar_t *z = fossil_utf8_to_unicode(zFilename);
449
+ wchar_t *z = fossil_utf8_to_filename(zFilename);
447450
_wunlink(z);
448
- fossil_unicode_free(z);
449451
#else
452
+ char *z = fossil_utf8_to_filename(zFilename);
450453
unlink(zFilename);
451454
#endif
455
+ fossil_filename_free(z);
452456
}
453457
454458
/*
455459
** Create the directory named in the argument, if it does not already
456460
** exist. If forceFlag is 1, delete any prior non-directory object
@@ -464,18 +468,18 @@
464468
if( !forceFlag ) return 1;
465469
file_delete(zName);
466470
}
467471
if( rc!=1 ){
468472
#if defined(_WIN32)
469
- int rc;
470473
wchar_t *zMbcs = fossil_utf8_to_filename(zName);
471474
rc = _wmkdir(zMbcs);
475
+#else
476
+ char *zMbcs = fossil_utf8_to_filename(zName);
477
+ rc = mkdir(zName, 0755);
478
+#endif
472479
fossil_filename_free(zMbcs);
473480
return rc;
474
-#else
475
- return mkdir(zName, 0755);
476
-#endif
477481
}
478482
return 0;
479483
}
480484
481485
/*
482486
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button