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

More complete implementation of directories in the virtual filesystem for Android

File:
1 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;
Note: See TracChangeset for help on using the changeset viewer.