Index: Make.rules.in
===================================================================
RCS file: /home/wine/wine/Make.rules.in,v
retrieving revision 1.186
diff -u -r1.186 Make.rules.in
--- Make.rules.in	7 May 2005 12:39:58 -0000	1.186
+++ Make.rules.in	20 Jun 2005 19:44:08 -0000
@@ -52,7 +52,7 @@
 LINT      = @LINT@
 LINTFLAGS = @LINTFLAGS@
 FONTFORGE = @FONTFORGE@
-INCLUDES     = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
+INCLUDES     = -I$(SRCDIR) -I. $(PREINCL) -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
 EXTRACFLAGS  = @EXTRACFLAGS@
 ALLCFLAGS    = $(INCLUDES) $(DEFS) $(DLLFLAGS) $(EXTRACFLAGS) $(CPPFLAGS) $(CFLAGS)
 ALLLINTFLAGS = $(INCLUDES) $(DEFS) $(LINTFLAGS)
Index: programs/winefile/Makefile.in
===================================================================
RCS file: /home/wine/wine/programs/winefile/Makefile.in,v
retrieving revision 1.12
diff -u -r1.12 Makefile.in
--- programs/winefile/Makefile.in	6 Jun 2005 10:02:43 -0000	1.12
+++ programs/winefile/Makefile.in	20 Jun 2005 19:49:26 -0000
@@ -1,16 +1,18 @@
-EXTRADEFS = -D__WINE__
+EXTRADEFS = -D__WINE__ -DUNICODE
 TOPSRCDIR = @top_srcdir@
 TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = winefile.exe
 APPMODE   = -mwindows
-IMPORTS   = shell32 comdlg32 comctl32 ole32 mpr version user32 gdi32 advapi32 kernel32
+PREINCL   = -I$(TOPSRCDIR)/include/msvcrt
+IMPORTS   = msvcrt shell32 comdlg32 comctl32 ole32 mpr version user32 gdi32 advapi32 kernel32
 EXTRALIBS = -luuid
 
 C_SRCS = \
 	license.c \
 	splitpath.c \
+	unixcalls.c \
 	winefile.c
 
 RC_SRCS = rsrc.rc
@@ -22,5 +24,11 @@
 	winefile.ico
 
 @MAKE_PROG_RULES@
+
+UNIX_INCLUDES = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include
+UNIX_CFLAGS = $(UNIX_INCLUDES) $(DEFS) $(DLLFLAGS) $(EXTRACFLAGS) $(CPPFLAGS) $(CFLAGS)
+
+unixcalls.o: unixcalls.c
+	$(CC) -c $(UNIX_CFLAGS) -o $@ $<
 
 ### Dependencies:
Index: programs/winefile/winefile.h
===================================================================
RCS file: /home/wine/wine/programs/winefile/winefile.h,v
retrieving revision 1.15
diff -u -r1.15 winefile.h
--- programs/winefile/winefile.h	20 Jun 2005 11:45:39 -0000	1.15
+++ programs/winefile/winefile.h	20 Jun 2005 19:44:21 -0000
@@ -44,6 +44,7 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <locale.h>
+#include <time.h>
 
 #ifndef __WINE__
 #include <malloc.h> /* for alloca() */
@@ -153,4 +154,19 @@
 #else
 extern void _splitpath(const CHAR* path, CHAR* drv, CHAR* dir, CHAR* name, CHAR* ext);
 #endif
+
+/* functions in unixcalls.c */
+
+extern void call_getcwd(char* buffer, size_t len);
+extern void* call_opendir(const char* path);
+extern int call_readdir(void* pdir, char* name, unsigned* pinode);
+extern void call_closedir(void* pdir);
+
+extern int call_stat(
+	const char* path, int* pis_dir,
+	unsigned long* psize_low, unsigned long* psize_high,
+	time_t* patime, time_t* pmtime,
+	unsigned long* plinks
+);
+
 #endif
Index: programs/winefile/winefile.c
===================================================================
RCS file: /home/wine/wine/programs/winefile/winefile.c,v
retrieving revision 1.56
diff -u -r1.56 winefile.c
--- programs/winefile/winefile.c	17 Jun 2005 10:11:37 -0000	1.56
+++ programs/winefile/winefile.c	20 Jun 2005 19:44:23 -0000
@@ -26,15 +26,6 @@
 #include "winefile.h"
 #include "resource.h"
 
-/* for read_directory_unix() */
-#if !defined(_NO_EXTENSIONS) && defined(__WINE__)
-#include <dirent.h>
-#include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#include <time.h>
-#endif
 
 #ifdef _NO_EXTENSIONS
 #undef _LEFT_FILES
@@ -180,6 +171,7 @@
 
 static int last_split;
 
+
 /* some common string constants */
 const static TCHAR sEmpty[] = {'\0'};
 const static TCHAR sSpace[] = {' ', '\0'};
@@ -461,23 +453,35 @@
 	Entry* first_entry = NULL;
 	Entry* last = NULL;
 	Entry* entry;
+	void* pdir;
 
-	int level = dir->level + 1;
+#ifdef UNICODE
+	char cpath[MAX_PATH];
 
-	DIR* pdir = opendir(path);
+	WideCharToMultiByte(CP_UNIXCP, 0, path, -1, cpath, MAX_PATH, NULL, NULL);
+#else
+	const char* cpath = path;
+#endif
+
+	pdir = call_opendir(cpath);
+
+	int level = dir->level + 1;
 
 	if (pdir) {
-		struct stat st;
-		struct dirent* ent;
-		TCHAR buffer[MAX_PATH], *p;
+		char buffer[MAX_PATH];
+		time_t atime, mtime;
+		unsigned inode;
+		int is_dir;
+		const char* s;
+		char* p;
 
-		for(p=buffer; *path; )
-			*p++ = *path++;
+		for(p=buffer,s=cpath; *s; )
+			*p++ = *s++;
 
 		if (p==buffer || p[-1]!='/')
 			*p++ = '/';
 
-		while((ent=readdir(pdir))) {
+		while(call_readdir(pdir, p, &inode)) {
 			entry = alloc_entry();
 
 			if (!first_entry)
@@ -488,27 +492,28 @@
 
 			entry->etype = ET_UNIX;
 
-			lstrcpy(entry->data.cFileName, ent->d_name);
-			entry->data.dwFileAttributes = ent->d_name[0]=='.'? FILE_ATTRIBUTE_HIDDEN: 0;
+#ifdef UNICODE
+			MultiByteToWideChar(CP_UNIXCP, 0, p, -1, entry->data.cFileName, MAX_PATH);
+#else
+			lstrcpy(entry->data.cFileName, p);
+#endif
 
-			strcpy(p, ent->d_name);
+			entry->data.dwFileAttributes = p[0]=='.'? FILE_ATTRIBUTE_HIDDEN: 0;
 
-			if (!stat(buffer, &st)) {
-				if (S_ISDIR(st.st_mode))
+			if (!call_stat(buffer, &is_dir,
+				&entry->data.nFileSizeLow, &entry->data.nFileSizeHigh,
+				&atime, &mtime, &entry->bhfi.nNumberOfLinks))
+			{
+				if (is_dir)
 					entry->data.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
 
-				entry->data.nFileSizeLow = st.st_size & 0xFFFFFFFF;
-				entry->data.nFileSizeHigh = st.st_size >> 32;
-
 				memset(&entry->data.ftCreationTime, 0, sizeof(FILETIME));
-				time_to_filetime(&st.st_atime, &entry->data.ftLastAccessTime);
-				time_to_filetime(&st.st_mtime, &entry->data.ftLastWriteTime);
+				time_to_filetime(&atime, &entry->data.ftLastAccessTime);
+				time_to_filetime(&mtime, &entry->data.ftLastWriteTime);
 
-				entry->bhfi.nFileIndexLow = ent->d_ino;
+				entry->bhfi.nFileIndexLow = inode;
 				entry->bhfi.nFileIndexHigh = 0;
 
-				entry->bhfi.nNumberOfLinks = st.st_nlink;
-
 				entry->bhfi_valid = TRUE;
 			} else {
 				entry->data.nFileSizeLow = 0;
@@ -528,7 +533,7 @@
 		if (last)
 			last->next = NULL;
 
-		closedir(pdir);
+		call_closedir(pdir);
 	}
 
 	dir->down = first_entry;
@@ -684,6 +689,7 @@
 }
 
 
+#ifndef UNICODE
 static HRESULT path_from_pidlA(IShellFolder* folder, LPITEMIDLIST pidl, LPSTR buffer, int len)
 {
 	STRRET str;
@@ -699,6 +705,7 @@
 
 	return hr;
 }
+#endif
 
 static HRESULT path_from_pidlW(IShellFolder* folder, LPITEMIDLIST pidl, LPWSTR buffer, int len)
 {
@@ -1095,7 +1102,7 @@
 {
 	const WIN32_FIND_DATA* fd1 = &(*(const Entry* const*)arg1)->data;
 	const WIN32_FIND_DATA* fd2 = &(*(const Entry* const*)arg2)->data;
-	const TCHAR *name1, *name2, *ext1, *ext2;
+	LPCTSTR name1, name2, ext1, ext2;
 
 	int cmp = compareType(fd1, fd2);
 	if (cmp)
@@ -2282,18 +2289,28 @@
 #ifdef __WINE__
 				case ID_DRIVE_UNIX_FS: {
 					TCHAR path[MAX_PATH];
+#ifdef UNICODE
+					char cpath[MAX_PATH];
+#endif
 					ChildWnd* child;
 
 					if (activate_fs_window(RS(b1,IDS_UNIXFS)))
 						break;
 
-					getcwd(path, MAX_PATH);
+
+#ifdef UNICODE
+					call_getcwd(cpath, MAX_PATH);
+					MultiByteToWideChar(CP_UNIXCP, 0, cpath, -1, path, MAX_PATH);
+#else
+					call_getcwd(path, MAX_PATH);
+#endif
 					child = alloc_child_window(path, NULL, hwnd);
 
 					if (!create_child_window(child))
 						free(child);
 					break;}
 #endif
+
 #ifdef _SHELL_FOLDERS
 				case ID_DRIVE_SHELL_NS: {
 					TCHAR path[MAX_PATH];
@@ -3756,20 +3773,6 @@
 
 	return TRUE;
 }
-
-#ifdef UNICODE
-static BOOL launch_fileA(HWND hwnd, LPSTR cmd, UINT nCmdShow)
-{
-	HINSTANCE hinst = ShellExecuteA(hwnd, NULL/*operation*/, cmd, NULL/*parameters*/, NULL/*dir*/, nCmdShow);
-
-	if ((int)hinst <= 32) {
-		display_error(hwnd, GetLastError());
-		return FALSE;
-	}
-
-	return TRUE;
-}
-#endif
 
 
 static BOOL launch_entry(Entry* entry, HWND hwnd, UINT nCmdShow)
Index: include/tchar.h
===================================================================
RCS file: /home/wine/wine/include/tchar.h,v
retrieving revision 1.24
diff -u -r1.24 tchar.h
--- include/tchar.h	19 Oct 2004 03:57:18 -0000	1.24
+++ include/tchar.h	20 Jun 2005 19:44:16 -0000
@@ -23,10 +23,6 @@
 #error Wine should not include tchar.h internally
 #endif
 
-#if defined(_UNICODE) || defined(_MBCS)
-#error You must use msvcrt when building in Unicode/MBCS mode
-#endif
-
 #ifdef __cplusplus
 extern "C" {
 #endif
Index: programs/winefile/unixcalls.c
--- /dev/null	2004-04-06 15:27:52.000000000 +0200
+++ programs/winefile/unixcalls.c	2005-06-12 15:11:15.573561272 +0200
@@ -0,0 +1,90 @@
+/*
+ * Winefile
+ *
+ * Copyright 2004 Martin Fuchs
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifdef __WINE__
+
+#include <unistd.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <dirent.h>
+
+
+void call_getcwd(char* buffer, size_t len)
+{
+	getcwd(buffer, len);
+}
+
+
+#ifndef _NO_EXTENSIONS
+
+/* proxy functions to call UNIX readdir() */
+
+void* call_opendir(const char* path)
+{
+	DIR* pdir = opendir(path);
+
+	return pdir;
+}
+
+int call_readdir(void* pdir, char* name, unsigned* inode)
+{
+	struct dirent* ent = readdir((DIR*)pdir);
+
+	if (!ent)
+		return 0;
+
+	strcpy(name, ent->d_name);
+	*inode = ent->d_ino;
+
+	return 1;
+}
+
+void call_closedir(void* pdir)
+{
+	closedir((DIR*)pdir);
+}
+
+
+/* proxy function to call UNIX stat() */
+int call_stat(
+	const char* path, int* pis_dir,
+	unsigned long* psize_low, unsigned long* psize_high,
+	time_t* patime, time_t* pmtime,
+	unsigned long* plinks
+)
+{
+	struct stat st;
+
+	if (stat(path, &st))
+		return 1;
+
+	*pis_dir = S_ISDIR(st.st_mode);
+	*psize_low = st.st_size & 0xFFFFFFFF;
+	*psize_high = 0; /*st.st_size >> 32;*/
+	*patime = st.st_atime;
+	*pmtime = st.st_mtime;
+
+	return 0;
+}
+
+#endif /* _NO_EXTENSIONS */
+
+#endif /* __WINE__ */
