Index: src/file.c ================================================================== --- src/file.c +++ src/file.c @@ -79,23 +79,23 @@ ** Fill stat buf with information received from stat() or lstat(). ** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on. ** */ static int fossil_stat(const char *zFilename, struct fossilStat *buf, int isWd){ -#if !defined(_WIN32) int rc; - char *zMbcs = fossil_utf8_to_filename(zFilename); + void *zMbcs = fossil_utf8_to_filename(zFilename); +#if !defined(_WIN32) if( isWd && g.allowSymlinks ){ rc = lstat(zMbcs, buf); }else{ rc = stat(zMbcs, buf); } +#else + rc = win32_stat(zMbcs, buf, isWd); +#endif fossil_filename_free(zMbcs); return rc; -#else - return win32_stat(zFilename, buf, isWd); -#endif } /* ** Fill in the fileStat variable for the file named zFilename. ** If zFilename==0, then use the previous value of fileStat if @@ -316,38 +316,40 @@ /* ** Wrapper around the access() system call. */ int file_access(const char *zFilename, int flags){ + int rc; + void *zMbcs = fossil_utf8_to_filename(zFilename); #ifdef _WIN32 - return win32_access(zFilename, flags); + rc = win32_access(zMbcs, flags); #else - char *zMbcs = fossil_utf8_to_filename(zFilename); - int rc = access(zMbcs, flags); + rc = access(zMbcs, flags); +#endif fossil_filename_free(zMbcs); return rc; -#endif } /* ** Wrapper around the chdir() system call. ** If bChroot=1, do a chroot to this dir as well ** (UNIX only) */ int file_chdir(const char *zChDir, int bChroot){ + int rc; + void *zPath = fossil_utf8_to_filename(zChDir); #ifdef _WIN32 - return win32_chdir(zChDir, bChroot); + rc = win32_chdir(zPath, bChroot); #else - char *zPath = fossil_utf8_to_filename(zChDir); int rc = chdir(zPath); if( !rc && bChroot ){ rc = chroot(zPath); if( !rc ) rc = chdir("/"); } +#endif fossil_filename_free(zPath); return rc; -#endif } /* ** Find an unused filename similar to zBase with zSuffix appended. ** Index: src/lookslike.c ================================================================== --- src/lookslike.c +++ src/lookslike.c @@ -371,15 +371,15 @@ ** ** FILENAME is the name of a file to check for textual content in the UTF-8 ** and/or UTF-16 encodings. */ void looks_like_utf_test_cmd(void){ - Blob blob; /* the contents of the specified file */ - int fUtf8; /* return value of starts_with_utf8_bom() */ - int fUtf16; /* return value of starts_with_utf16_bom() */ - int fUnicode; /* return value of could_be_utf16() */ - int lookFlags; /* output flags from looks_like_utf8/utf16() */ + Blob blob; /* the contents of the specified file */ + int fUtf8 = 0; /* return value of starts_with_utf8_bom() */ + int fUtf16 = 0; /* return value of starts_with_utf16_bom() */ + int fUnicode = 0; /* return value of could_be_utf16() */ + int lookFlags = 0; /* output flags from looks_like_utf8/utf16() */ int bRevUtf16 = 0; /* non-zero -> UTF-16 byte order reversed */ int fForceUtf8 = find_option("utf8",0,0)!=0; int fForceUtf16 = find_option("utf16",0,0)!=0; const char *zCount = find_option("limit","n",1); int nRepeat = 1; Index: src/winfile.c ================================================================== --- src/winfile.c +++ src/winfile.c @@ -32,15 +32,13 @@ /* ** Fill stat buf with information received from stat() or lstat(). ** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on. ** */ -int win32_stat(const char *zFilename, struct fossilStat *buf, int isWd){ +int win32_stat(const wchar_t *zFilename, struct fossilStat *buf, int isWd){ WIN32_FILE_ATTRIBUTE_DATA attr; - wchar_t *zMbcs = fossil_utf8_to_filename(zFilename); - int rc = GetFileAttributesExW(zMbcs, GetFileExInfoStandard, &attr); - fossil_filename_free(zMbcs); + int rc = GetFileAttributesExW(zFilename, GetFileExInfoStandard, &attr); if( rc ){ ULARGE_INTEGER ull; ull.LowPart = attr.ftLastWriteTime.dwLowDateTime; ull.HighPart = attr.ftLastWriteTime.dwHighDateTime; buf->st_mode = (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? @@ -53,11 +51,11 @@ /* ** Wrapper around the access() system call. This code was copied from Tcl ** 8.6 and then modified. */ -int win32_access(const char *zFilename, int flags){ +int win32_access(const wchar_t *zFilename, int flags){ int rc = 0; PSECURITY_DESCRIPTOR pSd = NULL; unsigned long size; PSID pSid = NULL; BOOL sidDefaulted; @@ -67,12 +65,11 @@ HANDLE hToken = NULL; DWORD desiredAccess = 0, grantedAccess = 0; BOOL accessYesNo = FALSE; PRIVILEGE_SET privSet; DWORD privSetSize = sizeof(PRIVILEGE_SET); - wchar_t *zMbcs = fossil_utf8_to_filename(zFilename); - DWORD attr = GetFileAttributesW(zMbcs); + DWORD attr = GetFileAttributesW(zFilename); if( attr==INVALID_FILE_ATTRIBUTES ){ /* * File might not exist. */ @@ -114,11 +111,11 @@ /* * First find out how big the buffer needs to be. */ size = 0; - GetFileSecurityW(zMbcs, + GetFileSecurityW(zFilename, OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION | LABEL_SECURITY_INFORMATION, 0, 0, &size); /* @@ -146,11 +143,11 @@ /* * Call GetFileSecurity() for real. */ - if( !GetFileSecurityW(zMbcs, + if( !GetFileSecurityW(zFilename, OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION | LABEL_SECURITY_INFORMATION, pSd, size, &size) ){ /* * Error getting owner SD @@ -243,23 +240,18 @@ impersonated = FALSE; } if( pSd!=NULL ){ HeapFree(GetProcessHeap(), 0, pSd); } - fossil_filename_free(zMbcs); return rc; } /* ** Wrapper around the chdir() system call. -** If bChroot=1, do a chroot to this dir as well -** (UNIX only) */ -int win32_chdir(const char *zChDir, int bChroot){ - wchar_t *zPath = fossil_utf8_to_filename(zChDir); - int rc = (int)!SetCurrentDirectoryW(zPath); - fossil_filename_free(zPath); +int win32_chdir(const void *zChDir, int bChroot){ + int rc = (int)!SetCurrentDirectoryW(zChDir); return rc; } /* ** Get the current working directory.