Ignore:
Timestamp:
12/27/14 01:01:43 (9 years ago)
Author:
Maciej Komosinski
Message:

Support for wide char (unicode) names of files and directories under Windows, internally encoded as char* utf-8

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/virtfile/stdiofile.cpp

    r227 r281  
    77#include <common/nonstd_stdio.h>
    88#include <common/framsg.h>
     9#include <common/Convert.h>
    910
    10 VirtFILE* StdioFileSystem::Vfopen(const char* path,const char*mode)
     11VirtFILE* StdioFileSystem::Vfopen(const char *path, const char *mode)
    1112{
    1213        //printFM("Vfopen %s %s",path,mode);
    1314#ifdef USE_MFILE
    14         MFILE *f=mfopen(path,mode);
     15        MFILE *f = mfopen(path, mode);
    1516#else
    16         FILE *f=fopen(path,mode);
     17#ifdef _WIN32
     18        FILE *f = _wfopen(Convert::utf8ToUtf16(path).c_str(), Convert::strTOwstr(mode).c_str());
     19#else
     20        FILE *f = fopen(path, mode);
     21#endif
    1722#endif
    1823        //printFM("%p",f);
    19         if (f) return new StdioFILE(f,path); else return 0;
     24        if (f) return new StdioFILE(f, path); else return 0;
    2025}
    2126
     
    2328{
    2429        //printFM("Vopendir %s",path);
    25         DIR *d=opendir(path);
     30#ifdef _WIN32
     31        DIRTYPE *d = wopendir(Convert::utf8ToUtf16(path).c_str());
     32#else
     33        DIR *d = opendir(path);
     34#endif
    2635        //printFM("%p",d);
    2736        if (d) return new StdioDIR(d); else return 0;
     
    4857{
    4958        //printFM("Vreaddir %s",dir);
     59#ifdef _WIN32
     60        wdirent *wde=wreaddir(dir);
     61        if (wde==NULL) return NULL;
     62        strcpy(de.d_name, Convert::wstrToUtf8(wde->d_name).c_str());
     63        return &de;
     64#else
    5065        return readdir(dir);
     66#endif
    5167}
Note: See TracChangeset for help on using the changeset viewer.