Fossil

Diff
Login

Differences From Artifact [0609b8972a]:

To Artifact [91b76476f2]:


653
654
655
656
657
658
659
660

661
662
663
664
665
666
667

668
669
670
671
672
673
674
653
654
655
656
657
658
659

660
661
662
663
664
665
666

667
668
669
670
671
672
673
674







-
+






-
+







  char *zPwdUtf8;
  int nPwd;
  int i;
  wchar_t zPwd[2000];
  if( _wgetcwd(zPwd, sizeof(zPwd)/sizeof(zPwd[0])-1)==0 ){
    fossil_fatal("cannot find the current working directory.");
  }
  zPwdUtf8 = fossil_unicode_to_utf8(zPwd);
  zPwdUtf8 = fossil_filename_to_utf8(zPwd);
  nPwd = strlen(zPwdUtf8);
  if( nPwd > nBuf-1 ){
    fossil_fatal("pwd too big: max %d\n", nBuf-1);
  }
  for(i=0; zPwdUtf8[i]; i++) if( zPwdUtf8[i]=='\\' ) zPwdUtf8[i] = '/';
  memcpy(zBuf, zPwdUtf8, nPwd+1);
  fossil_unicode_free(zPwdUtf8);
  fossil_filename_free(zPwdUtf8);
#else
  if( getcwd(zBuf, nBuf-1)==0 ){
    if( errno==ERANGE ){
      fossil_fatal("pwd too big: max %d\n", nBuf-1);
    }else{
      fossil_fatal("cannot find current working directory; %s",
                   strerror(errno));
1010
1011
1012
1013
1014
1015
1016
1017

1018
1019
1020
1021
1022
1023
1024
1010
1011
1012
1013
1014
1015
1016

1017
1018
1019
1020
1021
1022
1023
1024







-
+







  const char *zDir = ".";
  int cnt = 0;

#if defined(_WIN32)
  wchar_t zTmpPath[MAX_PATH];

  if( GetTempPathW(MAX_PATH, zTmpPath) ){
    azDirs[0] = fossil_unicode_to_utf8(zTmpPath);
    azDirs[0] = fossil_filename_to_utf8(zTmpPath);
  }

  azDirs[1] = fossil_getenv("TEMP");
  azDirs[2] = fossil_getenv("TMP");
#endif


1091
1092
1093
1094
1095
1096
1097
1098

1099
1100
1101
1102
1103
1104
1105

1106
1107
1108
1109
1110
1111
1112
1091
1092
1093
1094
1095
1096
1097

1098
1099
1100
1101
1102
1103
1104

1105
1106
1107
1108
1109
1110
1111
1112







-
+






-
+







# define closedir _wclosedir
#endif /* _WIN32 */

#endif /* INTERFACE */

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

/*