Changeset 523 for cpp/common


Ignore:
Timestamp:
07/03/16 17:36:35 (8 years ago)
Author:
Maciej Komosinski
Message:

No more overloading of fopen/fclose/... functions for the VirtFILE class. #define VIRTFILE_OVERLOADING to enable overloading only when necessary.

Location:
cpp/common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpp/common/stl-util.cpp

    r460 r523  
    7777        bool ok = false;
    7878#ifdef USE_VIRTFILE
    79         if (!isAbsolutePath(filename))
     79//      if (!isAbsolutePath(filename))
    8080        {
    8181                VirtFILE *f=Vfopen(filename,FOPEN_READ_BINARY);
     
    8989                }
    9090        }
    91         else
     91//      else
    9292#endif
    9393        {
     
    120120bool writeCompleteFile(const char* filename, const string& text, bool warn_on_fail)
    121121{
     122#ifdef USE_VIRTFILE
     123        VirtFILE *f = Vfopen(filename, FOPEN_WRITE_BINARY);
     124        bool ok = f != NULL;
     125        if (f)
     126        {
     127                int zapisane = f->Vwrite(text.c_str(), text.length(), 1);
     128                delete f;
     129                ok &= zapisane == 1;
     130        }
     131#else
    122132        MFILE *f = mfopen(filename, FOPEN_WRITE_BINARY);
    123133        bool ok = f != NULL;
     
    128138                ok &= zapisane == 1;
    129139        }
     140#endif
    130141        if (warn_on_fail && !ok)
    131                 logPrintf("stl-util", "writeCompleteFile", LOG_WARN, "couldn't write file '%s'", filename);
     142                logPrintf("stl-util", "writeCompleteFile", LOG_WARN, "Couldn't write file '%s'", filename);
    132143        return ok;
    133144}
  • cpp/common/virtfile/virtfile.h

    r427 r523  
    136136DLLEXP bool Vdirexists(const char* path, bool is_writable);
    137137
     138#ifdef VIRTFILE_OVERLOADING
     139//may be needed for redefine... or if someone simply prefers overloading ;-)
     140
    138141DLLEXP int fread(void *ptr, size_t size, size_t nmemb, VirtFILE* f);
    139142DLLEXP int fwrite(const void *ptr, size_t size, size_t nmemb, VirtFILE* f);
    140 
    141143
    142144//since we want our own feof(VirtFILE*) function and some systems unfortunately define feof as a macro, we need to #undef it. Same as in virtfile.cpp
     
    174176DLLEXP int closedir(VirtDIR* d);
    175177
     178#endif //VIRTFILE_OVERLOADING
     179
    176180#endif
    177 
Note: See TracChangeset for help on using the changeset viewer.