Use of undeclared identifier 'chdir' and 'access'

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
IrrlichtForiOS
Posts: 61
Joined: Mon Oct 08, 2012 1:46 pm

Use of undeclared identifier 'chdir' and 'access'

Post by IrrlichtForiOS »

Hi there,

we're using irrlicht engine within out two iPad Apps and since this morning I'm running into problems while trying to compile CFIleSystem.cpp.

Code: Select all

//! Creates an empty filelist
IFileList* CFileSystem::createEmptyFileList(const io::path& path, bool ignoreCase, bool ignorePaths)
{
    return new CFileList(path, ignoreCase, ignorePaths);
}
 
 
//! determines if a file exists and would be able to be opened.
bool CFileSystem::existFile(const io::path& filename) const
{
    for (u32 i=0; i < FileArchives.size(); ++i)
        if (FileArchives[i]->getFileList()->findFile(filename)!=-1)
            return true;
 
#if defined(_MSC_VER)
    #if defined(_IRR_WCHAR_FILESYSTEM)
        return (_waccess(filename.c_str(), 0) != -1);
    #else
        return (_access(filename.c_str(), 0) != -1);
    #endif
#elif defined(F_OK)
    #if defined(_IRR_WCHAR_FILESYSTEM)
        return (_waccess(filename.c_str(), F_OK) != -1);
    #else
        return (access(filename.c_str(), F_OK) != -1);
    #endif
#else
    return (access(filename.c_str(), 0) != -1); //FIXME: use of undeclared identifier 'access'
#endif
}

Code: Select all

//! Changes the current Working Directory to the given string.
bool CFileSystem::changeWorkingDirectoryTo(const io::path& newDirectory)
{
    bool success=false;
 
    if (FileSystemType != FILESYSTEM_NATIVE)
    {
        WorkingDirectory[FILESYSTEM_VIRTUAL] = newDirectory;
        // is this empty string constant really intended?
        flattenFilename(WorkingDirectory[FILESYSTEM_VIRTUAL], _IRR_TEXT(""));
        success = true;
    }
    else
    {
        WorkingDirectory[FILESYSTEM_NATIVE] = newDirectory;
 
#if defined(_MSC_VER)
    #if defined(_IRR_WCHAR_FILESYSTEM)
        success = (_wchdir(newDirectory.c_str()) == 0);
    #else
        success = (_chdir(newDirectory.c_str()) == 0);
    #endif
#else
    #if defined(_IRR_WCHAR_FILESYSTEM)
        success = (_wchdir(newDirectory.c_str()) == 0);
    #else
        success = (chdir(newDirectory.c_str()) == 0); //FIXME: use of undeclared identifier 'chdir'
    #endif
#endif
    }
 
    return success;
}
I really hope that somebody explain me, how to get both symbols/methods declared, so that It's compiling fine again.

Kind regards,
Daniel
IrrlichtForiOS
Posts: 61
Joined: Mon Oct 08, 2012 1:46 pm

Solution

Post by IrrlichtForiOS »

I solved this issues by checking also for iOS instead of checking for OSX only.

CFileSystem.cpp - 28

Code: Select all

#if defined (_IRR_WINDOWS_API_)
    #if !defined ( _WIN32_WCE )
        #include <direct.h> // for _chdir
        #include <io.h> // for _access
        #include <tchar.h>
    #endif
#else
    #if (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_) || defined(_IRR_IOS_PLATFORM_) || defined(_IRR_ANDROID_PLATFORM_))
        #include <stdio.h>
        #include <stdlib.h>
        #include <string.h>
        #include <limits.h>
        #include <sys/types.h>
        #include <dirent.h>
        #include <sys/stat.h>
        #include <unistd.h>
    #endif
#endif
CuteAlien
Admin
Posts: 9644
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Use of undeclared identifier 'chdir' and 'access'

Post by CuteAlien »

Thanks, svn got changed correspondingly.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply