Index: cpp/frams/virtfile/stdiofile.cpp
===================================================================
--- cpp/frams/virtfile/stdiofile.cpp	(revision 247)
+++ cpp/frams/virtfile/stdiofile.cpp	(revision 281)
@@ -7,15 +7,20 @@
 #include <common/nonstd_stdio.h>
 #include <common/framsg.h>
+#include <common/Convert.h>
 
-VirtFILE* StdioFileSystem::Vfopen(const char* path,const char*mode)
+VirtFILE* StdioFileSystem::Vfopen(const char *path, const char *mode)
 {
 	//printFM("Vfopen %s %s",path,mode);
 #ifdef USE_MFILE
-	MFILE *f=mfopen(path,mode);
+	MFILE *f = mfopen(path, mode);
 #else
-	FILE *f=fopen(path,mode);
+#ifdef _WIN32
+	FILE *f = _wfopen(Convert::utf8ToUtf16(path).c_str(), Convert::strTOwstr(mode).c_str());
+#else
+	FILE *f = fopen(path, mode);
+#endif
 #endif
 	//printFM("%p",f);
-	if (f) return new StdioFILE(f,path); else return 0;
+	if (f) return new StdioFILE(f, path); else return 0;
 }
 
@@ -23,5 +28,9 @@
 {
 	//printFM("Vopendir %s",path);
-	DIR *d=opendir(path);
+#ifdef _WIN32
+	DIRTYPE *d = wopendir(Convert::utf8ToUtf16(path).c_str());
+#else
+	DIR *d = opendir(path);
+#endif
 	//printFM("%p",d);
 	if (d) return new StdioDIR(d); else return 0;
@@ -48,4 +57,11 @@
 {
 	//printFM("Vreaddir %s",dir);
+#ifdef _WIN32
+	wdirent *wde=wreaddir(dir);
+	if (wde==NULL) return NULL;
+	strcpy(de.d_name, Convert::wstrToUtf8(wde->d_name).c_str());
+	return &de;
+#else
 	return readdir(dir);
+#endif
 }
Index: cpp/frams/virtfile/stdiofile.h
===================================================================
--- cpp/frams/virtfile/stdiofile.h	(revision 247)
+++ cpp/frams/virtfile/stdiofile.h	(revision 281)
@@ -15,81 +15,103 @@
 #include <common/nonstd_dir.h>
 
-class StdioFileSystem: public VirtFileSystem
+class StdioFileSystem : public VirtFileSystem
 {
 public:
-VirtFILE *Vfopen(const char* path,const char*mode);
-int Vfexists(const char* path);
-VirtDIR *Vopendir(const char* path);
+	VirtFILE *Vfopen(const char *path, const char *mode);
+	int Vfexists(const char* path);
+	VirtDIR *Vopendir(const char* path);
 };
 
 #ifdef USE_MFILE
-class StdioFILE: public VirtFILE
+class StdioFILE : public VirtFILE
 {
-  protected:
-MFILE *file;
-SString path;
-  public:
-StdioFILE(MFILE *f) {file=f;}
-StdioFILE(MFILE *f,const SString& p) {file=f;path=p;}
-static void setStdio();
-size_t Vread(void *ptr, size_t size, size_t nmemb) {return mfread(ptr,size,nmemb,file);}
-size_t Vwrite(const void *ptr, size_t size, size_t nmemb) {return mfwrite(ptr,size,nmemb,file);}
-int Veof() {return mfeof(file);}
-int Vputs(const char *s) {return mfputs(s,file);}
-char *Vgets(char *s, int size) {return mfgets(s,size,file);}
-int Vseek(long offset, int whence) {return mfseek(file,offset,whence);}
-long Vtell() {return mftell(file);}
-int Vflush() {return 0;/*NOT IMPLEMENTED!*/;}
-const char* VgetPath() {return path;}
+protected:
+	MFILE *file;
+	SString path;
+public:
+	StdioFILE(MFILE *f) { file = f; }
+	StdioFILE(MFILE *f, const SString& p) { file = f; path = p; }
+	static void setStdio();
+	size_t Vread(void *ptr, size_t size, size_t nmemb) { return mfread(ptr, size, nmemb, file); }
+	size_t Vwrite(const void *ptr, size_t size, size_t nmemb) { return mfwrite(ptr, size, nmemb, file); }
+	int Veof() { return mfeof(file); }
+	int Vputs(const char *s) { return mfputs(s, file); }
+	char *Vgets(char *s, int size) { return mfgets(s, size, file); }
+	int Vseek(long offset, int whence) { return mfseek(file, offset, whence); }
+	long Vtell() { return mftell(file); }
+	int Vflush() { return 0; /*NOT IMPLEMENTED!*/ }
+	const char* VgetPath() { return path; }
 
-~StdioFILE() {if (file) mfclose(file);}
+	~StdioFILE() { if (file) mfclose(file); }
 };
 #else
-class StdioFILE: public VirtFILE
+class StdioFILE : public VirtFILE
 {
-  protected:
-FILE *file;
-SString path;
-  public:
-StdioFILE(FILE *f) {file=f;}
-StdioFILE(FILE *f,const SString& p) {file=f;path=p;}
-static void setStdio();
-size_t Vread(void *ptr, size_t size, size_t nmemb) {return fread(ptr,size,nmemb,file);}
-size_t Vwrite(const void *ptr, size_t size, size_t nmemb) {return fwrite(ptr,size,nmemb,file);}
-int Veof() {return feof(file);}
-int Vputc(int c) {return fputc(c,file);}
-int Vputs(const char *s) {return fputs(s,file);}
-int Vgetc() {return fgetc(file);}
-char *Vgets(char *s, int size) {return fgets(s,size,file);}
-int Vprintf(const char *format, va_list args) { return vfprintf(file,format,args); }
-int Vseek(long offset, int whence) {return fseek(file,offset,whence);}
-long Vtell() {return ftell(file);}
-void Vrewind() {rewind(file);}
-int Vflush() {return fflush(file);}
-const char* VgetPath() {return path;}
+protected:
+	FILE *file;
+	SString path;
+public:
+	StdioFILE(FILE *f) { file = f; }
+	StdioFILE(FILE *f, const SString& p) { file = f; path = p; }
+	static void setStdio();
+	size_t Vread(void *ptr, size_t size, size_t nmemb) { return fread(ptr, size, nmemb, file); }
+	size_t Vwrite(const void *ptr, size_t size, size_t nmemb) { return fwrite(ptr, size, nmemb, file); }
+	int Veof() { return feof(file); }
+	int Vputc(int c) { return fputc(c, file); }
+	int Vputs(const char *s) { return fputs(s, file); }
+	int Vgetc() { return fgetc(file); }
+	char *Vgets(char *s, int size) { return fgets(s, size, file); }
+	int Vprintf(const char *format, va_list args) { return vfprintf(file, format, args); }
+	int Vseek(long offset, int whence) { return fseek(file, offset, whence); }
+	long Vtell() { return ftell(file); }
+	void Vrewind() { rewind(file); }
+	int Vflush() { return fflush(file); }
+	const char* VgetPath() { return path; }
 
-~StdioFILE() {if (file) fclose(file);}
+	~StdioFILE() { if (file) fclose(file); }
 };
 #endif
 
-class StdioDIR: public VirtDIR
+
+#ifdef _WIN32
+#ifdef __BORLANDC__
+ typedef wDIR DIRTYPE;
+#else
+ typedef WDIR DIRTYPE;
+#endif
+#else
+ typedef DIR DIRTYPE;
+#endif
+
+class StdioDIR : public VirtDIR
 {
-DIR *dir;
-  public:
-StdioDIR(DIR* d):dir(d) {}
-~StdioDIR() {if (dir) closedir(dir);}
-dirent* Vreaddir();
+	DIRTYPE *dir;
+#ifdef _WIN32
+	dirent de; //only used to convert wide string names (wdirent) to utf8 (dirent)
+#endif
+public:
+	StdioDIR(DIRTYPE *d) : dir(d) {}
+	~StdioDIR()
+	{
+#ifdef _WIN32
+		if (dir) wclosedir(dir);
+#else
+		if (dir) closedir(dir);
+#endif
+	}
+	dirent* Vreaddir();
 };
 
-class StdioFILEDontClose: public StdioFILE
+class StdioFILEDontClose : public StdioFILE
 {
-  public:
+public:
 #ifdef USE_MFILE
-StdioFILEDontClose(MFILE *f):StdioFILE(f) {}
+	StdioFILEDontClose(MFILE *f) : StdioFILE(f) {}
 #else
-StdioFILEDontClose(FILE *f):StdioFILE(f) {}
+	StdioFILEDontClose(FILE *f) : StdioFILE(f) {}
 #endif
-~StdioFILEDontClose() {file=0;}
+	~StdioFILEDontClose() { file = 0; }
 };
 
 #endif
+
