Changeset 301 for cpp


Ignore:
Timestamp:
01/19/15 01:50:31 (10 years ago)
Author:
Maciej Komosinski
Message:

VirtFILE can have fields and still be used as a DLL thanks to declspec(dllimport)

Location:
cpp/frams/virtfile
Files:
2 edited

Legend:

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

    r298 r301  
    1212VirtFileSystem *VirtFILE::vfs = NULL;
    1313
    14 VirtFILE *Vfopen(const char* path,const char*mode)
    15 {
     14//#define DEBUG_DLL_CALLS
     15
     16VirtFILE *Vfopen(const char* path,const char* mode)
     17{
     18#ifdef DEBUG_DLL_CALLS
     19printf("VirtFILE::Vfopen %s %s (vfs=%p)\n",path,mode,VirtFILE::vfs);
     20#endif
    1621return VirtFILE::vfs ? VirtFILE::vfs->Vfopen(path,mode) : NULL;
    1722}
     
    1924VirtDIR *Vopendir(const char* path)
    2025{
     26#ifdef DEBUG_DLL_CALLS
     27printf("VirtFILE::Vfopendir %s (vfs=%p)\n",path,VirtFILE::vfs);
     28#endif
    2129return VirtFILE::vfs ? VirtFILE::vfs->Vopendir(path) : NULL;
    2230}
     
    4553{}
    4654
    47 void VirtFILE::selectFileSystem(VirtFileSystem *s) {vfs=s;}
     55void VirtFILE::selectFileSystem(VirtFileSystem *s)
     56{
     57vfs=s;
     58#ifdef DEBUG_DLL_CALLS
     59::printf("VirtFILE::selectFileSystem: %p := %p\n",vfs,s);
     60#endif
     61}
    4862
    4963int VirtFILE::Vprintf(const char *format, va_list args)
     
    8094
    8195// base class only returns NULL/false/not supported - implementations perform the actual work
    82 VirtFILE* VirtFileSystem::Vfopen(const char* path,const char*mode) {return NULL;}
     96VirtFILE* VirtFileSystem::Vfopen(const char* path,const char* mode) {return NULL;}
    8397bool VirtFileSystem::Vfexists(const char* path) {return false;}
    8498VirtDIR* VirtFileSystem::Vopendir(const char* path) {return NULL;}
     
    147161//////////
    148162
    149 VirtFILE *ChainFileSystem::Vfopen(const char* path, const char*mode)
    150 {
     163
     164ChainFileSystem::ChainFileSystem(VirtFileSystem *_chain)
     165{
     166        chain=_chain;
     167#ifdef DEBUG_DLL_CALLS
     168printf("ChainFileSystem constructor: %p := %p\n",chain,_chain);
     169#endif
     170}
     171
     172
     173VirtFILE *ChainFileSystem::Vfopen(const char* path, const char* mode)
     174{
     175#ifdef DEBUG_DLL_CALLS
     176printf("ChainFileSystem::Vfopen %s %s (chain=%p)\n",path,mode,chain);
     177#endif
    151178        return (chain != NULL) ? chain->Vfopen(path, mode) : NULL;
    152179}
     
    159186VirtDIR *ChainFileSystem::Vopendir(const char* path)
    160187{
     188#ifdef DEBUG_DLL_CALLS
     189printf("ChainFileSystem::Vfopendir %s (chain=%p)\n",path,chain);
     190#endif
    161191        return (chain != NULL) ? chain->Vopendir(path) : NULL;
    162192}
  • cpp/frams/virtfile/virtfile.h

    r295 r301  
    1111#include <string>
    1212using std::string;
    13 //#include <dirent.h> //to jest inkludowane przez powyzsze
    14 //struct dirent; //kiedys byla ta linia jak nie bylo jeszcze implementacji windowsowej dirent, ale borlandowi sie nie podoba jak s¹ obie
    1513
    16 #ifdef DLLEXPORTACTIVE  //tylko w tym pliku uzyte
     14#ifdef DLLEXPORTACTIVE  //defined in the project that makes the DLL
    1715#define DLLEXP __declspec(dllexport)
    1816#else
     17#ifdef __BORLANDC__ //assuming that all executables produced by borland use the DLL
     18#define DLLEXP __declspec(dllimport) //without dllimport, fields in objects would have separate instances in DLL and in EXE
     19#else
    1920#define DLLEXP
     21#endif
    2022#endif
    2123
     
    102104public:
    103105        VirtFileSystem *chain;
    104         ChainFileSystem(VirtFileSystem *_chain = NULL) :chain(_chain) {}
     106        ChainFileSystem(VirtFileSystem *_chain = NULL);
    105107        VirtFILE *Vfopen(const char* path, const char*mode);
    106108        bool Vfexists(const char* path);
Note: See TracChangeset for help on using the changeset viewer.