Diff
Not logged in

Differences From Artifact [6fc0771be1]:

To Artifact [eaad71e0f9]:


70
71
72
73
74
75
76
77

78
79

80
81
82
83
84
85
86
70
71
72
73
74
75
76

77
78

79
80
81
82
83
84
85
86







-
+

-
+







  if( isWd && g.allowSymlinks ){
    return lstat(zFilename, buf);
  }else{
    return stat(zFilename, buf);
  }
#else
  int rc = 0;
  wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename);
  wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
  rc = _wstati64(zMbcs, buf);
  fossil_unicode_free(zMbcs);
  fossil_filename_free(zMbcs);
  return rc;
#endif
}

/*
** Fill in the fileStat variable for the file named zFilename.
** If zFilename==0, then use the previous value of fileStat if
301
302
303
304
305
306
307
308

309
310

311
312
313
314
315
316
317
301
302
303
304
305
306
307

308
309

310
311
312
313
314
315
316
317







-
+

-
+









/*
** Wrapper around the access() system call.
*/
int file_access(const char *zFilename, int flags){
#ifdef _WIN32
  wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename);
  wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
  int rc = _waccess(zMbcs, flags);
  fossil_unicode_free(zMbcs);
  fossil_filename_free(zMbcs);
#else
  int rc = access(zFilename, flags);
#endif
  return rc;
}

/*
403
404
405
406
407
408
409
410

411
412
413
414

415
416
417
418
419
420
421
403
404
405
406
407
408
409

410
411
412
413

414
415
416
417
418
419
420
421







-
+



-
+







  struct timeval tv[2];
  memset(tv, 0, sizeof(tv[0])*2);
  tv[0].tv_sec = newMTime;
  tv[1].tv_sec = newMTime;
  utimes(zFilename, tv);
#else
  struct _utimbuf tb;
  wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename);
  wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
  tb.actime = newMTime;
  tb.modtime = newMTime;
  _wutime(zMbcs, &tb);
  fossil_unicode_free(zMbcs);
  fossil_filename_free(zMbcs);
#endif
}

/*
** COMMAND: test-set-mtime
**
** Usage: %fossil test-set-mtime FILENAME DATE/TIME
439
440
441
442
443
444
445
446

447
448

449
450
451
452
453
454
455
439
440
441
442
443
444
445

446
447

448
449
450
451
452
453
454
455







-
+

-
+







}

/*
** Delete a file.
*/
void file_delete(const char *zFilename){
#ifdef _WIN32
  wchar_t *z = fossil_utf8_to_unicode(zFilename);
  wchar_t *z = fossil_utf8_to_filename(zFilename);
  _wunlink(z);
  fossil_unicode_free(z);
  fossil_filename_free(z);
#else
  unlink(zFilename);
#endif
}

/*
** Create the directory named in the argument, if it does not already
463
464
465
466
467
468
469
470

471
472

473
474
475
476
477
478
479
463
464
465
466
467
468
469

470
471

472
473
474
475
476
477
478
479







-
+

-
+







  if( rc==2 ){
    if( !forceFlag ) return 1;
    file_delete(zName);
  }
  if( rc!=1 ){
#if defined(_WIN32)
    int rc;
    wchar_t *zMbcs = fossil_utf8_to_unicode(zName);
    wchar_t *zMbcs = fossil_utf8_to_filename(zName);
    rc = _wmkdir(zMbcs);
    fossil_unicode_free(zMbcs);
    fossil_filename_free(zMbcs);
    return rc;
#else
    return mkdir(zName, 0755);
#endif
  }
  return 0;
}
1119
1120
1121
1122
1123
1124
1125
1126

1127
1128

1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142

1143
1144

1145
1146
1147
1148
1149
1150
1119
1120
1121
1122
1123
1124
1125

1126
1127

1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141

1142
1143

1144
1145
1146
1147
1148
1149
1150







-
+

-
+













-
+

-
+







/*
** Return the value of an environment variable as UTF8.
** Use fossil_filename_free() to release resources.
*/
char *fossil_getenv(const char *zName){
#ifdef _WIN32
  wchar_t *uName = fossil_utf8_to_unicode(zName);
  wchar_t *uName = fossil_utf8_to_filename(zName);
  void *zValue = _wgetenv(uName);
  fossil_unicode_free(uName);
  fossil_filename_free(uName);
#else
  char *zValue = getenv(zName);
#endif
  if( zValue ) zValue = fossil_filename_to_utf8(zValue);
  return zValue;
}

/*
** Like fopen() but always takes a UTF8 argument.
*/
FILE *fossil_fopen(const char *zName, const char *zMode){
#ifdef _WIN32
  wchar_t *uMode = fossil_utf8_to_unicode(zMode);
  wchar_t *uName = fossil_utf8_to_unicode(zName);
  wchar_t *uName = fossil_utf8_to_filename(zName);
  FILE *f = _wfopen(uName, uMode);
  fossil_unicode_free(uName);
  fossil_filename_free(uName);
  fossil_unicode_free(uMode);
#else
  FILE *f = fopen(zName, zMode);
#endif
  return f;
}