c++ file handling

Discussion in 'iOS Programming' started by aerlfredith, Feb 25, 2013.

  1. aerlfredith, Feb 25, 2013
    Last edited by a moderator: Feb 25, 2013

    aerlfredith macrumors newbie

    Joined:
    Feb 25, 2013
    #1
    Hi,

    I'm trying to load files from a directory in my appbundle in iOS the simulator does this fine but the std::ifstream doesnt open on the iPad i use for testing.
    Is this an issue with file access privileges or do i have to do something different,
    Code:
    	std::ifstream is;
    
    	is.open(fileString.c_str(), std::ios::binary);
    	if (!is.is_open())
            {
                   printf("FAIL");
            }
    
    Thanks, Jan
     
  2. lloyddean, Feb 25, 2013
    Last edited: Feb 25, 2013

    lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #2
    I do the following for my C++ game code -

    Code:
    [[NSFileManager defaultManager] changeCurrentDirectoryPath:[[NSBundle mainBundle] resourcePath]];
    
    std::ifstream	ifs("Token Map 1.data", std::ios::binary);
    if ( ifs.is_open() )
    {
        _thexder.load(ifs);
    }
    
     
  3. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #3
    You probably need a full path, not just the file name.
     
  4. aerlfredith thread starter macrumors newbie

    Joined:
    Feb 25, 2013
    #4
    :/

    I found out that the iOS simulator is not case-sensitive but the device IS case-sensitive
     
  5. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #5
    That's correct. The Sim uses the Mac file system, which is case-insensitive and the device file system is case-sensitive.
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    Unless you install your Mac OSX on a case-sensitive HFS+ volume of course :p
     
  7. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #7
    Anyone who does that should be smitten. ;-)

    And if OP did that we wouldn't be having this conversation.
     

Share This Page