Changeset 820


Ignore:
Timestamp:
10/09/18 02:00:49 (11 days ago)
Author:
Maciej Komosinski
Message:

More complete implementation of directories in the virtual filesystem for Android

Location:
cpp/common/virtfile
Files:
2 edited

Legend:

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

    r425 r820  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    2929        //log_printf("Vopendir %s",path);
    3030#ifdef __ANDROID__
    31         int resources_prefix_length=getAppResourcesDir().length();
     31        int resources_prefix_length = getAppResourcesDir().length();
    3232        if (strncmp(path, getAppResourcesDir().c_str(), resources_prefix_length) == 0) //it is a resources dir
    3333        {
    34                 VirtDIR *vd = AndroidAPK_DIR::opendir(path+resources_prefix_length+1); //+1 because we also skip '/' and start with a "relative" dir, otherwise it does not work.
     34                VirtDIR *vd = AndroidAPK_DIR::opendir(path + resources_prefix_length + 1); //+1 because we also skip '/' and start with a "relative" dir, otherwise it does not work.
    3535                return vd;
    3636        }
     
    5151}
    5252
     53bool StdioFileSystem::Vdirexists(const char* path, bool is_writable)
     54{
     55#ifdef __ANDROID__
     56        int resources_prefix_length = getAppResourcesDir().length();
     57        if (strncmp(path, getAppResourcesDir().c_str(), resources_prefix_length) == 0) //it is a resources dir
     58        {
     59                if (is_writable)
     60                        return false;
     61                VirtDIR *vd = AndroidAPK_DIR::opendir(path + resources_prefix_length + 1); //+1 because we also skip '/' and start with a "relative" dir, otherwise it does not work.
     62                if (vd != NULL)
     63                {
     64                        delete vd;
     65                        return true;
     66                }
     67                else
     68                {
     69                        return false;
     70                }
     71        }
     72#endif
     73        return directoryExists(path, is_writable);
     74}
     75
     76
     77
     78
     79
     80
    5381#ifndef NO_STD_IN_OUT_ERR
    5482void StdioFILE::setStdio()
     
    6795        //log_printf("Vreaddir %s",dir);
    6896#ifdef _WIN32
    69         wdirent *wde=wreaddir(dir);
    70         if (wde==NULL) return NULL;
     97        wdirent *wde = wreaddir(dir);
     98        if (wde == NULL) return NULL;
    7199        strcpy(de.d_name, Convert::wstrToUtf8(wde->d_name).c_str());
    72100        return &de;
  • cpp/common/virtfile/stdiofile.h

    r425 r820  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    1717        VirtDIR *Vopendir(const char* path);
    1818        bool Vmkdir(const char* path) { return makeDirectory(path); }
    19         bool Vdirexists(const char* path,bool is_writable) { return directoryExists(path,is_writable); }
     19        bool Vdirexists(const char* path, bool is_writable);
    2020};
    2121
     
    2626        MFILE *file;
    2727public:
    28         StdioFILE(MFILE *f):VirtFILE("") { file = f; }
    29         StdioFILE(MFILE *f, const char* p):VirtFILE(p) { file = f; }
     28        StdioFILE(MFILE *f) :VirtFILE("") { file = f; }
     29        StdioFILE(MFILE *f, const char* p) :VirtFILE(p) { file = f; }
    3030#ifndef NO_STD_IN_OUT_ERR
    3131        static void setStdio();
     
    4848        FILE *file;
    4949public:
    50         StdioFILE(FILE *f):VirtFILE("") { file = f; }
    51         StdioFILE(FILE *f, const char* p):VirtFILE(p) { file = f; }
     50        StdioFILE(FILE *f) :VirtFILE("") { file = f; }
     51        StdioFILE(FILE *f, const char* p) :VirtFILE(p) { file = f; }
    5252#ifndef NO_STD_IN_OUT_ERR
    5353        static void setStdio();
     
    7373#ifdef _WIN32
    7474#ifdef __BORLANDC__
    75  typedef wDIR DIRTYPE;
     75typedef wDIR DIRTYPE;
    7676#else
    77  typedef WDIR DIRTYPE;
     77typedef WDIR DIRTYPE;
    7878#endif
    7979#else
    80  typedef DIR DIRTYPE;
     80typedef DIR DIRTYPE;
    8181#endif
    8282
     
    111111};
    112112
    113 class StdioFileSystem_autoselect: public StdioFileSystem
     113class StdioFileSystem_autoselect : public StdioFileSystem
    114114{
    115115public:
    116 StdioFileSystem_autoselect()
     116        StdioFileSystem_autoselect()
    117117        {
    118         VirtFILE::selectFileSystem(this);
     118                VirtFILE::selectFileSystem(this);
    119119        }
    120120};
Note: See TracChangeset for help on using the changeset viewer.