Changeset 374 for cpp/common


Ignore:
Timestamp:
04/23/15 03:18:25 (10 years ago)
Author:
Maciej Komosinski
Message:

Under _WIN32, mfopen() now redirects to a function mfile_wfopen() that converts arguments to wide char and then uses _wfopen()

Location:
cpp/common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpp/common/nonstd_stdio.cpp

    r372 r374  
    1818#endif
    1919
     20
     21
     22#ifdef _WIN32
     23FILE* mfile_wfopen(const char *path, const char *mode) //to avoid converting args into wide char in all occurrences of mfopen()
     24{
     25        return _wfopen(Convert::utf8ToUtf16(path).c_str(), Convert::strTOwstr(mode).c_str());
     26}
     27#endif
     28
    2029bool fileExists(const char* path)
    2130{
    2231        //lepiej gdyby uzywalo stat bo mfopen mogloby cos niepotrzebnie wczytywac przy otwarciu pliku ale mfopen wiadomo ze zadziala wszedzie tak samo
    23 #ifdef _WIN32
    24         MFILE *f = mfopen(Convert::utf8ToUtf16(path).c_str(), Convert::strTOwstr(FOPEN_READ_BINARY).c_str());
    25 #else
    2632        MFILE *f = mfopen(path, FOPEN_READ_BINARY);
    27 #endif
    2833        if (f == NULL) return false;
    2934        mfclose(f);
     
    105110{
    106111        int size;
    107 #ifdef _WIN32
    108         MFILE *f = mfopen(Convert::utf8ToUtf16(path).c_str(), Convert::strTOwstr(FOPEN_READ_BINARY).c_str());
    109 #else
    110112        MFILE *f = mfopen(path, FOPEN_READ_BINARY);
    111 #endif
    112113        if (f == NULL) return -1;
    113114        size = getFileSize(f);
  • cpp/common/nonstd_stdio.h

    r295 r374  
    7979typedef FILE MFILE;
    8080#ifdef _WIN32
    81  #define mfopen _wfopen
     81 FILE* mfile_wfopen(const char *path, const char *mode);
     82 #define mfopen mfile_wfopen
    8283#else
    8384 #define mfopen fopen
  • cpp/common/stl-util.cpp

    r372 r374  
    9292#endif
    9393        {
    94 #ifdef _WIN32
    95                 MFILE *f = mfopen(Convert::utf8ToUtf16(filename).c_str(), Convert::strTOwstr(FOPEN_READ_BINARY).c_str());
    96 #else
    9794                MFILE *f = mfopen(filename, FOPEN_READ_BINARY);
    98 #endif
    9995                if (f)
    10096                {
     
    124120bool writeCompleteFile(const char* filename, const string& text, bool warn_on_fail)
    125121{
    126 #ifdef _WIN32
    127         MFILE *f = mfopen(Convert::utf8ToUtf16(filename).c_str(), Convert::strTOwstr(FOPEN_WRITE_BINARY).c_str());
    128 #else
    129122        MFILE *f = mfopen(filename, FOPEN_WRITE_BINARY);
    130 #endif
    131123        bool ok = f != NULL;
    132124        if (f)
Note: See TracChangeset for help on using the changeset viewer.